clang API Documentation
00001 //== BodyFarm.h - Factory for conjuring up fake bodies -------------*- C++ -*-// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // BodyFarm is a factory for creating faux implementations for functions/methods 00011 // for analysis purposes. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #ifndef LLVM_CLANG_LIB_ANALYSIS_BODYFARM_H 00016 #define LLVM_CLANG_LIB_ANALYSIS_BODYFARM_H 00017 00018 #include "clang/Basic/LLVM.h" 00019 #include "llvm/ADT/DenseMap.h" 00020 #include "llvm/ADT/Optional.h" 00021 00022 namespace clang { 00023 00024 class ASTContext; 00025 class Decl; 00026 class FunctionDecl; 00027 class ObjCMethodDecl; 00028 class ObjCPropertyDecl; 00029 class Stmt; 00030 class CodeInjector; 00031 00032 class BodyFarm { 00033 public: 00034 BodyFarm(ASTContext &C, CodeInjector *injector) : C(C), Injector(injector) {} 00035 00036 /// Factory method for creating bodies for ordinary functions. 00037 Stmt *getBody(const FunctionDecl *D); 00038 00039 /// Factory method for creating bodies for Objective-C properties. 00040 Stmt *getBody(const ObjCMethodDecl *D); 00041 00042 private: 00043 typedef llvm::DenseMap<const Decl *, Optional<Stmt *> > BodyMap; 00044 00045 ASTContext &C; 00046 BodyMap Bodies; 00047 CodeInjector *Injector; 00048 }; 00049 } 00050 00051 #endif