Remove BlockDeclRefExpr and introduce a bit on DeclRefExpr to
track whether the referenced declaration comes from an enclosing
local context.  I'm amenable to suggestions about the exact meaning
of this bit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152491 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/AnalysisDeclContext.cpp b/lib/Analysis/AnalysisDeclContext.cpp
index cbb08fd..1020898 100644
--- a/lib/Analysis/AnalysisDeclContext.cpp
+++ b/lib/Analysis/AnalysisDeclContext.cpp
@@ -362,20 +362,16 @@
           flag = 1;
           BEVals.push_back(VD, BC);
         }
+      } else if (DR->refersToEnclosingLocal()) {
+        unsigned &flag = Visited[VD];
+        if (!flag) {
+          flag = 1;
+          if (IsTrackedDecl(VD))
+            BEVals.push_back(VD, BC);
+        }
       }
   }
 
-  void VisitBlockDeclRefExpr(BlockDeclRefExpr *DR) {
-    if (const VarDecl *VD = dyn_cast<VarDecl>(DR->getDecl())) {
-      unsigned &flag = Visited[VD];
-      if (!flag) {
-        flag = 1;
-        if (IsTrackedDecl(VD))
-          BEVals.push_back(VD, BC);
-      }
-    }
-  }
-
   void VisitBlockExpr(BlockExpr *BR) {
     // Blocks containing blocks can transitively capture more variables.
     IgnoredContexts.insert(BR->getBlockDecl());