]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h
MFV: Update to less v444.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / include / clang / StaticAnalyzer / Core / PathSensitive / SubEngine.h
1 //== SubEngine.h - Interface of the subengine of CoreEngine --------*- 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 // This file defines the interface of a subengine of the CoreEngine.
11 //
12 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_CLANG_GR_SUBENGINE_H
14 #define LLVM_CLANG_GR_SUBENGINE_H
15
16 #include "clang/Analysis/ProgramPoint.h"
17 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
18
19 namespace clang {
20
21 class CFGBlock;
22 class CFGElement;
23 class LocationContext;
24 class Stmt;
25
26 namespace ento {
27   
28 template <typename PP> class GenericNodeBuilder;
29 class AnalysisManager;
30 class ExplodedNodeSet;
31 class ExplodedNode;
32 class GRState;
33 class GRStateManager;
34 class BlockCounter;
35 class StmtNodeBuilder;
36 class BranchNodeBuilder;
37 class IndirectGotoNodeBuilder;
38 class SwitchNodeBuilder;
39 class EndOfFunctionNodeBuilder;
40 class CallEnterNodeBuilder;
41 class CallExitNodeBuilder;
42 class MemRegion;
43
44 class SubEngine {
45 public:
46   virtual ~SubEngine() {}
47
48   virtual const GRState* getInitialState(const LocationContext *InitLoc) = 0;
49
50   virtual AnalysisManager &getAnalysisManager() = 0;
51
52   virtual GRStateManager &getStateManager() = 0;
53
54   /// Called by CoreEngine. Used to generate new successor
55   /// nodes by processing the 'effects' of a block-level statement.
56   virtual void processCFGElement(const CFGElement E, StmtNodeBuilder& builder)=0;
57
58   /// Called by CoreEngine when it starts processing a CFGBlock.  The
59   /// SubEngine is expected to populate dstNodes with new nodes representing
60   /// updated analysis state, or generate no nodes at all if it doesn't.
61   virtual void processCFGBlockEntrance(ExplodedNodeSet &dstNodes,
62                             GenericNodeBuilder<BlockEntrance> &nodeBuilder) = 0;
63
64   /// Called by CoreEngine.  Used to generate successor
65   ///  nodes by processing the 'effects' of a branch condition.
66   virtual void processBranch(const Stmt* Condition, const Stmt* Term,
67                              BranchNodeBuilder& builder) = 0;
68
69   /// Called by CoreEngine.  Used to generate successor
70   /// nodes by processing the 'effects' of a computed goto jump.
71   virtual void processIndirectGoto(IndirectGotoNodeBuilder& builder) = 0;
72
73   /// Called by CoreEngine.  Used to generate successor
74   /// nodes by processing the 'effects' of a switch statement.
75   virtual void processSwitch(SwitchNodeBuilder& builder) = 0;
76
77   /// Called by CoreEngine.  Used to generate end-of-path
78   /// nodes when the control reaches the end of a function.
79   virtual void processEndOfFunction(EndOfFunctionNodeBuilder& builder) = 0;
80
81   // Generate the entry node of the callee.
82   virtual void processCallEnter(CallEnterNodeBuilder &builder) = 0;
83
84   // Generate the first post callsite node.
85   virtual void processCallExit(CallExitNodeBuilder &builder) = 0;
86
87   /// Called by ConstraintManager. Used to call checker-specific
88   /// logic for handling assumptions on symbolic values.
89   virtual const GRState* processAssume(const GRState *state,
90                                        SVal cond, bool assumption) = 0;
91
92   /// wantsRegionChangeUpdate - Called by GRStateManager to determine if a
93   ///  region change should trigger a processRegionChanges update.
94   virtual bool wantsRegionChangeUpdate(const GRState* state) = 0;
95
96   /// processRegionChanges - Called by GRStateManager whenever a change is made
97   ///  to the store. Used to update checkers that track region values.
98   virtual const GRState* processRegionChanges(const GRState* state,
99                                               const MemRegion* const *Begin,
100                                               const MemRegion* const *End) = 0;
101
102   inline const GRState* processRegionChange(const GRState* state,
103                                             const MemRegion* MR) {
104     return processRegionChanges(state, &MR, &MR+1);
105   }
106
107   /// Called by CoreEngine when the analysis worklist is either empty or the
108   //  maximum number of analysis steps have been reached.
109   virtual void processEndWorklist(bool hasWorkRemaining) = 0;
110 };
111
112 } // end GR namespace
113
114 } // end clang namespace
115
116 #endif