diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-12-22 01:30:46 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-12-22 01:30:46 +0000 |
commit | 15ce164836472bfba88b30e53aa3f6ac0fb8a95d (patch) | |
tree | 3260a62044a3b2309f779bb92ea6048226cc66fb | |
parent | 974c5f93d0ce4f0699a6f0a4402f6b367da495e3 (diff) |
Enhance AnalysisDeclContext::getReferencedBlockVars() to understand PseudoObjExprs. It turns out
that the information collected by this method is a super set of the captured variables in BlockDecl.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147122 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Analysis/AnalysisContext.h | 1 | ||||
-rw-r--r-- | lib/Analysis/AnalysisDeclContext.cpp | 12 | ||||
-rw-r--r-- | lib/Analysis/LiveVariables.cpp | 9 |
3 files changed, 16 insertions, 6 deletions
diff --git a/include/clang/Analysis/AnalysisContext.h b/include/clang/Analysis/AnalysisContext.h index a204d83009..f4ece34286 100644 --- a/include/clang/Analysis/AnalysisContext.h +++ b/include/clang/Analysis/AnalysisContext.h @@ -92,7 +92,6 @@ class AnalysisDeclContext { llvm::BumpPtrAllocator A; - // FIXME: remove. llvm::DenseMap<const BlockDecl*,void*> *ReferencedBlockVars; void *ManagedAnalyses; diff --git a/lib/Analysis/AnalysisDeclContext.cpp b/lib/Analysis/AnalysisDeclContext.cpp index 546cf98f68..96a92b4b5b 100644 --- a/lib/Analysis/AnalysisDeclContext.cpp +++ b/lib/Analysis/AnalysisDeclContext.cpp @@ -353,7 +353,7 @@ public: Visit(child); } - void VisitDeclRefExpr(const DeclRefExpr *DR) { + void VisitDeclRefExpr(DeclRefExpr *DR) { // Non-local variables are also directly modified. if (const VarDecl *VD = dyn_cast<VarDecl>(DR->getDecl())) if (!VD->hasLocalStorage()) { @@ -381,6 +381,16 @@ public: IgnoredContexts.insert(BR->getBlockDecl()); Visit(BR->getBlockDecl()->getBody()); } + + void VisitPseudoObjectExpr(PseudoObjectExpr *PE) { + for (PseudoObjectExpr::semantics_iterator it = PE->semantics_begin(), + et = PE->semantics_end(); it != et; ++it) { + Expr *Semantic = *it; + if (OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(Semantic)) + Semantic = OVE->getSourceExpr(); + Visit(Semantic); + } + } }; } // end anonymous namespace diff --git a/lib/Analysis/LiveVariables.cpp b/lib/Analysis/LiveVariables.cpp index 89cf9f8bbb..ff6607d51a 100644 --- a/lib/Analysis/LiveVariables.cpp +++ b/lib/Analysis/LiveVariables.cpp @@ -354,10 +354,11 @@ void TransferFunctions::VisitBinaryOperator(BinaryOperator *B) { } void TransferFunctions::VisitBlockExpr(BlockExpr *BE) { - const BlockDecl *BD = BE->getBlockDecl(); - for (BlockDecl::capture_const_iterator it = BD->capture_begin(), - ei = BD->capture_end(); it != ei; ++it) { - const VarDecl *VD = it->getVariable(); + AnalysisDeclContext::referenced_decls_iterator I, E; + llvm::tie(I, E) = + LV.analysisContext.getReferencedBlockVars(BE->getBlockDecl()); + for ( ; I != E ; ++I) { + const VarDecl *VD = *I; if (isAlwaysAlive(VD)) continue; val.liveDecls = LV.DSetFact.add(val.liveDecls, VD); |