1 //== GRSubEngine.h - Interface of the subengine of GRCoreEngine ----*- 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 GRCoreEngine.
12 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_CLANG_ANALYSIS_GRSUBENGINE_H
14 #define LLVM_CLANG_ANALYSIS_GRSUBENGINE_H
16 #include "clang/Checker/PathSensitive/SVals.h"
20 class AnalysisManager;
27 class GRStmtNodeBuilder;
28 class GRBranchNodeBuilder;
29 class GRIndirectGotoNodeBuilder;
30 class GRSwitchNodeBuilder;
31 class GREndPathNodeBuilder;
32 class GRCallEnterNodeBuilder;
33 class GRCallExitNodeBuilder;
34 class LocationContext;
40 virtual ~GRSubEngine() {}
42 virtual const GRState* getInitialState(const LocationContext *InitLoc) = 0;
44 virtual AnalysisManager &getAnalysisManager() = 0;
46 virtual GRStateManager &getStateManager() = 0;
48 /// Called by GRCoreEngine. Used to generate new successor
49 /// nodes by processing the 'effects' of a block-level statement.
50 virtual void ProcessStmt(const CFGElement E, GRStmtNodeBuilder& builder) = 0;
52 /// Called by GRCoreEngine when start processing
53 /// a CFGBlock. This method returns true if the analysis should continue
54 /// exploring the given path, and false otherwise.
55 virtual bool ProcessBlockEntrance(const CFGBlock* B, const ExplodedNode *Pred,
56 GRBlockCounter BC) = 0;
58 /// Called by GRCoreEngine. Used to generate successor
59 /// nodes by processing the 'effects' of a branch condition.
60 virtual void ProcessBranch(const Stmt* Condition, const Stmt* Term,
61 GRBranchNodeBuilder& builder) = 0;
63 /// Called by GRCoreEngine. Used to generate successor
64 /// nodes by processing the 'effects' of a computed goto jump.
65 virtual void ProcessIndirectGoto(GRIndirectGotoNodeBuilder& builder) = 0;
67 /// Called by GRCoreEngine. Used to generate successor
68 /// nodes by processing the 'effects' of a switch statement.
69 virtual void ProcessSwitch(GRSwitchNodeBuilder& builder) = 0;
71 /// ProcessEndPath - Called by GRCoreEngine. Used to generate end-of-path
72 /// nodes when the control reaches the end of a function.
73 virtual void ProcessEndPath(GREndPathNodeBuilder& builder) = 0;
75 // Generate the entry node of the callee.
76 virtual void ProcessCallEnter(GRCallEnterNodeBuilder &builder) = 0;
78 // Generate the first post callsite node.
79 virtual void ProcessCallExit(GRCallExitNodeBuilder &builder) = 0;
81 /// Called by ConstraintManager. Used to call checker-specific
82 /// logic for handling assumptions on symbolic values.
83 virtual const GRState* ProcessAssume(const GRState *state,
84 SVal cond, bool assumption) = 0;
86 /// WantsRegionChangeUpdate - Called by GRStateManager to determine if a
87 /// region change should trigger a ProcessRegionChanges update.
88 virtual bool WantsRegionChangeUpdate(const GRState* state) = 0;
90 /// ProcessRegionChanges - Called by GRStateManager whenever a change is made
91 /// to the store. Used to update checkers that track region values.
92 virtual const GRState* ProcessRegionChanges(const GRState* state,
93 const MemRegion* const *Begin,
94 const MemRegion* const *End) = 0;
96 inline const GRState* ProcessRegionChange(const GRState* state,
97 const MemRegion* MR) {
98 return ProcessRegionChanges(state, &MR, &MR+1);
101 /// Called by GRCoreEngine when the analysis worklist is either empty or the
102 // maximum number of analysis steps have been reached.
103 virtual void ProcessEndWorklist(bool hasWorkRemaining) = 0;