Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 15ce164

Browse files
committed
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
1 parent 974c5f9 commit 15ce164

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

include/clang/Analysis/AnalysisContext.h

-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ class AnalysisDeclContext {
9292

9393
llvm::BumpPtrAllocator A;
9494

95-
// FIXME: remove.
9695
llvm::DenseMap<const BlockDecl*,void*> *ReferencedBlockVars;
9796

9897
void *ManagedAnalyses;

lib/Analysis/AnalysisDeclContext.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ class FindBlockDeclRefExprsVals : public StmtVisitor<FindBlockDeclRefExprsVals>{
353353
Visit(child);
354354
}
355355

356-
void VisitDeclRefExpr(const DeclRefExpr *DR) {
356+
void VisitDeclRefExpr(DeclRefExpr *DR) {
357357
// Non-local variables are also directly modified.
358358
if (const VarDecl *VD = dyn_cast<VarDecl>(DR->getDecl()))
359359
if (!VD->hasLocalStorage()) {
@@ -381,6 +381,16 @@ class FindBlockDeclRefExprsVals : public StmtVisitor<FindBlockDeclRefExprsVals>{
381381
IgnoredContexts.insert(BR->getBlockDecl());
382382
Visit(BR->getBlockDecl()->getBody());
383383
}
384+
385+
void VisitPseudoObjectExpr(PseudoObjectExpr *PE) {
386+
for (PseudoObjectExpr::semantics_iterator it = PE->semantics_begin(),
387+
et = PE->semantics_end(); it != et; ++it) {
388+
Expr *Semantic = *it;
389+
if (OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(Semantic))
390+
Semantic = OVE->getSourceExpr();
391+
Visit(Semantic);
392+
}
393+
}
384394
};
385395
} // end anonymous namespace
386396

lib/Analysis/LiveVariables.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -354,10 +354,11 @@ void TransferFunctions::VisitBinaryOperator(BinaryOperator *B) {
354354
}
355355

356356
void TransferFunctions::VisitBlockExpr(BlockExpr *BE) {
357-
const BlockDecl *BD = BE->getBlockDecl();
358-
for (BlockDecl::capture_const_iterator it = BD->capture_begin(),
359-
ei = BD->capture_end(); it != ei; ++it) {
360-
const VarDecl *VD = it->getVariable();
357+
AnalysisDeclContext::referenced_decls_iterator I, E;
358+
llvm::tie(I, E) =
359+
LV.analysisContext.getReferencedBlockVars(BE->getBlockDecl());
360+
for ( ; I != E ; ++I) {
361+
const VarDecl *VD = *I;
361362
if (isAlwaysAlive(VD))
362363
continue;
363364
val.liveDecls = LV.DSetFact.add(val.liveDecls, VD);

0 commit comments

Comments
 (0)