[cfe-commits] r57730 - /cfe/trunk/lib/Analysis/BasicConstraintManager.cpp

Ted Kremenek kremenek at apple.com
Fri Oct 17 14:22:20 PDT 2008


Author: kremenek
Date: Fri Oct 17 16:22:20 2008
New Revision: 57730

URL: http://llvm.org/viewvc/llvm-project?rev=57730&view=rev
Log:
Enhance "Assumption" logic in BasicConstraintManager when reasoning about regions and symbolic regions.  When assuming whether or not a location is non-null, walk up the region hierarchy until we hit a symbolic region (and test it for null).  This may not be the end all solution, as the notion of what a "symbolic region" is really belongs in the specific subclass of StoreManager.

Modified:
    cfe/trunk/lib/Analysis/BasicConstraintManager.cpp

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

==============================================================================
--- cfe/trunk/lib/Analysis/BasicConstraintManager.cpp (original)
+++ cfe/trunk/lib/Analysis/BasicConstraintManager.cpp Fri Oct 17 16:22:20 2008
@@ -129,7 +129,26 @@
       return AssumeSymEQ(St, cast<loc::SymbolVal>(Cond).getSymbol(),
                          BasicVals.getZeroWithPtrWidth(), isFeasible);
 
-  case loc::MemRegionKind:
+  case loc::MemRegionKind: {
+    // FIXME: Should this go into the storemanager?
+    
+    const MemRegion* R = cast<loc::MemRegionVal>(Cond).getRegion();
+    
+    while (R) {
+      if (const SubRegion* SubR = dyn_cast<SubRegion>(R)) {
+        R = SubR->getSuperRegion();
+        continue;
+      }
+      else if (const SymbolicRegion* SymR = dyn_cast<SymbolicRegion>(R))
+        return AssumeAux(St, loc::SymbolVal(SymR->getSymbol()), Assumption,
+                                            isFeasible);
+      
+      break;
+    }
+    
+    // FALL-THROUGH.
+  }
+      
   case loc::FuncValKind:
   case loc::GotoLabelKind:
   case loc::StringLiteralValKind:





More information about the cfe-commits mailing list