clang  6.0.0svn
BodyFarm.h
Go to the documentation of this file.
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 
23 namespace clang {
24 
25 class ASTContext;
26 class FunctionDecl;
27 class ObjCMethodDecl;
28 class ObjCPropertyDecl;
29 class Stmt;
30 class CodeInjector;
31 
32 class BodyFarm {
33 public:
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 
42  /// Remove copy constructor to avoid accidental copying.
43  BodyFarm(const BodyFarm &other) = delete;
44 
45 private:
46  typedef llvm::DenseMap<const Decl *, Optional<Stmt *>> BodyMap;
47 
48  ASTContext &C;
49  BodyMap Bodies;
50  CodeInjector *Injector;
51 };
52 } // namespace clang
53 
54 #endif
An instance of this class is created to represent a function declaration or definition.
Definition: Decl.h:1697
Stmt - This represents one statement.
Definition: Stmt.h:66
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:139
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:149
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
BodyFarm(ASTContext &C, CodeInjector *injector)
Definition: BodyFarm.h:34
Dataflow Directional Tag Classes.
CodeInjector is an interface which is responsible for injecting AST of function definitions that may ...
Definition: CodeInjector.h:36
Stmt * getBody(const FunctionDecl *D)
Factory method for creating bodies for ordinary functions.
Definition: BodyFarm.cpp:649