[cfe-commits] r74524 - in /cfe/trunk: lib/Analysis/RegionStore.cpp test/Analysis/xfail_regionstore_wine_crash.c

Zhongxing Xu xuzhongxing at gmail.com
Tue Jun 30 05:33:22 PDT 2009


Author: zhongxingxu
Date: Tue Jun 30 07:32:59 2009
New Revision: 74524

URL: http://llvm.org/viewvc/llvm-project?rev=74524&view=rev
Log:
When retrieving element region, if its super region has binding, return
unknown for it.

Mark the super region of a live region as live, if the live region is pointed
to by a live pointer variable.

These fixes xfail_regionstore_wine_crash.c.

Modified:
    cfe/trunk/lib/Analysis/RegionStore.cpp
    cfe/trunk/test/Analysis/xfail_regionstore_wine_crash.c

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

==============================================================================
--- cfe/trunk/lib/Analysis/RegionStore.cpp (original)
+++ cfe/trunk/lib/Analysis/RegionStore.cpp Tue Jun 30 07:32:59 2009
@@ -938,6 +938,8 @@
   }
 
   const MemRegion* SuperR = R->getSuperRegion();
+
+  // Check if the super region has a default value.
   const SVal* D = state->get<RegionDefaultValue>(SuperR);
 
   if (D) {
@@ -947,6 +949,13 @@
       return *D;
   }
 
+  // Check if the super region has a binding.
+  D = B.lookup(SuperR);
+  if (D) {
+    // We do not extract the bit value from super region for now.
+    return ValMgr.makeUnknownVal();
+  }
+
   if (R->hasHeapOrStackStorage())
     return UndefinedVal();
 
@@ -1358,8 +1367,9 @@
     IntermediateRoots.pop_back();
     
     if (const VarRegion* VR = dyn_cast<VarRegion>(R)) {
-      if (SymReaper.isLive(Loc, VR->getDecl()))
+      if (SymReaper.isLive(Loc, VR->getDecl())) {
         RegionRoots.push_back(VR); // This is a live "root".
+      }
     } 
     else if (const SymbolicRegion* SR = dyn_cast<SymbolicRegion>(R)) {
       if (SymReaper.isLive(SR->getSymbol()))
@@ -1410,9 +1420,18 @@
       SVal X = *Xptr;
       UpdateLiveSymbols(X, SymReaper); // Update the set of live symbols.
       
-      // If X is a region, then add it the RegionRoots.
-      if (loc::MemRegionVal* RegionX = dyn_cast<loc::MemRegionVal>(&X))
-        RegionRoots.push_back(RegionX->getRegion());
+      // If X is a region, then add it to the RegionRoots.
+      if (const MemRegion *RX = X.getAsRegion()) {
+        RegionRoots.push_back(RX);
+
+        // Mark the super region of the RX as live.
+        // e.g.: int x; char *y = (char*) &x; if (*y) ... 
+        // 'y' => element region. 'x' is its super region.
+        // We only add one level super region for now.
+        if (const SubRegion *SR = dyn_cast<SubRegion>(RX)) {
+          RegionRoots.push_back(SR->getSuperRegion());
+        }
+      }
     }
     
     // Get the subregions of R.  These are RegionRoots as well since they
@@ -1423,6 +1442,7 @@
     
     for (SubRegionsTy::iterator I=SR.begin(), E=SR.end(); I!=E; ++I)
       RegionRoots.push_back(*I);
+
   }
   
   // We have now scanned the store, marking reachable regions and symbols
@@ -1430,7 +1450,6 @@
   // as well as update DSymbols with the set symbols that are now dead.  
   for (RegionBindingsTy::iterator I = B.begin(), E = B.end(); I != E; ++I) {
     const MemRegion* R = I.getKey();
-    
     // If this region live?  Is so, none of its symbols are dead.
     if (Marked.count(R))
       continue;

Modified: cfe/trunk/test/Analysis/xfail_regionstore_wine_crash.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/xfail_regionstore_wine_crash.c?rev=74524&r1=74523&r2=74524&view=diff

==============================================================================
--- cfe/trunk/test/Analysis/xfail_regionstore_wine_crash.c (original)
+++ cfe/trunk/test/Analysis/xfail_regionstore_wine_crash.c Tue Jun 30 07:32:59 2009
@@ -1,5 +1,4 @@
-// RUN: clang-cc -checker-cfref -analyze -analyzer-store=region -verify %s
-// XFAIL
+// RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -verify %s
 
 // When this test passes we should put it in the misc-ps.m test file.
 // This test fails now because RegionStoreManager::Retrieve() does correctly 





More information about the cfe-commits mailing list