[cfe-commits] r73940 - in /cfe/trunk: include/clang/Analysis/PathSensitive/MemRegion.h lib/Analysis/MemRegion.cpp lib/Analysis/RegionStore.cpp

Zhongxing Xu xuzhongxing at gmail.com
Mon Jun 22 19:51:21 PDT 2009


Author: zhongxingxu
Date: Mon Jun 22 21:51:21 2009
New Revision: 73940

URL: http://llvm.org/viewvc/llvm-project?rev=73940&view=rev
Log:
Remove duplicated methods.

Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h
    cfe/trunk/lib/Analysis/MemRegion.cpp
    cfe/trunk/lib/Analysis/RegionStore.cpp

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h?rev=73940&r1=73939&r2=73940&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h Mon Jun 22 21:51:21 2009
@@ -608,19 +608,6 @@
 
   MemSpaceRegion* getCodeRegion();
 
-  bool isGlobalsRegion(const MemRegion* R) { 
-    assert(R);
-    return R == globals; 
-  }
-
-  /// onStack - check if the region is allocated on the stack.
-  bool onStack(const MemRegion* R);
-
-  /// onHeap - check if the region is allocated on the heap, usually by malloc.
-  bool onHeap(const MemRegion* R);
-  
-  bool hasStackStorage(const MemRegion* R);
-  
   /// getAllocaRegion - Retrieve a region associated with a call to alloca().
   AllocaRegion* getAllocaRegion(const Expr* Ex, unsigned Cnt);
   
@@ -677,6 +664,15 @@
   template <typename RegionTy, typename A1, typename A2>
   RegionTy* getRegion(const A1 a1, const A2 a2);
 
+  bool isGlobalsRegion(const MemRegion* R) { 
+    assert(R);
+    return R == globals; 
+  }
+
+  bool hasStackStorage(const MemRegion* R);
+
+  bool hasHeapStorage(const MemRegion* R);
+  
 private:
   MemSpaceRegion* LazyAllocate(MemSpaceRegion*& region);
 };

Modified: cfe/trunk/lib/Analysis/MemRegion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/MemRegion.cpp?rev=73940&r1=73939&r2=73940&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/MemRegion.cpp (original)
+++ cfe/trunk/lib/Analysis/MemRegion.cpp Mon Jun 22 21:51:21 2009
@@ -234,20 +234,6 @@
   return LazyAllocate(code);
 }
 
-bool MemRegionManager::onStack(const MemRegion* R) {
-  while (const SubRegion* SR = dyn_cast<SubRegion>(R))
-    R = SR->getSuperRegion();
-
-  return (R != 0) && (R == stack);
-}
-
-bool MemRegionManager::onHeap(const MemRegion* R) {
-  while (const SubRegion* SR = dyn_cast<SubRegion>(R))
-    R = SR->getSuperRegion();
-
-  return (R != 0) && (R == heap); 
-}
-
 //===----------------------------------------------------------------------===//
 // Constructing regions.
 //===----------------------------------------------------------------------===//
@@ -352,7 +338,6 @@
 }
 
 bool MemRegionManager::hasStackStorage(const MemRegion* R) {
-
   // Only subregions can have stack storage.
   const SubRegion* SR = dyn_cast<SubRegion>(R);
 
@@ -368,10 +353,29 @@
     
     SR = dyn_cast<SubRegion>(R);    
   }
-
+ 
   return false;
 }
 
+bool MemRegionManager::hasHeapStorage(const MemRegion* R) {
+  // Only subregions can have stack storage.
+  const SubRegion* SR = dyn_cast<SubRegion>(R);
+
+  if (!SR)
+    return false;
+
+  MemSpaceRegion* H = getHeapRegion();
+
+  while (SR) {
+    R = SR->getSuperRegion();
+    if (R == H)
+      return true;
+
+    SR = dyn_cast<SubRegion>(R);
+  }
+
+  return false;
+}
 
 //===----------------------------------------------------------------------===//
 // View handling.

Modified: cfe/trunk/lib/Analysis/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/RegionStore.cpp?rev=73940&r1=73939&r2=73940&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/RegionStore.cpp (original)
+++ cfe/trunk/lib/Analysis/RegionStore.cpp Mon Jun 22 21:51:21 2009
@@ -939,7 +939,7 @@
     }
   }  
 
-  if (MRMgr.onStack(R) || MRMgr.onHeap(R)) {
+  if (MRMgr.hasStackStorage(R) || MRMgr.hasHeapStorage(R)) {
     // All stack variables are considered to have undefined values
     // upon creation.  All heap allocated blocks are considered to
     // have undefined values as well unless they are explicitly bound





More information about the cfe-commits mailing list