]> CyberLeo.Net >> Repos - FreeBSD/releng/9.0.git/blob - contrib/llvm/tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h
Copy stable/9 to releng/9.0 as part of the FreeBSD 9.0-RELEASE release
[FreeBSD/releng/9.0.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 #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 template <typename PP> class GenericNodeBuilder;
30 class AnalysisManager;
31 class ExplodedNodeSet;
32 class ExplodedNode;
33 class ProgramState;
34 class ProgramStateManager;
35 class BlockCounter;
36 class StmtNodeBuilder;
37 class BranchNodeBuilder;
38 class IndirectGotoNodeBuilder;
39 class SwitchNodeBuilder;
40 class EndOfFunctionNodeBuilder;
41 class CallEnterNodeBuilder;
42 class CallExitNodeBuilder;
43 class MemRegion;
44
45 class SubEngine {
46 public:
47   virtual ~SubEngine() {}
48
49   virtual const ProgramState *getInitialState(const LocationContext *InitLoc) = 0;
50
51   virtual AnalysisManager &getAnalysisManager() = 0;
52
53   virtual ProgramStateManager &getStateManager() = 0;
54
55   /// Called by CoreEngine. Used to generate new successor
56   /// nodes by processing the 'effects' of a block-level statement.
57   virtual void processCFGElement(const CFGElement E, StmtNodeBuilder& builder)=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(ExplodedNodeSet &dstNodes,
63                             GenericNodeBuilder<BlockEntrance> &nodeBuilder) = 0;
64
65   /// Called by CoreEngine.  Used to generate successor
66   ///  nodes by processing the 'effects' of a branch condition.
67   virtual void processBranch(const Stmt *Condition, const Stmt *Term,
68                              BranchNodeBuilder& builder) = 0;
69
70   /// Called by CoreEngine.  Used to generate successor
71   /// nodes by processing the 'effects' of a computed goto jump.
72   virtual void processIndirectGoto(IndirectGotoNodeBuilder& builder) = 0;
73
74   /// Called by CoreEngine.  Used to generate successor
75   /// nodes by processing the 'effects' of a switch statement.
76   virtual void processSwitch(SwitchNodeBuilder& builder) = 0;
77
78   /// Called by CoreEngine.  Used to generate end-of-path
79   /// nodes when the control reaches the end of a function.
80   virtual void processEndOfFunction(EndOfFunctionNodeBuilder& builder) = 0;
81
82   // Generate the entry node of the callee.
83   virtual void processCallEnter(CallEnterNodeBuilder &builder) = 0;
84
85   // Generate the first post callsite node.
86   virtual void processCallExit(CallExitNodeBuilder &builder) = 0;
87
88   /// Called by ConstraintManager. Used to call checker-specific
89   /// logic for handling assumptions on symbolic values.
90   virtual const ProgramState *processAssume(const ProgramState *state,
91                                        SVal cond, bool assumption) = 0;
92
93   /// wantsRegionChangeUpdate - Called by ProgramStateManager to determine if a
94   ///  region change should trigger a processRegionChanges update.
95   virtual bool wantsRegionChangeUpdate(const ProgramState *state) = 0;
96
97   /// processRegionChanges - Called by ProgramStateManager whenever a change is made
98   ///  to the store. Used to update checkers that track region values.
99   virtual const ProgramState *
100   processRegionChanges(const ProgramState *state,
101                        const StoreManager::InvalidatedSymbols *invalidated,
102                        ArrayRef<const MemRegion *> ExplicitRegions,
103                        ArrayRef<const MemRegion *> Regions) = 0;
104
105
106   inline const ProgramState *
107   processRegionChange(const ProgramState *state,
108                       const MemRegion* MR) {
109     return processRegionChanges(state, 0, MR, MR);
110   }
111
112   /// printState - Called by ProgramStateManager to print checker-specific data.
113   virtual void printState(raw_ostream &Out, const ProgramState *State,
114                           const char *NL, const char *Sep) = 0;
115
116   /// Called by CoreEngine when the analysis worklist is either empty or the
117   //  maximum number of analysis steps have been reached.
118   virtual void processEndWorklist(bool hasWorkRemaining) = 0;
119 };
120
121 } // end GR namespace
122
123 } // end clang namespace
124
125 #endif