[cfe-commits] r73973 - in /cfe/trunk: 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

Ted Kremenek kremenek at apple.com
Tue Jun 23 11:05:22 PDT 2009


Author: kremenek
Date: Tue Jun 23 13:05:21 2009
New Revision: 73973

URL: http://llvm.org/viewvc/llvm-project?rev=73973&view=rev
Log:
Move 'hasStackStorage()' and 'hasHeapStorage()' from MemRegionManager to MemRegion.

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

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

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h Tue Jun 23 13:05:21 2009
@@ -574,11 +574,6 @@
   // 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) {

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=73973&r1=73972&r2=73973&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h Tue Jun 23 13:05:21 2009
@@ -68,6 +68,10 @@
   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 @@
     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/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFRefCount.cpp?rev=73973&r1=73972&r2=73973&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Tue Jun 23 13:05:21 2009
@@ -3141,7 +3141,7 @@
     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

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

==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Tue Jun 23 13:05:21 2009
@@ -2764,7 +2764,7 @@
       // 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();

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

==============================================================================
--- cfe/trunk/lib/Analysis/MemRegion.cpp (original)
+++ cfe/trunk/lib/Analysis/MemRegion.cpp Tue Jun 23 13:05:21 2009
@@ -313,17 +313,17 @@
   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 @@
   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;
 

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

==============================================================================
--- cfe/trunk/lib/Analysis/RegionStore.cpp (original)
+++ cfe/trunk/lib/Analysis/RegionStore.cpp Tue Jun 23 13:05:21 2009
@@ -939,7 +939,7 @@
     }
   }  
 
-  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





More information about the cfe-commits mailing list