[cfe-commits] r152494 - /cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp

Benjamin Kramer benny.kra at googlemail.com
Sat Mar 10 07:08:09 PST 2012


Author: d0k
Date: Sat Mar 10 09:08:09 2012
New Revision: 152494

URL: http://llvm.org/viewvc/llvm-project?rev=152494&view=rev
Log:
Replace a map of boolean values with a set.

No functionality change.

Modified:
    cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp

Modified: cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp?rev=152494&r1=152493&r2=152494&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp (original)
+++ cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp Sat Mar 10 09:08:09 2012
@@ -25,7 +25,7 @@
 #include "clang/Analysis/CFGStmtMap.h"
 #include "clang/Analysis/Support/BumpVector.h"
 #include "llvm/Support/SaveAndRestore.h"
-#include "llvm/ADT/SmallSet.h"
+#include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/Support/ErrorHandling.h"
 
 using namespace clang;
@@ -335,8 +335,8 @@
 class FindBlockDeclRefExprsVals : public StmtVisitor<FindBlockDeclRefExprsVals>{
   BumpVector<const VarDecl*> &BEVals;
   BumpVectorContext &BC;
-  llvm::DenseMap<const VarDecl*, unsigned> Visited;
-  llvm::SmallSet<const DeclContext*, 4> IgnoredContexts;
+  llvm::SmallPtrSet<const VarDecl*, 4> Visited;
+  llvm::SmallPtrSet<const DeclContext*, 4> IgnoredContexts;
 public:
   FindBlockDeclRefExprsVals(BumpVector<const VarDecl*> &bevals,
                             BumpVectorContext &bc)
@@ -355,21 +355,15 @@
 
   void VisitDeclRefExpr(DeclRefExpr *DR) {
     // Non-local variables are also directly modified.
-    if (const VarDecl *VD = dyn_cast<VarDecl>(DR->getDecl()))
+    if (const VarDecl *VD = dyn_cast<VarDecl>(DR->getDecl())) {
       if (!VD->hasLocalStorage()) {
-        unsigned &flag = Visited[VD];
-        if (!flag) {
-          flag = 1;
+        if (Visited.insert(VD))
           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);
-        }
+        if (Visited.insert(VD) && IsTrackedDecl(VD))
+          BEVals.push_back(VD, BC);
       }
+    }
   }
 
   void VisitBlockExpr(BlockExpr *BR) {





More information about the cfe-commits mailing list