Only provide explicit getCapturedRegion() and getOriginalRegion() from referenced_var...
authorTed Kremenek <kremenek@apple.com>
Thu, 6 Dec 2012 07:17:20 +0000 (07:17 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 6 Dec 2012 07:17:20 +0000 (07:17 +0000)
This is a nice conceptual cleanup.

llvm-svn: 169480

clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
clang/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp
clang/lib/StaticAnalyzer/Core/RegionStore.cpp

index 4a72875..b0a44e2 100644 (file)
@@ -642,22 +642,14 @@ public:
     explicit referenced_vars_iterator(const MemRegion * const *r,
                                       const MemRegion * const *originalR)
       : R(r), OriginalR(originalR) {}
-    
-    operator const MemRegion * const *() const {
-      return R;
-    }
-  
-    const MemRegion *getCapturedRegion() const {
-      return *R;
-    }
-    const MemRegion *getOriginalRegion() const {
-      return *OriginalR;
-    }
 
-    const VarRegion* operator*() const {
+    const VarRegion *getCapturedRegion() const {
       return cast<VarRegion>(*R);
     }
-    
+    const VarRegion *getOriginalRegion() const {
+      return cast<VarRegion>(*OriginalR);
+    }
+
     bool operator==(const referenced_vars_iterator &I) const {
       return I.R == R;
     }
index 4df1525..6d48f02 100644 (file)
@@ -1204,7 +1204,7 @@ void MallocChecker::checkPostStmt(const BlockExpr *BE,
   MemRegionManager &MemMgr = C.getSValBuilder().getRegionManager();
 
   for ( ; I != E; ++I) {
-    const VarRegion *VR = *I;
+    const VarRegion *VR = I.getCapturedRegion();
     if (VR->getSuperRegion() == R) {
       VR = MemMgr.getVarRegion(VR->getDecl(), LC);
     }
index d2335bb..4cf4799 100644 (file)
@@ -2602,7 +2602,7 @@ void RetainCountChecker::checkPostStmt(const BlockExpr *BE,
   MemRegionManager &MemMgr = C.getSValBuilder().getRegionManager();
 
   for ( ; I != E; ++I) {
-    const VarRegion *VR = *I;
+    const VarRegion *VR = I.getCapturedRegion();
     if (VR->getSuperRegion() == R) {
       VR = MemMgr.getVarRegion(VR->getDecl(), LC);
     }
index 865cbad..3f83637 100644 (file)
@@ -68,7 +68,7 @@ UndefCapturedBlockVarChecker::checkPostStmt(const BlockExpr *BE,
   for (; I != E; ++I) {
     // This VarRegion is the region associated with the block; we need
     // the one associated with the encompassing context.
-    const VarRegion *VR = *I;
+    const VarRegion *VR = I.getCapturedRegion();
     const VarDecl *VD = VR->getDecl();
 
     if (VD->getAttr<BlocksAttr>() || !VD->hasLocalStorage())
index 251735b..5ad38a7 100644 (file)
@@ -740,7 +740,7 @@ void invalidateRegionsWorker::VisitBaseRegion(const MemRegion *baseR) {
     for (BlockDataRegion::referenced_vars_iterator
          BI = BR->referenced_vars_begin(), BE = BR->referenced_vars_end() ;
          BI != BE; ++BI) {
-      const VarRegion *VR = *BI;
+      const VarRegion *VR = BI.getCapturedRegion();
       const VarDecl *VD = VR->getDecl();
       if (VD->getAttr<BlocksAttr>() || !VD->hasLocalStorage()) {
         AddToWorkList(VR);