Zhongxing Xu | 97ab394 | 2009-07-30 01:17:21 +0000 | [diff] [blame] | 1 | //== AnalysisContext.cpp - 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 | |
Zhongxing Xu | 97ab394 | 2009-07-30 01:17:21 +0000 | [diff] [blame] | 15 | #include "clang/AST/Decl.h" |
| 16 | #include "clang/AST/DeclObjC.h" |
Mike Stump | fa6ef18 | 2010-01-13 02:59:54 +0000 | [diff] [blame] | 17 | #include "clang/AST/DeclTemplate.h" |
Zhongxing Xu | 97ab394 | 2009-07-30 01:17:21 +0000 | [diff] [blame] | 18 | #include "clang/AST/ParentMap.h" |
Ted Kremenek | b1a7b65 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 19 | #include "clang/AST/StmtVisitor.h" |
Ted Kremenek | 2cfe28b | 2010-03-10 00:18:11 +0000 | [diff] [blame] | 20 | #include "clang/Analysis/Analyses/LiveVariables.h" |
| 21 | #include "clang/Analysis/AnalysisContext.h" |
| 22 | #include "clang/Analysis/CFG.h" |
Ted Kremenek | b1a7b65 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 23 | #include "clang/Analysis/Support/BumpVector.h" |
Ted Kremenek | 2cfe28b | 2010-03-10 00:18:11 +0000 | [diff] [blame] | 24 | #include "llvm/ADT/SmallSet.h" |
Mike Stump | 87a05f1 | 2009-07-31 01:10:29 +0000 | [diff] [blame] | 25 | #include "llvm/Support/ErrorHandling.h" |
Zhongxing Xu | 97ab394 | 2009-07-30 01:17:21 +0000 | [diff] [blame] | 26 | |
| 27 | using namespace clang; |
| 28 | |
Ted Kremenek | 58f5ec7 | 2009-10-20 21:39:41 +0000 | [diff] [blame] | 29 | void AnalysisContextManager::clear() { |
| 30 | for (ContextMap::iterator I = Contexts.begin(), E = Contexts.end(); I!=E; ++I) |
| 31 | delete I->second; |
| 32 | Contexts.clear(); |
| 33 | } |
| 34 | |
Zhongxing Xu | 97ab394 | 2009-07-30 01:17:21 +0000 | [diff] [blame] | 35 | Stmt *AnalysisContext::getBody() { |
Ted Kremenek | 2376002 | 2009-08-21 23:58:43 +0000 | [diff] [blame] | 36 | if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) |
Zhongxing Xu | 97ab394 | 2009-07-30 01:17:21 +0000 | [diff] [blame] | 37 | return FD->getBody(); |
Ted Kremenek | 2376002 | 2009-08-21 23:58:43 +0000 | [diff] [blame] | 38 | else if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) |
Zhongxing Xu | 97ab394 | 2009-07-30 01:17:21 +0000 | [diff] [blame] | 39 | return MD->getBody(); |
Ted Kremenek | 30a4534 | 2009-12-04 20:34:55 +0000 | [diff] [blame] | 40 | else if (const BlockDecl *BD = dyn_cast<BlockDecl>(D)) |
| 41 | return BD->getBody(); |
Mike Stump | fa6ef18 | 2010-01-13 02:59:54 +0000 | [diff] [blame] | 42 | else if (const FunctionTemplateDecl *FunTmpl |
| 43 | = dyn_cast_or_null<FunctionTemplateDecl>(D)) |
| 44 | return FunTmpl->getTemplatedDecl()->getBody(); |
Zhongxing Xu | 97ab394 | 2009-07-30 01:17:21 +0000 | [diff] [blame] | 45 | |
Jeffrey Yasskin | 9f61aa9 | 2009-12-12 05:05:38 +0000 | [diff] [blame] | 46 | llvm_unreachable("unknown code decl"); |
Zhongxing Xu | 97ab394 | 2009-07-30 01:17:21 +0000 | [diff] [blame] | 47 | } |
| 48 | |
Ted Kremenek | 82cd37c | 2009-08-21 23:25:54 +0000 | [diff] [blame] | 49 | const ImplicitParamDecl *AnalysisContext::getSelfDecl() const { |
| 50 | if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) |
| 51 | return MD->getSelfDecl(); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 52 | |
Ted Kremenek | 82cd37c | 2009-08-21 23:25:54 +0000 | [diff] [blame] | 53 | return NULL; |
| 54 | } |
| 55 | |
Zhongxing Xu | 97ab394 | 2009-07-30 01:17:21 +0000 | [diff] [blame] | 56 | CFG *AnalysisContext::getCFG() { |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 57 | if (!builtCFG) { |
Mike Stump | 4c45aa1 | 2010-01-21 15:20:48 +0000 | [diff] [blame] | 58 | cfg = CFG::buildCFG(D, getBody(), &D->getASTContext(), AddEHEdges); |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 59 | // Even when the cfg is not successfully built, we don't |
| 60 | // want to try building it again. |
| 61 | builtCFG = true; |
| 62 | } |
Zhongxing Xu | 97ab394 | 2009-07-30 01:17:21 +0000 | [diff] [blame] | 63 | return cfg; |
| 64 | } |
| 65 | |
| 66 | ParentMap &AnalysisContext::getParentMap() { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 67 | if (!PM) |
Zhongxing Xu | 97ab394 | 2009-07-30 01:17:21 +0000 | [diff] [blame] | 68 | PM = new ParentMap(getBody()); |
| 69 | return *PM; |
| 70 | } |
| 71 | |
| 72 | LiveVariables *AnalysisContext::getLiveVariables() { |
| 73 | if (!liveness) { |
| 74 | CFG *c = getCFG(); |
| 75 | if (!c) |
| 76 | return 0; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 77 | |
Ted Kremenek | b1a7b65 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 78 | liveness = new LiveVariables(*this); |
Zhongxing Xu | 97ab394 | 2009-07-30 01:17:21 +0000 | [diff] [blame] | 79 | liveness->runOnCFG(*c); |
| 80 | liveness->runOnAllBlocks(*c, 0, true); |
| 81 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 82 | |
Zhongxing Xu | 97ab394 | 2009-07-30 01:17:21 +0000 | [diff] [blame] | 83 | return liveness; |
| 84 | } |
| 85 | |
Ted Kremenek | 2376002 | 2009-08-21 23:58:43 +0000 | [diff] [blame] | 86 | AnalysisContext *AnalysisContextManager::getContext(const Decl *D) { |
| 87 | AnalysisContext *&AC = Contexts[D]; |
| 88 | if (!AC) |
| 89 | AC = new AnalysisContext(D); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 90 | |
Ted Kremenek | 2376002 | 2009-08-21 23:58:43 +0000 | [diff] [blame] | 91 | return AC; |
Zhongxing Xu | 97ab394 | 2009-07-30 01:17:21 +0000 | [diff] [blame] | 92 | } |
Zhongxing Xu | 18c7c06 | 2009-08-03 07:23:22 +0000 | [diff] [blame] | 93 | |
Ted Kremenek | dc0d909 | 2009-12-04 00:50:10 +0000 | [diff] [blame] | 94 | //===----------------------------------------------------------------------===// |
| 95 | // FoldingSet profiling. |
| 96 | //===----------------------------------------------------------------------===// |
| 97 | |
Ted Kremenek | dc0d909 | 2009-12-04 00:50:10 +0000 | [diff] [blame] | 98 | void LocationContext::ProfileCommon(llvm::FoldingSetNodeID &ID, |
| 99 | ContextKind ck, |
| 100 | AnalysisContext *ctx, |
| 101 | const LocationContext *parent, |
| 102 | const void* data) { |
Ted Kremenek | 0ee4124 | 2009-12-04 01:28:56 +0000 | [diff] [blame] | 103 | ID.AddInteger(ck); |
| 104 | ID.AddPointer(ctx); |
| 105 | ID.AddPointer(parent); |
Ted Kremenek | dc0d909 | 2009-12-04 00:50:10 +0000 | [diff] [blame] | 106 | ID.AddPointer(data); |
Zhongxing Xu | 18c7c06 | 2009-08-03 07:23:22 +0000 | [diff] [blame] | 107 | } |
| 108 | |
Ted Kremenek | dc0d909 | 2009-12-04 00:50:10 +0000 | [diff] [blame] | 109 | void StackFrameContext::Profile(llvm::FoldingSetNodeID &ID) { |
Zhongxing Xu | 62d399e | 2009-12-24 03:34:38 +0000 | [diff] [blame] | 110 | Profile(ID, getAnalysisContext(), getParent(), CallSite, Block, Index); |
Zhongxing Xu | 18c7c06 | 2009-08-03 07:23:22 +0000 | [diff] [blame] | 111 | } |
| 112 | |
Ted Kremenek | dc0d909 | 2009-12-04 00:50:10 +0000 | [diff] [blame] | 113 | void ScopeContext::Profile(llvm::FoldingSetNodeID &ID) { |
| 114 | Profile(ID, getAnalysisContext(), getParent(), Enter); |
| 115 | } |
| 116 | |
| 117 | void BlockInvocationContext::Profile(llvm::FoldingSetNodeID &ID) { |
Ted Kremenek | 1309f9a | 2010-01-25 04:41:41 +0000 | [diff] [blame] | 118 | Profile(ID, getAnalysisContext(), getParent(), BD); |
Ted Kremenek | dc0d909 | 2009-12-04 00:50:10 +0000 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | //===----------------------------------------------------------------------===// |
Ted Kremenek | 0ee4124 | 2009-12-04 01:28:56 +0000 | [diff] [blame] | 122 | // LocationContext creation. |
Ted Kremenek | dc0d909 | 2009-12-04 00:50:10 +0000 | [diff] [blame] | 123 | //===----------------------------------------------------------------------===// |
| 124 | |
Ted Kremenek | 0ee4124 | 2009-12-04 01:28:56 +0000 | [diff] [blame] | 125 | template <typename LOC, typename DATA> |
| 126 | const LOC* |
| 127 | LocationContextManager::getLocationContext(AnalysisContext *ctx, |
| 128 | const LocationContext *parent, |
| 129 | const DATA *d) { |
| 130 | llvm::FoldingSetNodeID ID; |
| 131 | LOC::Profile(ID, ctx, parent, d); |
| 132 | void *InsertPos; |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 133 | |
Ted Kremenek | 0ee4124 | 2009-12-04 01:28:56 +0000 | [diff] [blame] | 134 | LOC *L = cast_or_null<LOC>(Contexts.FindNodeOrInsertPos(ID, InsertPos)); |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 135 | |
Ted Kremenek | 0ee4124 | 2009-12-04 01:28:56 +0000 | [diff] [blame] | 136 | if (!L) { |
| 137 | L = new LOC(ctx, parent, d); |
| 138 | Contexts.InsertNode(L, InsertPos); |
| 139 | } |
| 140 | return L; |
Ted Kremenek | 58f5ec7 | 2009-10-20 21:39:41 +0000 | [diff] [blame] | 141 | } |
| 142 | |
Ted Kremenek | 0ee4124 | 2009-12-04 01:28:56 +0000 | [diff] [blame] | 143 | const StackFrameContext* |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 144 | LocationContextManager::getStackFrame(AnalysisContext *ctx, |
Ted Kremenek | 54c809b | 2009-08-21 23:39:58 +0000 | [diff] [blame] | 145 | const LocationContext *parent, |
Zhongxing Xu | 62d399e | 2009-12-24 03:34:38 +0000 | [diff] [blame] | 146 | const Stmt *s, const CFGBlock *blk, |
| 147 | unsigned idx) { |
| 148 | llvm::FoldingSetNodeID ID; |
| 149 | StackFrameContext::Profile(ID, ctx, parent, s, blk, idx); |
| 150 | void *InsertPos; |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 151 | StackFrameContext *L = |
Zhongxing Xu | 62d399e | 2009-12-24 03:34:38 +0000 | [diff] [blame] | 152 | cast_or_null<StackFrameContext>(Contexts.FindNodeOrInsertPos(ID, InsertPos)); |
| 153 | if (!L) { |
| 154 | L = new StackFrameContext(ctx, parent, s, blk, idx); |
| 155 | Contexts.InsertNode(L, InsertPos); |
| 156 | } |
| 157 | return L; |
Zhongxing Xu | 18c7c06 | 2009-08-03 07:23:22 +0000 | [diff] [blame] | 158 | } |
| 159 | |
Ted Kremenek | 0ee4124 | 2009-12-04 01:28:56 +0000 | [diff] [blame] | 160 | const ScopeContext * |
| 161 | LocationContextManager::getScope(AnalysisContext *ctx, |
| 162 | const LocationContext *parent, |
| 163 | const Stmt *s) { |
| 164 | return getLocationContext<ScopeContext, Stmt>(ctx, parent, s); |
| 165 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 166 | |
Ted Kremenek | b1a7b65 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 167 | //===----------------------------------------------------------------------===// |
Ted Kremenek | 67d1287 | 2009-12-07 22:05:27 +0000 | [diff] [blame] | 168 | // LocationContext methods. |
| 169 | //===----------------------------------------------------------------------===// |
| 170 | |
| 171 | const StackFrameContext *LocationContext::getCurrentStackFrame() const { |
| 172 | const LocationContext *LC = this; |
| 173 | while (LC) { |
| 174 | if (const StackFrameContext *SFC = dyn_cast<StackFrameContext>(LC)) |
| 175 | return SFC; |
| 176 | LC = LC->getParent(); |
| 177 | } |
| 178 | return NULL; |
| 179 | } |
| 180 | |
Ted Kremenek | 2b87ae4 | 2009-12-11 06:43:27 +0000 | [diff] [blame] | 181 | const StackFrameContext * |
| 182 | LocationContext::getStackFrameForDeclContext(const DeclContext *DC) const { |
| 183 | const LocationContext *LC = this; |
| 184 | while (LC) { |
| 185 | if (const StackFrameContext *SFC = dyn_cast<StackFrameContext>(LC)) { |
| 186 | if (cast<DeclContext>(SFC->getDecl()) == DC) |
| 187 | return SFC; |
| 188 | } |
| 189 | LC = LC->getParent(); |
| 190 | } |
| 191 | return NULL; |
| 192 | } |
| 193 | |
Zhongxing Xu | 8ddf7ce | 2010-02-17 08:45:06 +0000 | [diff] [blame] | 194 | bool LocationContext::isParentOf(const LocationContext *LC) const { |
| 195 | do { |
| 196 | const LocationContext *Parent = LC->getParent(); |
| 197 | if (Parent == this) |
| 198 | return true; |
| 199 | else |
| 200 | LC = Parent; |
| 201 | } while (LC); |
| 202 | |
| 203 | return false; |
| 204 | } |
| 205 | |
Ted Kremenek | 67d1287 | 2009-12-07 22:05:27 +0000 | [diff] [blame] | 206 | //===----------------------------------------------------------------------===// |
Ted Kremenek | b1a7b65 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 207 | // Lazily generated map to query the external variables referenced by a Block. |
| 208 | //===----------------------------------------------------------------------===// |
| 209 | |
| 210 | namespace { |
| 211 | class FindBlockDeclRefExprsVals : public StmtVisitor<FindBlockDeclRefExprsVals>{ |
| 212 | BumpVector<const VarDecl*> &BEVals; |
| 213 | BumpVectorContext &BC; |
Ted Kremenek | 8524873 | 2010-02-06 00:30:00 +0000 | [diff] [blame] | 214 | llvm::DenseMap<const VarDecl*, unsigned> Visited; |
Ted Kremenek | 2cfe28b | 2010-03-10 00:18:11 +0000 | [diff] [blame] | 215 | llvm::SmallSet<const DeclContext*, 4> IgnoredContexts; |
Ted Kremenek | b1a7b65 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 216 | public: |
| 217 | FindBlockDeclRefExprsVals(BumpVector<const VarDecl*> &bevals, |
| 218 | BumpVectorContext &bc) |
| 219 | : BEVals(bevals), BC(bc) {} |
Ted Kremenek | 2cfe28b | 2010-03-10 00:18:11 +0000 | [diff] [blame] | 220 | |
| 221 | bool IsTrackedDecl(const VarDecl *VD) { |
| 222 | const DeclContext *DC = VD->getDeclContext(); |
| 223 | return IgnoredContexts.count(DC) == 0; |
| 224 | } |
| 225 | |
Ted Kremenek | b1a7b65 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 226 | void VisitStmt(Stmt *S) { |
| 227 | for (Stmt::child_iterator I = S->child_begin(), E = S->child_end();I!=E;++I) |
| 228 | if (Stmt *child = *I) |
| 229 | Visit(child); |
| 230 | } |
Ted Kremenek | 8524873 | 2010-02-06 00:30:00 +0000 | [diff] [blame] | 231 | |
| 232 | void VisitDeclRefExpr(const DeclRefExpr *DR) { |
| 233 | // Non-local variables are also directly modified. |
| 234 | if (const VarDecl *VD = dyn_cast<VarDecl>(DR->getDecl())) |
| 235 | if (!VD->hasLocalStorage()) { |
| 236 | unsigned &flag = Visited[VD]; |
| 237 | if (!flag) { |
| 238 | flag = 1; |
| 239 | BEVals.push_back(VD, BC); |
| 240 | } |
| 241 | } |
| 242 | } |
Ted Kremenek | 2cfe28b | 2010-03-10 00:18:11 +0000 | [diff] [blame] | 243 | |
Ted Kremenek | b1a7b65 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 244 | void VisitBlockDeclRefExpr(BlockDeclRefExpr *DR) { |
Ted Kremenek | 8524873 | 2010-02-06 00:30:00 +0000 | [diff] [blame] | 245 | if (const VarDecl *VD = dyn_cast<VarDecl>(DR->getDecl())) { |
| 246 | unsigned &flag = Visited[VD]; |
| 247 | if (!flag) { |
| 248 | flag = 1; |
Ted Kremenek | 2cfe28b | 2010-03-10 00:18:11 +0000 | [diff] [blame] | 249 | if (IsTrackedDecl(VD)) |
| 250 | BEVals.push_back(VD, BC); |
Ted Kremenek | 8524873 | 2010-02-06 00:30:00 +0000 | [diff] [blame] | 251 | } |
| 252 | } |
Ted Kremenek | b1a7b65 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 253 | } |
Ted Kremenek | 2cfe28b | 2010-03-10 00:18:11 +0000 | [diff] [blame] | 254 | |
| 255 | void VisitBlockExpr(BlockExpr *BR) { |
| 256 | // Blocks containing blocks can transitively capture more variables. |
| 257 | IgnoredContexts.insert(BR->getBlockDecl()); |
| 258 | Visit(BR->getBlockDecl()->getBody()); |
| 259 | } |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 260 | }; |
Ted Kremenek | b1a7b65 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 261 | } // end anonymous namespace |
| 262 | |
| 263 | typedef BumpVector<const VarDecl*> DeclVec; |
| 264 | |
| 265 | static DeclVec* LazyInitializeReferencedDecls(const BlockDecl *BD, |
| 266 | void *&Vec, |
| 267 | llvm::BumpPtrAllocator &A) { |
| 268 | if (Vec) |
| 269 | return (DeclVec*) Vec; |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 270 | |
Ted Kremenek | b1a7b65 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 271 | BumpVectorContext BC(A); |
| 272 | DeclVec *BV = (DeclVec*) A.Allocate<DeclVec>(); |
| 273 | new (BV) DeclVec(BC, 10); |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 274 | |
Ted Kremenek | b1a7b65 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 275 | // Find the referenced variables. |
| 276 | FindBlockDeclRefExprsVals F(*BV, BC); |
| 277 | F.Visit(BD->getBody()); |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 278 | |
| 279 | Vec = BV; |
Ted Kremenek | b1a7b65 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 280 | return BV; |
| 281 | } |
| 282 | |
| 283 | std::pair<AnalysisContext::referenced_decls_iterator, |
| 284 | AnalysisContext::referenced_decls_iterator> |
| 285 | AnalysisContext::getReferencedBlockVars(const BlockDecl *BD) { |
| 286 | if (!ReferencedBlockVars) |
| 287 | ReferencedBlockVars = new llvm::DenseMap<const BlockDecl*,void*>(); |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 288 | |
Ted Kremenek | b1a7b65 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 289 | DeclVec *V = LazyInitializeReferencedDecls(BD, (*ReferencedBlockVars)[BD], A); |
| 290 | return std::make_pair(V->begin(), V->end()); |
| 291 | } |
| 292 | |
| 293 | //===----------------------------------------------------------------------===// |
| 294 | // Cleanup. |
| 295 | //===----------------------------------------------------------------------===// |
| 296 | |
| 297 | AnalysisContext::~AnalysisContext() { |
| 298 | delete cfg; |
| 299 | delete liveness; |
| 300 | delete PM; |
| 301 | delete ReferencedBlockVars; |
| 302 | } |
| 303 | |
| 304 | AnalysisContextManager::~AnalysisContextManager() { |
| 305 | for (ContextMap::iterator I = Contexts.begin(), E = Contexts.end(); I!=E; ++I) |
| 306 | delete I->second; |
| 307 | } |
Ted Kremenek | 0ee4124 | 2009-12-04 01:28:56 +0000 | [diff] [blame] | 308 | |
| 309 | LocationContext::~LocationContext() {} |
| 310 | |
| 311 | LocationContextManager::~LocationContextManager() { |
| 312 | clear(); |
| 313 | } |
| 314 | |
| 315 | void LocationContextManager::clear() { |
| 316 | for (llvm::FoldingSet<LocationContext>::iterator I = Contexts.begin(), |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 317 | E = Contexts.end(); I != E; ) { |
Ted Kremenek | 0ee4124 | 2009-12-04 01:28:56 +0000 | [diff] [blame] | 318 | LocationContext *LC = &*I; |
| 319 | ++I; |
| 320 | delete LC; |
| 321 | } |
Ted Kremenek | d064fdc | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 322 | |
Ted Kremenek | 0ee4124 | 2009-12-04 01:28:56 +0000 | [diff] [blame] | 323 | Contexts.clear(); |
| 324 | } |
| 325 | |