1//== BodyFarm.h - Factory for conjuring up fake bodies -------------*- C++ -*-// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// BodyFarm is a factory for creating faux implementations for functions/methods 11// for analysis purposes. 12// 13//===----------------------------------------------------------------------===// 14 15#ifndef LLVM_CLANG_LIB_ANALYSIS_BODYFARM_H 16#define LLVM_CLANG_LIB_ANALYSIS_BODYFARM_H 17 18#include "clang/AST/DeclBase.h" 19#include "clang/Basic/LLVM.h" 20#include "llvm/ADT/DenseMap.h" 21#include "llvm/ADT/Optional.h" 22 23namespace clang { 24 25class ASTContext; 26class FunctionDecl; 27class ObjCMethodDecl; 28class ObjCPropertyDecl; 29class Stmt; 30class CodeInjector; 31 32class BodyFarm { 33public: 34 BodyFarm(ASTContext &C, CodeInjector *injector) : C(C), Injector(injector) {} 35 36 /// Factory method for creating bodies for ordinary functions. 37 Stmt *getBody(const FunctionDecl *D); 38 39 /// Factory method for creating bodies for Objective-C properties. 40 Stmt *getBody(const ObjCMethodDecl *D); 41 42private: 43 typedef llvm::DenseMap<const Decl *, Optional<Stmt *> > BodyMap; 44 45 ASTContext &C; 46 BodyMap Bodies; 47 CodeInjector *Injector; 48}; 49} 50 51#endif 52