[cfe-commits] r147122 - in /cfe/trunk: include/clang/Analysis/AnalysisContext.h lib/Analysis/AnalysisDeclContext.cpp lib/Analysis/LiveVariables.cpp

Ted Kremenek kremenek at apple.com
Wed Dec 21 17:30:47 PST 2011


Author: kremenek
Date: Wed Dec 21 19:30:46 2011
New Revision: 147122

URL: http://llvm.org/viewvc/llvm-project?rev=147122&view=rev
Log:
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.

Modified:
    cfe/trunk/include/clang/Analysis/AnalysisContext.h
    cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp
    cfe/trunk/lib/Analysis/LiveVariables.cpp

Modified: cfe/trunk/include/clang/Analysis/AnalysisContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/AnalysisContext.h?rev=147122&r1=147121&r2=147122&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/AnalysisContext.h (original)
+++ cfe/trunk/include/clang/Analysis/AnalysisContext.h Wed Dec 21 19:30:46 2011
@@ -92,7 +92,6 @@
 
   llvm::BumpPtrAllocator A;
 
-  // FIXME: remove.
   llvm::DenseMap<const BlockDecl*,void*> *ReferencedBlockVars;
 
   void *ManagedAnalyses;

Modified: cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp?rev=147122&r1=147121&r2=147122&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp (original)
+++ cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp Wed Dec 21 19:30:46 2011
@@ -353,7 +353,7 @@
         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 @@
     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
 

Modified: cfe/trunk/lib/Analysis/LiveVariables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/LiveVariables.cpp?rev=147122&r1=147121&r2=147122&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/LiveVariables.cpp (original)
+++ cfe/trunk/lib/Analysis/LiveVariables.cpp Wed Dec 21 19:30:46 2011
@@ -354,10 +354,11 @@
 }
 
 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);





More information about the cfe-commits mailing list