]> granicus.if.org Git - clang/blob - include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h
[analyzer] Remove CallEnterNodeBuilder and simplify ExprEngine::processCallEnter().
[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 #include "clang/StaticAnalyzer/Core/PathSensitive/Store.h"
19
20 namespace clang {
21
22 class CFGBlock;
23 class CFGElement;
24 class LocationContext;
25 class Stmt;
26
27 namespace ento {
28   
29 struct NodeBuilderContext;
30 class AnalysisManager;
31 class ExplodedNodeSet;
32 class ExplodedNode;
33 class ProgramState;
34 class ProgramStateManager;
35 class BlockCounter;
36 class BranchNodeBuilder;
37 class IndirectGotoNodeBuilder;
38 class SwitchNodeBuilder;
39 class EndOfFunctionNodeBuilder;
40 class NodeBuilderWithSinks;
41 class MemRegion;
42
43 class SubEngine {
44   virtual void anchor();
45 public:
46   virtual ~SubEngine() {}
47
48   virtual const ProgramState *getInitialState(const LocationContext *InitLoc) = 0;
49
50   virtual AnalysisManager &getAnalysisManager() = 0;
51
52   virtual ProgramStateManager &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, ExplodedNode* Pred,
57                                  unsigned StmtIdx, NodeBuilderContext *Ctx)=0;
58
59   /// Called by CoreEngine when it starts processing a CFGBlock.  The
60   /// SubEngine is expected to populate dstNodes with new nodes representing
61   /// updated analysis state, or generate no nodes at all if it doesn't.
62   virtual void processCFGBlockEntrance(NodeBuilderWithSinks &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                              NodeBuilderContext& BuilderCtx,
68                              ExplodedNode *Pred,
69                              ExplodedNodeSet &Dst,
70                              const CFGBlock *DstT,
71                              const CFGBlock *DstF) = 0;
72
73   /// Called by CoreEngine.  Used to generate successor
74   /// nodes by processing the 'effects' of a computed goto jump.
75   virtual void processIndirectGoto(IndirectGotoNodeBuilder& builder) = 0;
76
77   /// Called by CoreEngine.  Used to generate successor
78   /// nodes by processing the 'effects' of a switch statement.
79   virtual void processSwitch(SwitchNodeBuilder& builder) = 0;
80
81   /// Called by CoreEngine.  Used to generate end-of-path
82   /// nodes when the control reaches the end of a function.
83   virtual void processEndOfFunction(NodeBuilderContext& BC) = 0;
84
85   // Generate the entry node of the callee.
86   virtual void processCallEnter(CallEnter CE, ExplodedNode *Pred) = 0;
87
88   // Generate the first post callsite node.
89   virtual void processCallExit(ExplodedNode *Pred) = 0;
90
91   /// Called by ConstraintManager. Used to call checker-specific
92   /// logic for handling assumptions on symbolic values.
93   virtual const ProgramState *processAssume(const ProgramState *state,
94                                        SVal cond, bool assumption) = 0;
95
96   /// wantsRegionChangeUpdate - Called by ProgramStateManager to determine if a
97   ///  region change should trigger a processRegionChanges update.
98   virtual bool wantsRegionChangeUpdate(const ProgramState *state) = 0;
99
100   /// processRegionChanges - Called by ProgramStateManager whenever a change is made
101   ///  to the store. Used to update checkers that track region values.
102   virtual const ProgramState *
103   processRegionChanges(const ProgramState *state,
104                        const StoreManager::InvalidatedSymbols *invalidated,
105                        ArrayRef<const MemRegion *> ExplicitRegions,
106                        ArrayRef<const MemRegion *> Regions) = 0;
107
108
109   inline const ProgramState *
110   processRegionChange(const ProgramState *state,
111                       const MemRegion* MR) {
112     return processRegionChanges(state, 0, MR, MR);
113   }
114
115   /// printState - Called by ProgramStateManager to print checker-specific data.
116   virtual void printState(raw_ostream &Out, const ProgramState *State,
117                           const char *NL, const char *Sep) = 0;
118
119   /// Called by CoreEngine when the analysis worklist is either empty or the
120   //  maximum number of analysis steps have been reached.
121   virtual void processEndWorklist(bool hasWorkRemaining) = 0;
122 };
123
124 } // end GR namespace
125
126 } // end clang namespace
127
128 #endif