]> granicus.if.org Git - clang/commitdiff
Move 'hasStackStorage()' and 'hasHeapStorage()' from MemRegionManager to MemRegion.
authorTed Kremenek <kremenek@apple.com>
Tue, 23 Jun 2009 18:05:21 +0000 (18:05 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 23 Jun 2009 18:05:21 +0000 (18:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73973 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/PathSensitive/GRState.h
include/clang/Analysis/PathSensitive/MemRegion.h
lib/Analysis/CFRefCount.cpp
lib/Analysis/GRExprEngine.cpp
lib/Analysis/MemRegion.cpp
lib/Analysis/RegionStore.cpp

index 2954bd4733fa4b2a099b2c0395a27a67593f820e..98f1242ad81ec661b3c00a3d34152c1c1d8a2dc9 100644 (file)
@@ -574,11 +574,6 @@ public:
   // Methods that manipulate the GDM.
   const GRState* addGDM(const GRState* St, void* Key, void* Data);
   
-  // Methods that query or create regions.
-  bool hasStackStorage(const MemRegion* R) {
-    return getRegionManager().hasStackStorage(R);
-  }
-  
   // Methods that query & manipulate the Store.
 
   void iterBindings(const GRState* state, StoreManager::BindingsHandler& F) {
index ac158dc88f5c461cd9aca57085b0bbbfeaa80ca4..b531375be2bcc25b87e6a1a3b02cee38515b7f17 100644 (file)
@@ -68,6 +68,10 @@ public:
   virtual MemRegionManager* getMemRegionManager() const = 0;
 
   std::string getString() const;
+    
+  bool hasStackStorage() const;
+  
+  bool hasHeapStorage() const;
 
   virtual void print(llvm::raw_ostream& os) const;  
   
@@ -668,10 +672,6 @@ public:
     assert(R);
     return R == globals; 
   }
-
-  bool hasStackStorage(const MemRegion* R);
-
-  bool hasHeapStorage(const MemRegion* R);
   
 private:
   MemSpaceRegion* LazyAllocate(MemSpaceRegion*& region);
index 1ccd0924f378350ca354c0c05c6661e310d83fa4..46333a74f27d77f6b391881f289f8dc54dccd4c0 100644 (file)
@@ -3141,7 +3141,7 @@ void CFRefCount::EvalBind(GRStmtNodeBuilderRef& B, SVal location, SVal val) {
     escapes = true;
   else {
     const MemRegion* R = cast<loc::MemRegionVal>(location).getRegion();
-    escapes = !B.getStateManager().hasStackStorage(R);
+    escapes = !R->hasStackStorage();
     
     if (!escapes) {
       // To test (3), generate a new state with the binding removed.  If it is
index d5f0e406bb7c3519ebd896525e8117deb6bc07ea..7d56d108debe215630fee1a5e0f322e3ee66a205 100644 (file)
@@ -2764,7 +2764,7 @@ void GRExprEngine::VisitReturnStmt(ReturnStmt* S, NodeTy* Pred, NodeSet& Dst) {
       // Determine if the value is on the stack.
       const MemRegion* R = cast<loc::MemRegionVal>(&X)->getRegion();
       
-      if (R && getStateManager().hasStackStorage(R)) {
+      if (R && R->hasStackStorage()) {
         // Create a special node representing the error.
         if (NodeTy* N = Builder->generateNode(S, GetState(*I), *I)) {
           N->markAsSink();
index 9bd93cd6eb9cd31e555602003d79e205c0c716dd..f018c83b910c57096fd463c1b23496d06f96e984 100644 (file)
@@ -313,17 +313,17 @@ AllocaRegion* MemRegionManager::getAllocaRegion(const Expr* E, unsigned cnt) {
   return getRegion<AllocaRegion>(E, cnt);
 }
 
-bool MemRegionManager::hasStackStorage(const MemRegion* R) {
+bool MemRegion::hasStackStorage() const {
   // Only subregions can have stack storage.
-  const SubRegion* SR = dyn_cast<SubRegion>(R);
+  const SubRegion* SR = dyn_cast<SubRegion>(this);
 
   if (!SR)
     return false;
 
-  MemSpaceRegion* S = getStackRegion();
+  MemSpaceRegion* S = getMemRegionManager()->getStackRegion();
   
   while (SR) {
-    R = SR->getSuperRegion();
+    const MemRegion *R = SR->getSuperRegion();
     if (R == S)
       return true;
     
@@ -333,17 +333,17 @@ bool MemRegionManager::hasStackStorage(const MemRegion* R) {
   return false;
 }
 
-bool MemRegionManager::hasHeapStorage(const MemRegion* R) {
+bool MemRegion::hasHeapStorage() const {
   // Only subregions can have stack storage.
-  const SubRegion* SR = dyn_cast<SubRegion>(R);
+  const SubRegion* SR = dyn_cast<SubRegion>(this);
 
   if (!SR)
     return false;
 
-  MemSpaceRegion* H = getHeapRegion();
+  MemSpaceRegion* H = getMemRegionManager()->getHeapRegion();
 
   while (SR) {
-    R = SR->getSuperRegion();
+    const MemRegion *R = SR->getSuperRegion();
     if (R == H)
       return true;
 
index f76807beb29eaa2c28603dc46d5cd06701e76e9a..17e332387f7ccd04a3a85d06b90c08a522e9f11a 100644 (file)
@@ -939,7 +939,7 @@ SVal RegionStoreManager::Retrieve(const GRState *state, Loc L, QualType T) {
     }
   }  
 
-  if (MRMgr.hasStackStorage(R) || MRMgr.hasHeapStorage(R)) {
+  if (R->hasStackStorage() || R->hasHeapStorage()) {
     // 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