Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 1 | //=== AnalysisContext.h - Analysis context for Path Sens analysis --*- 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 AnalysisContext, a class that manages the analysis context |
| 11 | // data for path sensitive analysis. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef LLVM_CLANG_ANALYSIS_ANALYSISCONTEXT_H |
| 16 | #define LLVM_CLANG_ANALYSIS_ANALYSISCONTEXT_H |
| 17 | |
| 18 | #include "clang/AST/Decl.h" |
Ted Kremenek | 892697d | 2010-12-16 07:46:53 +0000 | [diff] [blame] | 19 | #include "clang/AST/Expr.h" |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 20 | #include "llvm/ADT/OwningPtr.h" |
| 21 | #include "llvm/ADT/FoldingSet.h" |
| 22 | #include "llvm/ADT/PointerUnion.h" |
| 23 | #include "llvm/ADT/DenseMap.h" |
| 24 | #include "llvm/Support/Allocator.h" |
| 25 | |
| 26 | namespace clang { |
| 27 | |
| 28 | class Decl; |
| 29 | class Stmt; |
| 30 | class CFG; |
| 31 | class CFGBlock; |
Ted Kremenek | 42461ee | 2011-02-23 01:51:59 +0000 | [diff] [blame^] | 32 | class CFGReachabilityAnalysis; |
Ted Kremenek | 283a358 | 2011-02-23 01:51:53 +0000 | [diff] [blame] | 33 | class CFGStmtMap; |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 34 | class LiveVariables; |
| 35 | class ParentMap; |
Tom Care | db34ab7 | 2010-08-23 19:51:57 +0000 | [diff] [blame] | 36 | class PseudoConstantAnalysis; |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 37 | class ImplicitParamDecl; |
| 38 | class LocationContextManager; |
| 39 | class StackFrameContext; |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 40 | |
Zhongxing Xu | c6238d2 | 2010-07-19 01:31:21 +0000 | [diff] [blame] | 41 | namespace idx { class TranslationUnit; } |
| 42 | |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 43 | /// AnalysisContext contains the context data for the function or method under |
| 44 | /// analysis. |
| 45 | class AnalysisContext { |
| 46 | const Decl *D; |
| 47 | |
Zhongxing Xu | c6238d2 | 2010-07-19 01:31:21 +0000 | [diff] [blame] | 48 | // TranslationUnit is NULL if we don't have multiple translation units. |
Zhongxing Xu | 2ce43c8 | 2010-07-22 13:52:13 +0000 | [diff] [blame] | 49 | idx::TranslationUnit *TU; |
Zhongxing Xu | c6238d2 | 2010-07-19 01:31:21 +0000 | [diff] [blame] | 50 | |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 51 | // AnalysisContext owns the following data. |
Ted Kremenek | ad5a894 | 2010-08-02 23:46:59 +0000 | [diff] [blame] | 52 | CFG *cfg, *completeCFG; |
Ted Kremenek | 283a358 | 2011-02-23 01:51:53 +0000 | [diff] [blame] | 53 | CFGStmtMap *cfgStmtMap; |
Ted Kremenek | ad5a894 | 2010-08-02 23:46:59 +0000 | [diff] [blame] | 54 | bool builtCFG, builtCompleteCFG; |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 55 | LiveVariables *liveness; |
Tom Care | ec49bf4 | 2010-08-27 22:30:10 +0000 | [diff] [blame] | 56 | LiveVariables *relaxedLiveness; |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 57 | ParentMap *PM; |
Tom Care | db34ab7 | 2010-08-23 19:51:57 +0000 | [diff] [blame] | 58 | PseudoConstantAnalysis *PCA; |
Ted Kremenek | 42461ee | 2011-02-23 01:51:59 +0000 | [diff] [blame^] | 59 | CFGReachabilityAnalysis *CFA; |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 60 | llvm::DenseMap<const BlockDecl*,void*> *ReferencedBlockVars; |
| 61 | llvm::BumpPtrAllocator A; |
Ted Kremenek | 9b823e8 | 2010-08-03 00:09:51 +0000 | [diff] [blame] | 62 | bool UseUnoptimizedCFG; |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 63 | bool AddEHEdges; |
Marcin Swiderski | 9121ba2 | 2010-09-30 07:41:24 +0000 | [diff] [blame] | 64 | bool AddImplicitDtors; |
| 65 | bool AddInitializers; |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 66 | public: |
Zhongxing Xu | 2ce43c8 | 2010-07-22 13:52:13 +0000 | [diff] [blame] | 67 | AnalysisContext(const Decl *d, idx::TranslationUnit *tu, |
Ted Kremenek | 9b823e8 | 2010-08-03 00:09:51 +0000 | [diff] [blame] | 68 | bool useUnoptimizedCFG = false, |
Marcin Swiderski | 9121ba2 | 2010-09-30 07:41:24 +0000 | [diff] [blame] | 69 | bool addehedges = false, |
| 70 | bool addImplicitDtors = false, |
| 71 | bool addInitializers = false) |
Ted Kremenek | 283a358 | 2011-02-23 01:51:53 +0000 | [diff] [blame] | 72 | : D(d), TU(tu), cfg(0), completeCFG(0), cfgStmtMap(0), |
Ted Kremenek | ad5a894 | 2010-08-02 23:46:59 +0000 | [diff] [blame] | 73 | builtCFG(false), builtCompleteCFG(false), |
Ted Kremenek | 42461ee | 2011-02-23 01:51:59 +0000 | [diff] [blame^] | 74 | liveness(0), relaxedLiveness(0), PM(0), PCA(0), CFA(0), |
Ted Kremenek | 9b823e8 | 2010-08-03 00:09:51 +0000 | [diff] [blame] | 75 | ReferencedBlockVars(0), UseUnoptimizedCFG(useUnoptimizedCFG), |
Marcin Swiderski | 9121ba2 | 2010-09-30 07:41:24 +0000 | [diff] [blame] | 76 | AddEHEdges(addehedges), AddImplicitDtors(addImplicitDtors), |
| 77 | AddInitializers(addInitializers) {} |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 78 | |
| 79 | ~AnalysisContext(); |
| 80 | |
| 81 | ASTContext &getASTContext() { return D->getASTContext(); } |
Zhongxing Xu | c6238d2 | 2010-07-19 01:31:21 +0000 | [diff] [blame] | 82 | const Decl *getDecl() const { return D; } |
| 83 | |
Zhongxing Xu | 2ce43c8 | 2010-07-22 13:52:13 +0000 | [diff] [blame] | 84 | idx::TranslationUnit *getTranslationUnit() const { return TU; } |
Zhongxing Xu | c6238d2 | 2010-07-19 01:31:21 +0000 | [diff] [blame] | 85 | |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 86 | /// getAddEHEdges - Return true iff we are adding exceptional edges from |
| 87 | /// callExprs. If this is false, then try/catch statements and blocks |
| 88 | /// reachable from them can appear to be dead in the CFG, analysis passes must |
| 89 | /// cope with that. |
| 90 | bool getAddEHEdges() const { return AddEHEdges; } |
Ted Kremenek | 9b823e8 | 2010-08-03 00:09:51 +0000 | [diff] [blame] | 91 | |
| 92 | bool getUseUnoptimizedCFG() const { return UseUnoptimizedCFG; } |
Marcin Swiderski | 9121ba2 | 2010-09-30 07:41:24 +0000 | [diff] [blame] | 93 | bool getAddImplicitDtors() const { return AddImplicitDtors; } |
| 94 | bool getAddInitializers() const { return AddInitializers; } |
Ted Kremenek | 9b823e8 | 2010-08-03 00:09:51 +0000 | [diff] [blame] | 95 | |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 96 | Stmt *getBody(); |
| 97 | CFG *getCFG(); |
Ted Kremenek | 283a358 | 2011-02-23 01:51:53 +0000 | [diff] [blame] | 98 | |
| 99 | CFGStmtMap *getCFGStmtMap(); |
Anders Carlsson | 04eeba4 | 2011-01-16 22:05:23 +0000 | [diff] [blame] | 100 | |
Ted Kremenek | 42461ee | 2011-02-23 01:51:59 +0000 | [diff] [blame^] | 101 | CFGReachabilityAnalysis *getCFGReachablityAnalysis(); |
| 102 | |
Ted Kremenek | ad5a894 | 2010-08-02 23:46:59 +0000 | [diff] [blame] | 103 | /// Return a version of the CFG without any edges pruned. |
| 104 | CFG *getUnoptimizedCFG(); |
| 105 | |
Anders Carlsson | 04eeba4 | 2011-01-16 22:05:23 +0000 | [diff] [blame] | 106 | void dumpCFG(); |
| 107 | |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 108 | ParentMap &getParentMap(); |
Tom Care | db34ab7 | 2010-08-23 19:51:57 +0000 | [diff] [blame] | 109 | PseudoConstantAnalysis *getPseudoConstantAnalysis(); |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 110 | LiveVariables *getLiveVariables(); |
Tom Care | ec49bf4 | 2010-08-27 22:30:10 +0000 | [diff] [blame] | 111 | LiveVariables *getRelaxedLiveVariables(); |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 112 | |
| 113 | typedef const VarDecl * const * referenced_decls_iterator; |
| 114 | |
| 115 | std::pair<referenced_decls_iterator, referenced_decls_iterator> |
| 116 | getReferencedBlockVars(const BlockDecl *BD); |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 117 | |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 118 | /// Return the ImplicitParamDecl* associated with 'self' if this |
| 119 | /// AnalysisContext wraps an ObjCMethodDecl. Returns NULL otherwise. |
| 120 | const ImplicitParamDecl *getSelfDecl() const; |
| 121 | }; |
| 122 | |
| 123 | class AnalysisContextManager { |
| 124 | typedef llvm::DenseMap<const Decl*, AnalysisContext*> ContextMap; |
| 125 | ContextMap Contexts; |
Ted Kremenek | 9b823e8 | 2010-08-03 00:09:51 +0000 | [diff] [blame] | 126 | bool UseUnoptimizedCFG; |
Marcin Swiderski | 9121ba2 | 2010-09-30 07:41:24 +0000 | [diff] [blame] | 127 | bool AddImplicitDtors; |
| 128 | bool AddInitializers; |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 129 | public: |
Marcin Swiderski | 9121ba2 | 2010-09-30 07:41:24 +0000 | [diff] [blame] | 130 | AnalysisContextManager(bool useUnoptimizedCFG = false, |
| 131 | bool addImplicitDtors = false, bool addInitializers = false) |
| 132 | : UseUnoptimizedCFG(useUnoptimizedCFG), AddImplicitDtors(addImplicitDtors), |
| 133 | AddInitializers(addInitializers) {} |
Ted Kremenek | 9b823e8 | 2010-08-03 00:09:51 +0000 | [diff] [blame] | 134 | |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 135 | ~AnalysisContextManager(); |
| 136 | |
Zhongxing Xu | 2ce43c8 | 2010-07-22 13:52:13 +0000 | [diff] [blame] | 137 | AnalysisContext *getContext(const Decl *D, idx::TranslationUnit *TU = 0); |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 138 | |
Ted Kremenek | 9b823e8 | 2010-08-03 00:09:51 +0000 | [diff] [blame] | 139 | bool getUseUnoptimizedCFG() const { return UseUnoptimizedCFG; } |
Marcin Swiderski | 9121ba2 | 2010-09-30 07:41:24 +0000 | [diff] [blame] | 140 | bool getAddImplicitDtors() const { return AddImplicitDtors; } |
| 141 | bool getAddInitializers() const { return AddInitializers; } |
Ted Kremenek | 9b823e8 | 2010-08-03 00:09:51 +0000 | [diff] [blame] | 142 | |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 143 | // Discard all previously created AnalysisContexts. |
| 144 | void clear(); |
| 145 | }; |
| 146 | |
| 147 | class LocationContext : public llvm::FoldingSetNode { |
| 148 | public: |
| 149 | enum ContextKind { StackFrame, Scope, Block }; |
| 150 | |
| 151 | private: |
| 152 | ContextKind Kind; |
Zhongxing Xu | a02d893 | 2010-07-20 02:14:22 +0000 | [diff] [blame] | 153 | |
| 154 | // AnalysisContext can't be const since some methods may modify its member. |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 155 | AnalysisContext *Ctx; |
Zhongxing Xu | a02d893 | 2010-07-20 02:14:22 +0000 | [diff] [blame] | 156 | |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 157 | const LocationContext *Parent; |
| 158 | |
| 159 | protected: |
| 160 | LocationContext(ContextKind k, AnalysisContext *ctx, |
| 161 | const LocationContext *parent) |
| 162 | : Kind(k), Ctx(ctx), Parent(parent) {} |
| 163 | |
| 164 | public: |
| 165 | virtual ~LocationContext(); |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 166 | |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 167 | ContextKind getKind() const { return Kind; } |
| 168 | |
| 169 | AnalysisContext *getAnalysisContext() const { return Ctx; } |
| 170 | |
Zhongxing Xu | 2ce43c8 | 2010-07-22 13:52:13 +0000 | [diff] [blame] | 171 | idx::TranslationUnit *getTranslationUnit() const { |
Zhongxing Xu | c6238d2 | 2010-07-19 01:31:21 +0000 | [diff] [blame] | 172 | return Ctx->getTranslationUnit(); |
| 173 | } |
| 174 | |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 175 | const LocationContext *getParent() const { return Parent; } |
| 176 | |
Zhongxing Xu | 8ddf7ce | 2010-02-17 08:45:06 +0000 | [diff] [blame] | 177 | bool isParentOf(const LocationContext *LC) const; |
| 178 | |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 179 | const Decl *getDecl() const { return getAnalysisContext()->getDecl(); } |
| 180 | |
| 181 | CFG *getCFG() const { return getAnalysisContext()->getCFG(); } |
| 182 | |
| 183 | LiveVariables *getLiveVariables() const { |
| 184 | return getAnalysisContext()->getLiveVariables(); |
| 185 | } |
| 186 | |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 187 | ParentMap &getParentMap() const { |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 188 | return getAnalysisContext()->getParentMap(); |
| 189 | } |
| 190 | |
| 191 | const ImplicitParamDecl *getSelfDecl() const { |
| 192 | return Ctx->getSelfDecl(); |
| 193 | } |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 194 | |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 195 | const StackFrameContext *getCurrentStackFrame() const; |
| 196 | const StackFrameContext * |
| 197 | getStackFrameForDeclContext(const DeclContext *DC) const; |
| 198 | |
| 199 | virtual void Profile(llvm::FoldingSetNodeID &ID) = 0; |
| 200 | |
| 201 | static bool classof(const LocationContext*) { return true; } |
| 202 | |
| 203 | public: |
| 204 | static void ProfileCommon(llvm::FoldingSetNodeID &ID, |
| 205 | ContextKind ck, |
| 206 | AnalysisContext *ctx, |
| 207 | const LocationContext *parent, |
| 208 | const void* data); |
| 209 | }; |
| 210 | |
| 211 | class StackFrameContext : public LocationContext { |
Zhongxing Xu | 26c9cb5 | 2011-01-10 11:28:29 +0000 | [diff] [blame] | 212 | // The callsite where this stack frame is established. |
Ted Kremenek | 892697d | 2010-12-16 07:46:53 +0000 | [diff] [blame] | 213 | const Stmt *CallSite; |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 214 | |
| 215 | // The parent block of the callsite. |
| 216 | const CFGBlock *Block; |
| 217 | |
| 218 | // The index of the callsite in the CFGBlock. |
| 219 | unsigned Index; |
| 220 | |
| 221 | friend class LocationContextManager; |
| 222 | StackFrameContext(AnalysisContext *ctx, const LocationContext *parent, |
Ted Kremenek | 892697d | 2010-12-16 07:46:53 +0000 | [diff] [blame] | 223 | const Stmt *s, const CFGBlock *blk, |
Zhongxing Xu | d706434 | 2010-11-24 13:08:51 +0000 | [diff] [blame] | 224 | unsigned idx) |
Ted Kremenek | 892697d | 2010-12-16 07:46:53 +0000 | [diff] [blame] | 225 | : LocationContext(StackFrame, ctx, parent), CallSite(s), |
Zhongxing Xu | d706434 | 2010-11-24 13:08:51 +0000 | [diff] [blame] | 226 | Block(blk), Index(idx) {} |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 227 | |
| 228 | public: |
| 229 | ~StackFrameContext() {} |
| 230 | |
Ted Kremenek | 892697d | 2010-12-16 07:46:53 +0000 | [diff] [blame] | 231 | const Stmt *getCallSite() const { return CallSite; } |
Zhongxing Xu | d706434 | 2010-11-24 13:08:51 +0000 | [diff] [blame] | 232 | |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 233 | const CFGBlock *getCallSiteBlock() const { return Block; } |
| 234 | |
| 235 | unsigned getIndex() const { return Index; } |
| 236 | |
| 237 | void Profile(llvm::FoldingSetNodeID &ID); |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 238 | |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 239 | static void Profile(llvm::FoldingSetNodeID &ID, AnalysisContext *ctx, |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 240 | const LocationContext *parent, const Stmt *s, |
Ted Kremenek | 892697d | 2010-12-16 07:46:53 +0000 | [diff] [blame] | 241 | const CFGBlock *blk, unsigned idx) { |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 242 | ProfileCommon(ID, StackFrame, ctx, parent, s); |
| 243 | ID.AddPointer(blk); |
| 244 | ID.AddInteger(idx); |
| 245 | } |
| 246 | |
| 247 | static bool classof(const LocationContext* Ctx) { |
| 248 | return Ctx->getKind() == StackFrame; |
| 249 | } |
| 250 | }; |
| 251 | |
| 252 | class ScopeContext : public LocationContext { |
| 253 | const Stmt *Enter; |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 254 | |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 255 | friend class LocationContextManager; |
| 256 | ScopeContext(AnalysisContext *ctx, const LocationContext *parent, |
| 257 | const Stmt *s) |
| 258 | : LocationContext(Scope, ctx, parent), Enter(s) {} |
| 259 | |
| 260 | public: |
| 261 | ~ScopeContext() {} |
| 262 | |
| 263 | void Profile(llvm::FoldingSetNodeID &ID); |
| 264 | |
| 265 | static void Profile(llvm::FoldingSetNodeID &ID, AnalysisContext *ctx, |
| 266 | const LocationContext *parent, const Stmt *s) { |
| 267 | ProfileCommon(ID, Scope, ctx, parent, s); |
| 268 | } |
| 269 | |
| 270 | static bool classof(const LocationContext* Ctx) { |
| 271 | return Ctx->getKind() == Scope; |
| 272 | } |
| 273 | }; |
| 274 | |
| 275 | class BlockInvocationContext : public LocationContext { |
| 276 | // FIXME: Add back context-sensivity (we don't want libAnalysis to know |
| 277 | // about MemRegion). |
| 278 | const BlockDecl *BD; |
| 279 | |
| 280 | friend class LocationContextManager; |
| 281 | |
| 282 | BlockInvocationContext(AnalysisContext *ctx, const LocationContext *parent, |
| 283 | const BlockDecl *bd) |
| 284 | : LocationContext(Block, ctx, parent), BD(bd) {} |
| 285 | |
| 286 | public: |
| 287 | ~BlockInvocationContext() {} |
| 288 | |
| 289 | const BlockDecl *getBlockDecl() const { return BD; } |
| 290 | |
| 291 | void Profile(llvm::FoldingSetNodeID &ID); |
| 292 | |
| 293 | static void Profile(llvm::FoldingSetNodeID &ID, AnalysisContext *ctx, |
| 294 | const LocationContext *parent, const BlockDecl *bd) { |
| 295 | ProfileCommon(ID, Block, ctx, parent, bd); |
| 296 | } |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 297 | |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 298 | static bool classof(const LocationContext* Ctx) { |
| 299 | return Ctx->getKind() == Block; |
| 300 | } |
| 301 | }; |
| 302 | |
| 303 | class LocationContextManager { |
| 304 | llvm::FoldingSet<LocationContext> Contexts; |
| 305 | public: |
| 306 | ~LocationContextManager(); |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 307 | |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 308 | const StackFrameContext *getStackFrame(AnalysisContext *ctx, |
| 309 | const LocationContext *parent, |
Ted Kremenek | 892697d | 2010-12-16 07:46:53 +0000 | [diff] [blame] | 310 | const Stmt *s, |
Zhongxing Xu | d706434 | 2010-11-24 13:08:51 +0000 | [diff] [blame] | 311 | const CFGBlock *blk, unsigned idx); |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 312 | |
| 313 | const ScopeContext *getScope(AnalysisContext *ctx, |
| 314 | const LocationContext *parent, |
| 315 | const Stmt *s); |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 316 | |
Ted Kremenek | 326be56 | 2010-01-25 05:19:37 +0000 | [diff] [blame] | 317 | /// Discard all previously created LocationContext objects. |
| 318 | void clear(); |
| 319 | private: |
| 320 | template <typename LOC, typename DATA> |
| 321 | const LOC *getLocationContext(AnalysisContext *ctx, |
| 322 | const LocationContext *parent, |
| 323 | const DATA *d); |
| 324 | }; |
| 325 | |
| 326 | } // end clang namespace |
| 327 | #endif |