1 //== SubEngine.h - Interface of the subengine of CoreEngine --------*- C++ -*-//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the interface of a subengine of the CoreEngine.
12 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_CLANG_GR_SUBENGINE_H
14 #define LLVM_CLANG_GR_SUBENGINE_H
16 #include "clang/Analysis/ProgramPoint.h"
17 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
23 class LocationContext;
28 template <typename PP> class GenericNodeBuilder;
29 class AnalysisManager;
30 class ExplodedNodeSet;
35 class StmtNodeBuilder;
36 class BranchNodeBuilder;
37 class IndirectGotoNodeBuilder;
38 class SwitchNodeBuilder;
39 class EndOfFunctionNodeBuilder;
40 class CallEnterNodeBuilder;
41 class CallExitNodeBuilder;
46 virtual ~SubEngine() {}
48 virtual const GRState* getInitialState(const LocationContext *InitLoc) = 0;
50 virtual AnalysisManager &getAnalysisManager() = 0;
52 virtual GRStateManager &getStateManager() = 0;
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;
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;
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;
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;
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;
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;
81 // Generate the entry node of the callee.
82 virtual void processCallEnter(CallEnterNodeBuilder &builder) = 0;
84 // Generate the first post callsite node.
85 virtual void processCallExit(CallExitNodeBuilder &builder) = 0;
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;
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;
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;
102 inline const GRState* processRegionChange(const GRState* state,
103 const MemRegion* MR) {
104 return processRegionChanges(state, &MR, &MR+1);
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;
112 } // end GR namespace
114 } // end clang namespace