Ted Kremenek | 81ce1c8 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 1 | //== AnalysisDeclContext.cpp - Analysis context for Path Sens analysis -*- C++ -*-// |
Zhongxing Xu | 14407bf | 2009-07-30 01:17:21 +0000 | [diff] [blame] | 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 | // |
Ted Kremenek | 81ce1c8 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 10 | // This file defines AnalysisDeclContext, a class that manages the analysis context |
Zhongxing Xu | 14407bf | 2009-07-30 01:17:21 +0000 | [diff] [blame] | 11 | // data for path sensitive analysis. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Chandler Carruth | 3a02247 | 2012-12-04 09:13:33 +0000 | [diff] [blame] | 15 | #include "clang/Analysis/AnalysisContext.h" |
| 16 | #include "BodyFarm.h" |
Benjamin Kramer | 4ab984e | 2012-07-04 20:19:54 +0000 | [diff] [blame] | 17 | #include "clang/AST/ASTContext.h" |
Zhongxing Xu | 14407bf | 2009-07-30 01:17:21 +0000 | [diff] [blame] | 18 | #include "clang/AST/Decl.h" |
| 19 | #include "clang/AST/DeclObjC.h" |
Mike Stump | 1bacb81 | 2010-01-13 02:59:54 +0000 | [diff] [blame] | 20 | #include "clang/AST/DeclTemplate.h" |
Zhongxing Xu | 14407bf | 2009-07-30 01:17:21 +0000 | [diff] [blame] | 21 | #include "clang/AST/ParentMap.h" |
Ted Kremenek | 0f5e6f88 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 22 | #include "clang/AST/StmtVisitor.h" |
Chandler Carruth | 3a02247 | 2012-12-04 09:13:33 +0000 | [diff] [blame] | 23 | #include "clang/Analysis/Analyses/CFGReachabilityAnalysis.h" |
Ted Kremenek | 575398e | 2010-03-10 00:18:11 +0000 | [diff] [blame] | 24 | #include "clang/Analysis/Analyses/LiveVariables.h" |
Tom Care | e332c3b | 2010-08-23 19:51:57 +0000 | [diff] [blame] | 25 | #include "clang/Analysis/Analyses/PseudoConstantAnalysis.h" |
Ted Kremenek | 575398e | 2010-03-10 00:18:11 +0000 | [diff] [blame] | 26 | #include "clang/Analysis/CFG.h" |
Ted Kremenek | cc7f1f8 | 2011-02-23 01:51:53 +0000 | [diff] [blame] | 27 | #include "clang/Analysis/CFGStmtMap.h" |
Ted Kremenek | 0f5e6f88 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 28 | #include "clang/Analysis/Support/BumpVector.h" |
Benjamin Kramer | 616f802 | 2012-03-10 15:08:09 +0000 | [diff] [blame] | 29 | #include "llvm/ADT/SmallPtrSet.h" |
Mike Stump | 5b78af9 | 2009-07-31 01:10:29 +0000 | [diff] [blame] | 30 | #include "llvm/Support/ErrorHandling.h" |
Chandler Carruth | 3a02247 | 2012-12-04 09:13:33 +0000 | [diff] [blame] | 31 | #include "llvm/Support/SaveAndRestore.h" |
Ted Kremenek | 14f779c | 2012-09-21 00:09:11 +0000 | [diff] [blame] | 32 | |
Zhongxing Xu | 14407bf | 2009-07-30 01:17:21 +0000 | [diff] [blame] | 33 | using namespace clang; |
| 34 | |
Ted Kremenek | dccc2b2 | 2011-10-07 22:21:02 +0000 | [diff] [blame] | 35 | typedef llvm::DenseMap<const void *, ManagedAnalysis *> ManagedAnalysisMap; |
| 36 | |
Ted Kremenek | 81ce1c8 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 37 | AnalysisDeclContext::AnalysisDeclContext(AnalysisDeclContextManager *Mgr, |
Ted Kremenek | 14f779c | 2012-09-21 00:09:11 +0000 | [diff] [blame] | 38 | const Decl *d, |
| 39 | const CFG::BuildOptions &buildOptions) |
Ted Kremenek | 142adc4 | 2011-10-23 02:31:52 +0000 | [diff] [blame] | 40 | : Manager(Mgr), |
| 41 | D(d), |
Ted Kremenek | 189ecec | 2011-07-21 05:22:47 +0000 | [diff] [blame] | 42 | cfgBuildOptions(buildOptions), |
Ted Kremenek | f9d8290 | 2011-03-10 01:14:05 +0000 | [diff] [blame] | 43 | forcedBlkExprs(0), |
Ted Kremenek | 189ecec | 2011-07-21 05:22:47 +0000 | [diff] [blame] | 44 | builtCFG(false), |
| 45 | builtCompleteCFG(false), |
Ted Kremenek | dccc2b2 | 2011-10-07 22:21:02 +0000 | [diff] [blame] | 46 | ReferencedBlockVars(0), |
| 47 | ManagedAnalyses(0) |
Ted Kremenek | 189ecec | 2011-07-21 05:22:47 +0000 | [diff] [blame] | 48 | { |
Ted Kremenek | f9d8290 | 2011-03-10 01:14:05 +0000 | [diff] [blame] | 49 | cfgBuildOptions.forcedBlkExprs = &forcedBlkExprs; |
Ted Kremenek | 189ecec | 2011-07-21 05:22:47 +0000 | [diff] [blame] | 50 | } |
| 51 | |
Ted Kremenek | 81ce1c8 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 52 | AnalysisDeclContext::AnalysisDeclContext(AnalysisDeclContextManager *Mgr, |
Ted Kremenek | 14f779c | 2012-09-21 00:09:11 +0000 | [diff] [blame] | 53 | const Decl *d) |
Ted Kremenek | 142adc4 | 2011-10-23 02:31:52 +0000 | [diff] [blame] | 54 | : Manager(Mgr), |
| 55 | D(d), |
Ted Kremenek | 189ecec | 2011-07-21 05:22:47 +0000 | [diff] [blame] | 56 | forcedBlkExprs(0), |
| 57 | builtCFG(false), |
| 58 | builtCompleteCFG(false), |
Ted Kremenek | dccc2b2 | 2011-10-07 22:21:02 +0000 | [diff] [blame] | 59 | ReferencedBlockVars(0), |
| 60 | ManagedAnalyses(0) |
Ted Kremenek | 189ecec | 2011-07-21 05:22:47 +0000 | [diff] [blame] | 61 | { |
| 62 | cfgBuildOptions.forcedBlkExprs = &forcedBlkExprs; |
| 63 | } |
| 64 | |
Ted Kremenek | 81ce1c8 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 65 | AnalysisDeclContextManager::AnalysisDeclContextManager(bool useUnoptimizedCFG, |
Jordan Rose | 6d671cc | 2012-09-05 22:55:23 +0000 | [diff] [blame] | 66 | bool addImplicitDtors, |
| 67 | bool addInitializers, |
Ted Kremenek | 14f779c | 2012-09-21 00:09:11 +0000 | [diff] [blame] | 68 | bool addTemporaryDtors, |
| 69 | bool synthesizeBodies) |
| 70 | : SynthesizeBodies(synthesizeBodies) |
| 71 | { |
Ted Kremenek | 189ecec | 2011-07-21 05:22:47 +0000 | [diff] [blame] | 72 | cfgBuildOptions.PruneTriviallyFalseEdges = !useUnoptimizedCFG; |
Ted Kremenek | f9d8290 | 2011-03-10 01:14:05 +0000 | [diff] [blame] | 73 | cfgBuildOptions.AddImplicitDtors = addImplicitDtors; |
| 74 | cfgBuildOptions.AddInitializers = addInitializers; |
Jordan Rose | 6d671cc | 2012-09-05 22:55:23 +0000 | [diff] [blame] | 75 | cfgBuildOptions.AddTemporaryDtors = addTemporaryDtors; |
Ted Kremenek | f9d8290 | 2011-03-10 01:14:05 +0000 | [diff] [blame] | 76 | } |
| 77 | |
Ted Kremenek | 81ce1c8 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 78 | void AnalysisDeclContextManager::clear() { |
Ted Kremenek | d45ff6c | 2009-10-20 21:39:41 +0000 | [diff] [blame] | 79 | for (ContextMap::iterator I = Contexts.begin(), E = Contexts.end(); I!=E; ++I) |
| 80 | delete I->second; |
| 81 | Contexts.clear(); |
| 82 | } |
| 83 | |
Ted Kremenek | 14f779c | 2012-09-21 00:09:11 +0000 | [diff] [blame] | 84 | static BodyFarm &getBodyFarm(ASTContext &C) { |
| 85 | static BodyFarm *BF = new BodyFarm(C); |
| 86 | return *BF; |
| 87 | } |
| 88 | |
Anna Zaks | 00c69a5 | 2013-02-02 00:30:04 +0000 | [diff] [blame] | 89 | Stmt *AnalysisDeclContext::getBody(bool &IsAutosynthesized) const { |
Ted Kremenek | 14f779c | 2012-09-21 00:09:11 +0000 | [diff] [blame] | 90 | if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { |
| 91 | Stmt *Body = FD->getBody(); |
Anna Zaks | 00c69a5 | 2013-02-02 00:30:04 +0000 | [diff] [blame] | 92 | if (!Body && Manager && Manager->synthesizeBodies()) { |
| 93 | IsAutosynthesized = true; |
Ted Kremenek | 14f779c | 2012-09-21 00:09:11 +0000 | [diff] [blame] | 94 | return getBodyFarm(getASTContext()).getBody(FD); |
Anna Zaks | 00c69a5 | 2013-02-02 00:30:04 +0000 | [diff] [blame] | 95 | } |
Ted Kremenek | 14f779c | 2012-09-21 00:09:11 +0000 | [diff] [blame] | 96 | return Body; |
| 97 | } |
Ted Kremenek | cdf5f4a | 2009-08-21 23:58:43 +0000 | [diff] [blame] | 98 | else if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) |
Zhongxing Xu | 14407bf | 2009-07-30 01:17:21 +0000 | [diff] [blame] | 99 | return MD->getBody(); |
Ted Kremenek | 45805b9 | 2009-12-04 20:34:55 +0000 | [diff] [blame] | 100 | else if (const BlockDecl *BD = dyn_cast<BlockDecl>(D)) |
| 101 | return BD->getBody(); |
Mike Stump | 1bacb81 | 2010-01-13 02:59:54 +0000 | [diff] [blame] | 102 | else if (const FunctionTemplateDecl *FunTmpl |
| 103 | = dyn_cast_or_null<FunctionTemplateDecl>(D)) |
| 104 | return FunTmpl->getTemplatedDecl()->getBody(); |
Zhongxing Xu | 14407bf | 2009-07-30 01:17:21 +0000 | [diff] [blame] | 105 | |
Jeffrey Yasskin | 1615d45 | 2009-12-12 05:05:38 +0000 | [diff] [blame] | 106 | llvm_unreachable("unknown code decl"); |
Zhongxing Xu | 14407bf | 2009-07-30 01:17:21 +0000 | [diff] [blame] | 107 | } |
| 108 | |
Anna Zaks | 00c69a5 | 2013-02-02 00:30:04 +0000 | [diff] [blame] | 109 | Stmt *AnalysisDeclContext::getBody() const { |
| 110 | bool Tmp; |
| 111 | return getBody(Tmp); |
| 112 | } |
| 113 | |
| 114 | bool AnalysisDeclContext::isBodyAutosynthesized() const { |
| 115 | bool Tmp; |
| 116 | getBody(Tmp); |
| 117 | return Tmp; |
| 118 | } |
| 119 | |
Ted Kremenek | 81ce1c8 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 120 | const ImplicitParamDecl *AnalysisDeclContext::getSelfDecl() const { |
Ted Kremenek | 608677a | 2009-08-21 23:25:54 +0000 | [diff] [blame] | 121 | if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) |
| 122 | return MD->getSelfDecl(); |
Ted Kremenek | b39fcfa | 2011-11-14 19:36:08 +0000 | [diff] [blame] | 123 | if (const BlockDecl *BD = dyn_cast<BlockDecl>(D)) { |
| 124 | // See if 'self' was captured by the block. |
| 125 | for (BlockDecl::capture_const_iterator it = BD->capture_begin(), |
| 126 | et = BD->capture_end(); it != et; ++it) { |
| 127 | const VarDecl *VD = it->getVariable(); |
| 128 | if (VD->getName() == "self") |
| 129 | return dyn_cast<ImplicitParamDecl>(VD); |
| 130 | } |
| 131 | } |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 132 | |
Ted Kremenek | 608677a | 2009-08-21 23:25:54 +0000 | [diff] [blame] | 133 | return NULL; |
| 134 | } |
| 135 | |
Ted Kremenek | 81ce1c8 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 136 | void AnalysisDeclContext::registerForcedBlockExpression(const Stmt *stmt) { |
Ted Kremenek | a099c59 | 2011-03-10 03:50:34 +0000 | [diff] [blame] | 137 | if (!forcedBlkExprs) |
| 138 | forcedBlkExprs = new CFG::BuildOptions::ForcedBlkExprs(); |
| 139 | // Default construct an entry for 'stmt'. |
Jordy Rose | 1734737 | 2011-06-10 08:49:37 +0000 | [diff] [blame] | 140 | if (const Expr *e = dyn_cast<Expr>(stmt)) |
| 141 | stmt = e->IgnoreParens(); |
Ted Kremenek | a099c59 | 2011-03-10 03:50:34 +0000 | [diff] [blame] | 142 | (void) (*forcedBlkExprs)[stmt]; |
| 143 | } |
| 144 | |
| 145 | const CFGBlock * |
Ted Kremenek | 81ce1c8 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 146 | AnalysisDeclContext::getBlockForRegisteredExpression(const Stmt *stmt) { |
Ted Kremenek | a099c59 | 2011-03-10 03:50:34 +0000 | [diff] [blame] | 147 | assert(forcedBlkExprs); |
Jordy Rose | 1734737 | 2011-06-10 08:49:37 +0000 | [diff] [blame] | 148 | if (const Expr *e = dyn_cast<Expr>(stmt)) |
| 149 | stmt = e->IgnoreParens(); |
Ted Kremenek | a099c59 | 2011-03-10 03:50:34 +0000 | [diff] [blame] | 150 | CFG::BuildOptions::ForcedBlkExprs::const_iterator itr = |
| 151 | forcedBlkExprs->find(stmt); |
| 152 | assert(itr != forcedBlkExprs->end()); |
| 153 | return itr->second; |
| 154 | } |
| 155 | |
Ted Kremenek | 81ce1c8 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 156 | CFG *AnalysisDeclContext::getCFG() { |
Ted Kremenek | 189ecec | 2011-07-21 05:22:47 +0000 | [diff] [blame] | 157 | if (!cfgBuildOptions.PruneTriviallyFalseEdges) |
Ted Kremenek | 4a2b237 | 2010-08-03 00:09:51 +0000 | [diff] [blame] | 158 | return getUnoptimizedCFG(); |
| 159 | |
Ted Kremenek | 0b40532 | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 160 | if (!builtCFG) { |
Ted Kremenek | f9d8290 | 2011-03-10 01:14:05 +0000 | [diff] [blame] | 161 | cfg.reset(CFG::buildCFG(D, getBody(), |
| 162 | &D->getASTContext(), cfgBuildOptions)); |
Ted Kremenek | 0b40532 | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 163 | // Even when the cfg is not successfully built, we don't |
| 164 | // want to try building it again. |
| 165 | builtCFG = true; |
| 166 | } |
Ted Kremenek | f9d8290 | 2011-03-10 01:14:05 +0000 | [diff] [blame] | 167 | return cfg.get(); |
Zhongxing Xu | 14407bf | 2009-07-30 01:17:21 +0000 | [diff] [blame] | 168 | } |
| 169 | |
Ted Kremenek | 81ce1c8 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 170 | CFG *AnalysisDeclContext::getUnoptimizedCFG() { |
Ted Kremenek | dc03bd0 | 2010-08-02 23:46:59 +0000 | [diff] [blame] | 171 | if (!builtCompleteCFG) { |
Ted Kremenek | 189ecec | 2011-07-21 05:22:47 +0000 | [diff] [blame] | 172 | SaveAndRestore<bool> NotPrune(cfgBuildOptions.PruneTriviallyFalseEdges, |
| 173 | false); |
| 174 | completeCFG.reset(CFG::buildCFG(D, getBody(), &D->getASTContext(), |
| 175 | cfgBuildOptions)); |
Ted Kremenek | dc03bd0 | 2010-08-02 23:46:59 +0000 | [diff] [blame] | 176 | // Even when the cfg is not successfully built, we don't |
| 177 | // want to try building it again. |
| 178 | builtCompleteCFG = true; |
| 179 | } |
Ted Kremenek | f9d8290 | 2011-03-10 01:14:05 +0000 | [diff] [blame] | 180 | return completeCFG.get(); |
Ted Kremenek | dc03bd0 | 2010-08-02 23:46:59 +0000 | [diff] [blame] | 181 | } |
| 182 | |
Ted Kremenek | 81ce1c8 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 183 | CFGStmtMap *AnalysisDeclContext::getCFGStmtMap() { |
Ted Kremenek | cc7f1f8 | 2011-02-23 01:51:53 +0000 | [diff] [blame] | 184 | if (cfgStmtMap) |
Ted Kremenek | f9d8290 | 2011-03-10 01:14:05 +0000 | [diff] [blame] | 185 | return cfgStmtMap.get(); |
Ted Kremenek | cc7f1f8 | 2011-02-23 01:51:53 +0000 | [diff] [blame] | 186 | |
| 187 | if (CFG *c = getCFG()) { |
Ted Kremenek | f9d8290 | 2011-03-10 01:14:05 +0000 | [diff] [blame] | 188 | cfgStmtMap.reset(CFGStmtMap::Build(c, &getParentMap())); |
| 189 | return cfgStmtMap.get(); |
Ted Kremenek | cc7f1f8 | 2011-02-23 01:51:53 +0000 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | return 0; |
| 193 | } |
Ted Kremenek | 80861ca | 2011-02-23 01:51:59 +0000 | [diff] [blame] | 194 | |
Ted Kremenek | 81ce1c8 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 195 | CFGReverseBlockReachabilityAnalysis *AnalysisDeclContext::getCFGReachablityAnalysis() { |
Ted Kremenek | 80861ca | 2011-02-23 01:51:59 +0000 | [diff] [blame] | 196 | if (CFA) |
Ted Kremenek | f9d8290 | 2011-03-10 01:14:05 +0000 | [diff] [blame] | 197 | return CFA.get(); |
Ted Kremenek | cc7f1f8 | 2011-02-23 01:51:53 +0000 | [diff] [blame] | 198 | |
Ted Kremenek | 80861ca | 2011-02-23 01:51:59 +0000 | [diff] [blame] | 199 | if (CFG *c = getCFG()) { |
Ted Kremenek | ddc06d0 | 2011-03-19 01:00:33 +0000 | [diff] [blame] | 200 | CFA.reset(new CFGReverseBlockReachabilityAnalysis(*c)); |
Ted Kremenek | f9d8290 | 2011-03-10 01:14:05 +0000 | [diff] [blame] | 201 | return CFA.get(); |
Ted Kremenek | 80861ca | 2011-02-23 01:51:59 +0000 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | return 0; |
| 205 | } |
Ted Kremenek | cc7f1f8 | 2011-02-23 01:51:53 +0000 | [diff] [blame] | 206 | |
Ted Kremenek | 72be32a | 2011-12-22 23:33:52 +0000 | [diff] [blame] | 207 | void AnalysisDeclContext::dumpCFG(bool ShowColors) { |
David Blaikie | bbafb8a | 2012-03-11 07:00:24 +0000 | [diff] [blame] | 208 | getCFG()->dump(getASTContext().getLangOpts(), ShowColors); |
Anders Carlsson | 36ecb1f | 2011-01-16 22:05:23 +0000 | [diff] [blame] | 209 | } |
| 210 | |
Ted Kremenek | 81ce1c8 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 211 | ParentMap &AnalysisDeclContext::getParentMap() { |
Jordan Rose | 25bc20f | 2012-07-26 20:04:30 +0000 | [diff] [blame] | 212 | if (!PM) { |
Ted Kremenek | f9d8290 | 2011-03-10 01:14:05 +0000 | [diff] [blame] | 213 | PM.reset(new ParentMap(getBody())); |
Jordan Rose | 25bc20f | 2012-07-26 20:04:30 +0000 | [diff] [blame] | 214 | if (const CXXConstructorDecl *C = dyn_cast<CXXConstructorDecl>(getDecl())) { |
| 215 | for (CXXConstructorDecl::init_const_iterator I = C->init_begin(), |
| 216 | E = C->init_end(); |
| 217 | I != E; ++I) { |
| 218 | PM->addStmt((*I)->getInit()); |
| 219 | } |
| 220 | } |
| 221 | } |
Zhongxing Xu | 14407bf | 2009-07-30 01:17:21 +0000 | [diff] [blame] | 222 | return *PM; |
| 223 | } |
| 224 | |
Ted Kremenek | 81ce1c8 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 225 | PseudoConstantAnalysis *AnalysisDeclContext::getPseudoConstantAnalysis() { |
Tom Care | b9933f3 | 2010-08-18 21:17:24 +0000 | [diff] [blame] | 226 | if (!PCA) |
Ted Kremenek | f9d8290 | 2011-03-10 01:14:05 +0000 | [diff] [blame] | 227 | PCA.reset(new PseudoConstantAnalysis(getBody())); |
| 228 | return PCA.get(); |
Tom Care | b9933f3 | 2010-08-18 21:17:24 +0000 | [diff] [blame] | 229 | } |
| 230 | |
Jordy Rose | 4f8198e | 2012-04-28 01:58:08 +0000 | [diff] [blame] | 231 | AnalysisDeclContext *AnalysisDeclContextManager::getContext(const Decl *D) { |
Ted Kremenek | 14f779c | 2012-09-21 00:09:11 +0000 | [diff] [blame] | 232 | if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { |
Ted Kremenek | 3d0ec38 | 2012-09-24 21:17:14 +0000 | [diff] [blame] | 233 | // Calling 'hasBody' replaces 'FD' in place with the FunctionDecl |
| 234 | // that has the body. |
Ted Kremenek | 14f779c | 2012-09-21 00:09:11 +0000 | [diff] [blame] | 235 | FD->hasBody(FD); |
| 236 | D = FD; |
| 237 | } |
| 238 | |
Ted Kremenek | 81ce1c8 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 239 | AnalysisDeclContext *&AC = Contexts[D]; |
Ted Kremenek | cdf5f4a | 2009-08-21 23:58:43 +0000 | [diff] [blame] | 240 | if (!AC) |
Jordy Rose | 4f8198e | 2012-04-28 01:58:08 +0000 | [diff] [blame] | 241 | AC = new AnalysisDeclContext(this, D, cfgBuildOptions); |
Ted Kremenek | cdf5f4a | 2009-08-21 23:58:43 +0000 | [diff] [blame] | 242 | return AC; |
Zhongxing Xu | 14407bf | 2009-07-30 01:17:21 +0000 | [diff] [blame] | 243 | } |
Zhongxing Xu | 9ad0b46 | 2009-08-03 07:23:22 +0000 | [diff] [blame] | 244 | |
Ted Kremenek | 142adc4 | 2011-10-23 02:31:52 +0000 | [diff] [blame] | 245 | const StackFrameContext * |
Ted Kremenek | 81ce1c8 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 246 | AnalysisDeclContext::getStackFrame(LocationContext const *Parent, const Stmt *S, |
Ted Kremenek | 142adc4 | 2011-10-23 02:31:52 +0000 | [diff] [blame] | 247 | const CFGBlock *Blk, unsigned Idx) { |
| 248 | return getLocationContextManager().getStackFrame(this, Parent, S, Blk, Idx); |
| 249 | } |
| 250 | |
Ted Kremenek | c3da376 | 2012-06-01 20:04:04 +0000 | [diff] [blame] | 251 | const BlockInvocationContext * |
| 252 | AnalysisDeclContext::getBlockInvocationContext(const LocationContext *parent, |
| 253 | const clang::BlockDecl *BD, |
| 254 | const void *ContextData) { |
| 255 | return getLocationContextManager().getBlockInvocationContext(this, parent, |
| 256 | BD, ContextData); |
| 257 | } |
| 258 | |
Ted Kremenek | 81ce1c8 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 259 | LocationContextManager & AnalysisDeclContext::getLocationContextManager() { |
Ted Kremenek | 142adc4 | 2011-10-23 02:31:52 +0000 | [diff] [blame] | 260 | assert(Manager && |
Ted Kremenek | 81ce1c8 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 261 | "Cannot create LocationContexts without an AnalysisDeclContextManager!"); |
Ted Kremenek | 142adc4 | 2011-10-23 02:31:52 +0000 | [diff] [blame] | 262 | return Manager->getLocationContextManager(); |
| 263 | } |
| 264 | |
Ted Kremenek | 2538824 | 2009-12-04 00:50:10 +0000 | [diff] [blame] | 265 | //===----------------------------------------------------------------------===// |
| 266 | // FoldingSet profiling. |
| 267 | //===----------------------------------------------------------------------===// |
| 268 | |
Ted Kremenek | 2538824 | 2009-12-04 00:50:10 +0000 | [diff] [blame] | 269 | void LocationContext::ProfileCommon(llvm::FoldingSetNodeID &ID, |
| 270 | ContextKind ck, |
Ted Kremenek | 81ce1c8 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 271 | AnalysisDeclContext *ctx, |
Ted Kremenek | 2538824 | 2009-12-04 00:50:10 +0000 | [diff] [blame] | 272 | const LocationContext *parent, |
Ted Kremenek | 5ef32db | 2011-08-12 23:37:29 +0000 | [diff] [blame] | 273 | const void *data) { |
Ted Kremenek | 43d4a89 | 2009-12-04 01:28:56 +0000 | [diff] [blame] | 274 | ID.AddInteger(ck); |
| 275 | ID.AddPointer(ctx); |
| 276 | ID.AddPointer(parent); |
Ted Kremenek | 2538824 | 2009-12-04 00:50:10 +0000 | [diff] [blame] | 277 | ID.AddPointer(data); |
Zhongxing Xu | 9ad0b46 | 2009-08-03 07:23:22 +0000 | [diff] [blame] | 278 | } |
| 279 | |
Ted Kremenek | 2538824 | 2009-12-04 00:50:10 +0000 | [diff] [blame] | 280 | void StackFrameContext::Profile(llvm::FoldingSetNodeID &ID) { |
Ted Kremenek | 81ce1c8 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 281 | Profile(ID, getAnalysisDeclContext(), getParent(), CallSite, Block, Index); |
Zhongxing Xu | 9ad0b46 | 2009-08-03 07:23:22 +0000 | [diff] [blame] | 282 | } |
| 283 | |
Ted Kremenek | 2538824 | 2009-12-04 00:50:10 +0000 | [diff] [blame] | 284 | void ScopeContext::Profile(llvm::FoldingSetNodeID &ID) { |
Ted Kremenek | 81ce1c8 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 285 | Profile(ID, getAnalysisDeclContext(), getParent(), Enter); |
Ted Kremenek | 2538824 | 2009-12-04 00:50:10 +0000 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | void BlockInvocationContext::Profile(llvm::FoldingSetNodeID &ID) { |
Ted Kremenek | c3da376 | 2012-06-01 20:04:04 +0000 | [diff] [blame] | 289 | Profile(ID, getAnalysisDeclContext(), getParent(), BD, ContextData); |
Ted Kremenek | 2538824 | 2009-12-04 00:50:10 +0000 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | //===----------------------------------------------------------------------===// |
Ted Kremenek | 43d4a89 | 2009-12-04 01:28:56 +0000 | [diff] [blame] | 293 | // LocationContext creation. |
Ted Kremenek | 2538824 | 2009-12-04 00:50:10 +0000 | [diff] [blame] | 294 | //===----------------------------------------------------------------------===// |
| 295 | |
Ted Kremenek | 43d4a89 | 2009-12-04 01:28:56 +0000 | [diff] [blame] | 296 | template <typename LOC, typename DATA> |
| 297 | const LOC* |
Ted Kremenek | 81ce1c8 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 298 | LocationContextManager::getLocationContext(AnalysisDeclContext *ctx, |
Ted Kremenek | 43d4a89 | 2009-12-04 01:28:56 +0000 | [diff] [blame] | 299 | const LocationContext *parent, |
| 300 | const DATA *d) { |
| 301 | llvm::FoldingSetNodeID ID; |
| 302 | LOC::Profile(ID, ctx, parent, d); |
| 303 | void *InsertPos; |
Ted Kremenek | 0b40532 | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 304 | |
Ted Kremenek | 43d4a89 | 2009-12-04 01:28:56 +0000 | [diff] [blame] | 305 | LOC *L = cast_or_null<LOC>(Contexts.FindNodeOrInsertPos(ID, InsertPos)); |
Ted Kremenek | 0b40532 | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 306 | |
Ted Kremenek | 43d4a89 | 2009-12-04 01:28:56 +0000 | [diff] [blame] | 307 | if (!L) { |
| 308 | L = new LOC(ctx, parent, d); |
| 309 | Contexts.InsertNode(L, InsertPos); |
| 310 | } |
| 311 | return L; |
Ted Kremenek | d45ff6c | 2009-10-20 21:39:41 +0000 | [diff] [blame] | 312 | } |
| 313 | |
Ted Kremenek | 43d4a89 | 2009-12-04 01:28:56 +0000 | [diff] [blame] | 314 | const StackFrameContext* |
Ted Kremenek | 81ce1c8 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 315 | LocationContextManager::getStackFrame(AnalysisDeclContext *ctx, |
Ted Kremenek | 00aeae9 | 2009-08-21 23:39:58 +0000 | [diff] [blame] | 316 | const LocationContext *parent, |
Ted Kremenek | 8219b82 | 2010-12-16 07:46:53 +0000 | [diff] [blame] | 317 | const Stmt *s, |
Zhongxing Xu | a1a9ba1 | 2010-11-24 13:08:51 +0000 | [diff] [blame] | 318 | const CFGBlock *blk, unsigned idx) { |
Zhongxing Xu | 51f1ca8 | 2009-12-24 03:34:38 +0000 | [diff] [blame] | 319 | llvm::FoldingSetNodeID ID; |
Ted Kremenek | 8219b82 | 2010-12-16 07:46:53 +0000 | [diff] [blame] | 320 | StackFrameContext::Profile(ID, ctx, parent, s, blk, idx); |
Zhongxing Xu | 51f1ca8 | 2009-12-24 03:34:38 +0000 | [diff] [blame] | 321 | void *InsertPos; |
Ted Kremenek | 0b40532 | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 322 | StackFrameContext *L = |
Zhongxing Xu | 51f1ca8 | 2009-12-24 03:34:38 +0000 | [diff] [blame] | 323 | cast_or_null<StackFrameContext>(Contexts.FindNodeOrInsertPos(ID, InsertPos)); |
| 324 | if (!L) { |
Ted Kremenek | 8219b82 | 2010-12-16 07:46:53 +0000 | [diff] [blame] | 325 | L = new StackFrameContext(ctx, parent, s, blk, idx); |
Zhongxing Xu | 51f1ca8 | 2009-12-24 03:34:38 +0000 | [diff] [blame] | 326 | Contexts.InsertNode(L, InsertPos); |
| 327 | } |
| 328 | return L; |
Zhongxing Xu | 9ad0b46 | 2009-08-03 07:23:22 +0000 | [diff] [blame] | 329 | } |
| 330 | |
Ted Kremenek | 43d4a89 | 2009-12-04 01:28:56 +0000 | [diff] [blame] | 331 | const ScopeContext * |
Ted Kremenek | 81ce1c8 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 332 | LocationContextManager::getScope(AnalysisDeclContext *ctx, |
Ted Kremenek | 43d4a89 | 2009-12-04 01:28:56 +0000 | [diff] [blame] | 333 | const LocationContext *parent, |
| 334 | const Stmt *s) { |
| 335 | return getLocationContext<ScopeContext, Stmt>(ctx, parent, s); |
| 336 | } |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 337 | |
Ted Kremenek | c3da376 | 2012-06-01 20:04:04 +0000 | [diff] [blame] | 338 | const BlockInvocationContext * |
| 339 | LocationContextManager::getBlockInvocationContext(AnalysisDeclContext *ctx, |
| 340 | const LocationContext *parent, |
| 341 | const BlockDecl *BD, |
| 342 | const void *ContextData) { |
| 343 | llvm::FoldingSetNodeID ID; |
| 344 | BlockInvocationContext::Profile(ID, ctx, parent, BD, ContextData); |
| 345 | void *InsertPos; |
| 346 | BlockInvocationContext *L = |
| 347 | cast_or_null<BlockInvocationContext>(Contexts.FindNodeOrInsertPos(ID, |
| 348 | InsertPos)); |
| 349 | if (!L) { |
| 350 | L = new BlockInvocationContext(ctx, parent, BD, ContextData); |
| 351 | Contexts.InsertNode(L, InsertPos); |
| 352 | } |
| 353 | return L; |
| 354 | } |
| 355 | |
Ted Kremenek | 0f5e6f88 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 356 | //===----------------------------------------------------------------------===// |
Ted Kremenek | 04af9f2 | 2009-12-07 22:05:27 +0000 | [diff] [blame] | 357 | // LocationContext methods. |
| 358 | //===----------------------------------------------------------------------===// |
| 359 | |
| 360 | const StackFrameContext *LocationContext::getCurrentStackFrame() const { |
| 361 | const LocationContext *LC = this; |
| 362 | while (LC) { |
| 363 | if (const StackFrameContext *SFC = dyn_cast<StackFrameContext>(LC)) |
| 364 | return SFC; |
| 365 | LC = LC->getParent(); |
| 366 | } |
| 367 | return NULL; |
| 368 | } |
| 369 | |
Anna Zaks | 44dc91b | 2012-11-03 02:54:16 +0000 | [diff] [blame] | 370 | bool LocationContext::inTopFrame() const { |
| 371 | return getCurrentStackFrame()->inTopFrame(); |
| 372 | } |
| 373 | |
Zhongxing Xu | 86bab2c | 2010-02-17 08:45:06 +0000 | [diff] [blame] | 374 | bool LocationContext::isParentOf(const LocationContext *LC) const { |
| 375 | do { |
| 376 | const LocationContext *Parent = LC->getParent(); |
| 377 | if (Parent == this) |
| 378 | return true; |
| 379 | else |
| 380 | LC = Parent; |
| 381 | } while (LC); |
| 382 | |
| 383 | return false; |
| 384 | } |
| 385 | |
Ted Kremenek | 04af9f2 | 2009-12-07 22:05:27 +0000 | [diff] [blame] | 386 | //===----------------------------------------------------------------------===// |
Ted Kremenek | 0f5e6f88 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 387 | // Lazily generated map to query the external variables referenced by a Block. |
| 388 | //===----------------------------------------------------------------------===// |
| 389 | |
| 390 | namespace { |
| 391 | class FindBlockDeclRefExprsVals : public StmtVisitor<FindBlockDeclRefExprsVals>{ |
| 392 | BumpVector<const VarDecl*> &BEVals; |
| 393 | BumpVectorContext &BC; |
Benjamin Kramer | 616f802 | 2012-03-10 15:08:09 +0000 | [diff] [blame] | 394 | llvm::SmallPtrSet<const VarDecl*, 4> Visited; |
| 395 | llvm::SmallPtrSet<const DeclContext*, 4> IgnoredContexts; |
Ted Kremenek | 0f5e6f88 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 396 | public: |
| 397 | FindBlockDeclRefExprsVals(BumpVector<const VarDecl*> &bevals, |
| 398 | BumpVectorContext &bc) |
| 399 | : BEVals(bevals), BC(bc) {} |
Ted Kremenek | 575398e | 2010-03-10 00:18:11 +0000 | [diff] [blame] | 400 | |
| 401 | bool IsTrackedDecl(const VarDecl *VD) { |
| 402 | const DeclContext *DC = VD->getDeclContext(); |
| 403 | return IgnoredContexts.count(DC) == 0; |
| 404 | } |
| 405 | |
Ted Kremenek | 0f5e6f88 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 406 | void VisitStmt(Stmt *S) { |
John McCall | 8322c3a | 2011-02-13 04:07:26 +0000 | [diff] [blame] | 407 | for (Stmt::child_range I = S->children(); I; ++I) |
Ted Kremenek | 0f5e6f88 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 408 | if (Stmt *child = *I) |
| 409 | Visit(child); |
| 410 | } |
Ted Kremenek | 5abd69d | 2010-02-06 00:30:00 +0000 | [diff] [blame] | 411 | |
Ted Kremenek | 299cfb7 | 2011-12-22 01:30:46 +0000 | [diff] [blame] | 412 | void VisitDeclRefExpr(DeclRefExpr *DR) { |
Ted Kremenek | 5abd69d | 2010-02-06 00:30:00 +0000 | [diff] [blame] | 413 | // Non-local variables are also directly modified. |
Benjamin Kramer | 616f802 | 2012-03-10 15:08:09 +0000 | [diff] [blame] | 414 | if (const VarDecl *VD = dyn_cast<VarDecl>(DR->getDecl())) { |
Ted Kremenek | 5abd69d | 2010-02-06 00:30:00 +0000 | [diff] [blame] | 415 | if (!VD->hasLocalStorage()) { |
Benjamin Kramer | 616f802 | 2012-03-10 15:08:09 +0000 | [diff] [blame] | 416 | if (Visited.insert(VD)) |
Ted Kremenek | 5abd69d | 2010-02-06 00:30:00 +0000 | [diff] [blame] | 417 | BEVals.push_back(VD, BC); |
Ted Kremenek | 5abd69d | 2010-02-06 00:30:00 +0000 | [diff] [blame] | 418 | } |
Benjamin Kramer | 616f802 | 2012-03-10 15:08:09 +0000 | [diff] [blame] | 419 | } |
Ted Kremenek | 5abd69d | 2010-02-06 00:30:00 +0000 | [diff] [blame] | 420 | } |
Ted Kremenek | 575398e | 2010-03-10 00:18:11 +0000 | [diff] [blame] | 421 | |
Ted Kremenek | 575398e | 2010-03-10 00:18:11 +0000 | [diff] [blame] | 422 | void VisitBlockExpr(BlockExpr *BR) { |
| 423 | // Blocks containing blocks can transitively capture more variables. |
| 424 | IgnoredContexts.insert(BR->getBlockDecl()); |
| 425 | Visit(BR->getBlockDecl()->getBody()); |
| 426 | } |
Ted Kremenek | 299cfb7 | 2011-12-22 01:30:46 +0000 | [diff] [blame] | 427 | |
| 428 | void VisitPseudoObjectExpr(PseudoObjectExpr *PE) { |
| 429 | for (PseudoObjectExpr::semantics_iterator it = PE->semantics_begin(), |
| 430 | et = PE->semantics_end(); it != et; ++it) { |
| 431 | Expr *Semantic = *it; |
| 432 | if (OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(Semantic)) |
| 433 | Semantic = OVE->getSourceExpr(); |
| 434 | Visit(Semantic); |
| 435 | } |
| 436 | } |
Ted Kremenek | 0b40532 | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 437 | }; |
Ted Kremenek | 0f5e6f88 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 438 | } // end anonymous namespace |
| 439 | |
| 440 | typedef BumpVector<const VarDecl*> DeclVec; |
| 441 | |
| 442 | static DeclVec* LazyInitializeReferencedDecls(const BlockDecl *BD, |
| 443 | void *&Vec, |
| 444 | llvm::BumpPtrAllocator &A) { |
| 445 | if (Vec) |
| 446 | return (DeclVec*) Vec; |
Ted Kremenek | 0b40532 | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 447 | |
Ted Kremenek | 0f5e6f88 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 448 | BumpVectorContext BC(A); |
| 449 | DeclVec *BV = (DeclVec*) A.Allocate<DeclVec>(); |
| 450 | new (BV) DeclVec(BC, 10); |
Ted Kremenek | 0b40532 | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 451 | |
Ted Kremenek | 3e871d8 | 2012-12-06 07:17:26 +0000 | [diff] [blame] | 452 | // Go through the capture list. |
| 453 | for (BlockDecl::capture_const_iterator CI = BD->capture_begin(), |
| 454 | CE = BD->capture_end(); CI != CE; ++CI) { |
| 455 | BV->push_back(CI->getVariable(), BC); |
| 456 | } |
| 457 | |
| 458 | // Find the referenced global/static variables. |
Ted Kremenek | 0f5e6f88 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 459 | FindBlockDeclRefExprsVals F(*BV, BC); |
| 460 | F.Visit(BD->getBody()); |
Ted Kremenek | 0b40532 | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 461 | |
| 462 | Vec = BV; |
Ted Kremenek | 0f5e6f88 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 463 | return BV; |
| 464 | } |
| 465 | |
Ted Kremenek | 81ce1c8 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 466 | std::pair<AnalysisDeclContext::referenced_decls_iterator, |
| 467 | AnalysisDeclContext::referenced_decls_iterator> |
| 468 | AnalysisDeclContext::getReferencedBlockVars(const BlockDecl *BD) { |
Ted Kremenek | 0f5e6f88 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 469 | if (!ReferencedBlockVars) |
| 470 | ReferencedBlockVars = new llvm::DenseMap<const BlockDecl*,void*>(); |
Ted Kremenek | 0b40532 | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 471 | |
Ted Kremenek | 0f5e6f88 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 472 | DeclVec *V = LazyInitializeReferencedDecls(BD, (*ReferencedBlockVars)[BD], A); |
| 473 | return std::make_pair(V->begin(), V->end()); |
| 474 | } |
| 475 | |
Ted Kremenek | 81ce1c8 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 476 | ManagedAnalysis *&AnalysisDeclContext::getAnalysisImpl(const void *tag) { |
Ted Kremenek | dccc2b2 | 2011-10-07 22:21:02 +0000 | [diff] [blame] | 477 | if (!ManagedAnalyses) |
| 478 | ManagedAnalyses = new ManagedAnalysisMap(); |
| 479 | ManagedAnalysisMap *M = (ManagedAnalysisMap*) ManagedAnalyses; |
| 480 | return (*M)[tag]; |
| 481 | } |
| 482 | |
Ted Kremenek | 0f5e6f88 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 483 | //===----------------------------------------------------------------------===// |
| 484 | // Cleanup. |
| 485 | //===----------------------------------------------------------------------===// |
| 486 | |
Ted Kremenek | dccc2b2 | 2011-10-07 22:21:02 +0000 | [diff] [blame] | 487 | ManagedAnalysis::~ManagedAnalysis() {} |
| 488 | |
Ted Kremenek | 81ce1c8 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 489 | AnalysisDeclContext::~AnalysisDeclContext() { |
Ted Kremenek | f9d8290 | 2011-03-10 01:14:05 +0000 | [diff] [blame] | 490 | delete forcedBlkExprs; |
Ted Kremenek | 0f5e6f88 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 491 | delete ReferencedBlockVars; |
Ted Kremenek | dccc2b2 | 2011-10-07 22:21:02 +0000 | [diff] [blame] | 492 | // Release the managed analyses. |
| 493 | if (ManagedAnalyses) { |
| 494 | ManagedAnalysisMap *M = (ManagedAnalysisMap*) ManagedAnalyses; |
| 495 | for (ManagedAnalysisMap::iterator I = M->begin(), E = M->end(); I!=E; ++I) |
| 496 | delete I->second; |
| 497 | delete M; |
| 498 | } |
Ted Kremenek | 0f5e6f88 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 499 | } |
| 500 | |
Ted Kremenek | 81ce1c8 | 2011-10-24 01:32:45 +0000 | [diff] [blame] | 501 | AnalysisDeclContextManager::~AnalysisDeclContextManager() { |
Ted Kremenek | 0f5e6f88 | 2009-11-26 02:31:33 +0000 | [diff] [blame] | 502 | for (ContextMap::iterator I = Contexts.begin(), E = Contexts.end(); I!=E; ++I) |
| 503 | delete I->second; |
| 504 | } |
Ted Kremenek | 43d4a89 | 2009-12-04 01:28:56 +0000 | [diff] [blame] | 505 | |
| 506 | LocationContext::~LocationContext() {} |
| 507 | |
| 508 | LocationContextManager::~LocationContextManager() { |
| 509 | clear(); |
| 510 | } |
| 511 | |
| 512 | void LocationContextManager::clear() { |
| 513 | for (llvm::FoldingSet<LocationContext>::iterator I = Contexts.begin(), |
Ted Kremenek | 0b40532 | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 514 | E = Contexts.end(); I != E; ) { |
Ted Kremenek | 43d4a89 | 2009-12-04 01:28:56 +0000 | [diff] [blame] | 515 | LocationContext *LC = &*I; |
| 516 | ++I; |
| 517 | delete LC; |
| 518 | } |
Ted Kremenek | 0b40532 | 2010-03-23 00:13:23 +0000 | [diff] [blame] | 519 | |
Ted Kremenek | 43d4a89 | 2009-12-04 01:28:56 +0000 | [diff] [blame] | 520 | Contexts.clear(); |
| 521 | } |
| 522 | |