]> granicus.if.org Git - clang/commitdiff
Remove duplicated methods.
authorZhongxing Xu <xuzhongxing@gmail.com>
Tue, 23 Jun 2009 02:51:21 +0000 (02:51 +0000)
committerZhongxing Xu <xuzhongxing@gmail.com>
Tue, 23 Jun 2009 02:51:21 +0000 (02:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73940 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/PathSensitive/MemRegion.h
lib/Analysis/MemRegion.cpp
lib/Analysis/RegionStore.cpp

index 605fa27cc15550d94db646cd986ba04349198a24..c853a5fa86ff36e638f6551a7583ae0e29048747 100644 (file)
@@ -608,19 +608,6 @@ public:
 
   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 @@ public:
   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);
 };
index a923ac29eb338297cb413bb5431aac5190d07c60..619d1617d0006251090fdd783377c1314ddd2fe2 100644 (file)
@@ -234,20 +234,6 @@ MemSpaceRegion* MemRegionManager::getCodeRegion() {
   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 @@ AllocaRegion* MemRegionManager::getAllocaRegion(const Expr* E, unsigned cnt) {
 }
 
 bool MemRegionManager::hasStackStorage(const MemRegion* R) {
-
   // Only subregions can have stack storage.
   const SubRegion* SR = dyn_cast<SubRegion>(R);
 
@@ -368,10 +353,29 @@ bool MemRegionManager::hasStackStorage(const MemRegion* R) {
     
     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.
index 4b598a384f300cb619281ba44882b81af601a349..564ffec6cf90332a932bb1d9a999f7302d980ff9 100644 (file)
@@ -939,7 +939,7 @@ SVal RegionStoreManager::Retrieve(const GRState *state, Loc L, QualType T) {
     }
   }  
 
-  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