Ted Kremenek | 14f779c | 2012-09-21 00:09:11 +0000 | [diff] [blame] | 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 | |
Benjamin Kramer | 2f5db8b | 2014-08-13 16:25:19 +0000 | [diff] [blame] | 15 | #ifndef LLVM_CLANG_LIB_ANALYSIS_BODYFARM_H |
| 16 | #define LLVM_CLANG_LIB_ANALYSIS_BODYFARM_H |
Ted Kremenek | 14f779c | 2012-09-21 00:09:11 +0000 | [diff] [blame] | 17 | |
Benjamin Kramer | fa51138 | 2016-02-02 11:06:57 +0000 | [diff] [blame] | 18 | #include "clang/AST/DeclBase.h" |
David Blaikie | 05785d1 | 2013-02-20 22:23:23 +0000 | [diff] [blame] | 19 | #include "clang/Basic/LLVM.h" |
Ted Kremenek | 14f779c | 2012-09-21 00:09:11 +0000 | [diff] [blame] | 20 | #include "llvm/ADT/DenseMap.h" |
Chandler Carruth | 3a02247 | 2012-12-04 09:13:33 +0000 | [diff] [blame] | 21 | #include "llvm/ADT/Optional.h" |
Ted Kremenek | 14f779c | 2012-09-21 00:09:11 +0000 | [diff] [blame] | 22 | |
| 23 | namespace clang { |
| 24 | |
| 25 | class ASTContext; |
Ted Kremenek | 14f779c | 2012-09-21 00:09:11 +0000 | [diff] [blame] | 26 | class FunctionDecl; |
Jordan Rose | 1a866cd | 2014-01-10 20:06:06 +0000 | [diff] [blame] | 27 | class ObjCMethodDecl; |
| 28 | class ObjCPropertyDecl; |
Ted Kremenek | 14f779c | 2012-09-21 00:09:11 +0000 | [diff] [blame] | 29 | class Stmt; |
Ted Kremenek | eeccb30 | 2014-08-27 15:14:15 +0000 | [diff] [blame] | 30 | class CodeInjector; |
Ted Kremenek | 14f779c | 2012-09-21 00:09:11 +0000 | [diff] [blame] | 31 | |
| 32 | class BodyFarm { |
| 33 | public: |
Ted Kremenek | eeccb30 | 2014-08-27 15:14:15 +0000 | [diff] [blame] | 34 | BodyFarm(ASTContext &C, CodeInjector *injector) : C(C), Injector(injector) {} |
Ted Kremenek | 14f779c | 2012-09-21 00:09:11 +0000 | [diff] [blame] | 35 | |
| 36 | /// Factory method for creating bodies for ordinary functions. |
| 37 | Stmt *getBody(const FunctionDecl *D); |
Jordan Rose | 1a866cd | 2014-01-10 20:06:06 +0000 | [diff] [blame] | 38 | |
| 39 | /// Factory method for creating bodies for Objective-C properties. |
Jordan Rose | ddf1966 | 2014-01-23 03:59:10 +0000 | [diff] [blame] | 40 | Stmt *getBody(const ObjCMethodDecl *D); |
Jordan Rose | 1a866cd | 2014-01-10 20:06:06 +0000 | [diff] [blame] | 41 | |
Ted Kremenek | 14f779c | 2012-09-21 00:09:11 +0000 | [diff] [blame] | 42 | private: |
David Blaikie | 05785d1 | 2013-02-20 22:23:23 +0000 | [diff] [blame] | 43 | typedef llvm::DenseMap<const Decl *, Optional<Stmt *> > BodyMap; |
Ted Kremenek | 14f779c | 2012-09-21 00:09:11 +0000 | [diff] [blame] | 44 | |
| 45 | ASTContext &C; |
| 46 | BodyMap Bodies; |
Ted Kremenek | eeccb30 | 2014-08-27 15:14:15 +0000 | [diff] [blame] | 47 | CodeInjector *Injector; |
Ted Kremenek | 14f779c | 2012-09-21 00:09:11 +0000 | [diff] [blame] | 48 | }; |
Alexander Kornienko | ab9db51 | 2015-06-22 23:07:51 +0000 | [diff] [blame] | 49 | } |
Ted Kremenek | 14f779c | 2012-09-21 00:09:11 +0000 | [diff] [blame] | 50 | |
| 51 | #endif |