[cfe-commits] r57741 - /cfe/trunk/lib/Analysis/BasicStore.cpp

Ted Kremenek kremenek at apple.com
Fri Oct 17 15:52:41 PDT 2008


Author: kremenek
Date: Fri Oct 17 17:52:40 2008
New Revision: 57741

URL: http://llvm.org/viewvc/llvm-project?rev=57741&view=rev
Log:
Hack: have BasicStore::getLValueElement return the "Base" lvalue.  This restores null dereference checking with array accesses.

BasicStore::RemoveDeadBindings: handle regions besides VarRegions (we now have FieldRegions).

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

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

==============================================================================
--- cfe/trunk/lib/Analysis/BasicStore.cpp (original)
+++ cfe/trunk/lib/Analysis/BasicStore.cpp Fri Oct 17 17:52:40 2008
@@ -129,7 +129,8 @@
 
 SVal BasicStoreManager::getLValueElement(const GRState* St, SVal Base,
                                          SVal Offset) {
-  return UnknownVal();
+  // Total hack: Just return "Base" for now.
+  return Base;
 }
 
 SVal BasicStoreManager::GetSVal(Store St, Loc LV, QualType T) {
@@ -237,25 +238,37 @@
   llvm::SmallPtrSet<const VarRegion*, 10> Marked;
   
   while (!RegionRoots.empty()) {
-    const VarRegion* R = cast<VarRegion>(RegionRoots.back());
+    const MemRegion* MR = RegionRoots.back();
     RegionRoots.pop_back();
     
-    if (Marked.count(R))
-      continue;
-    
-    Marked.insert(R);    
-    // FIXME: Do we need the QualType here, since regions are partially
-    // typed?
-    SVal X = GetSVal(store, loc::MemRegionVal(R), QualType());      
+    while (MR) {
+      if (const SymbolicRegion* SymR = dyn_cast<SymbolicRegion>(MR)) {
+        LSymbols.insert(SymR->getSymbol());
+        break;
+      }
+      else if (const VarRegion* R = dyn_cast<VarRegion>(MR)) {
+        if (Marked.count(R))
+          break;
+        
+        Marked.insert(R);
+        SVal X = GetRegionSVal(store, R);      
     
-    for (symbol_iterator SI=X.symbol_begin(), SE=X.symbol_end(); SI!=SE; ++SI)
-      LSymbols.insert(*SI);
+        // FIXME: We need to handle symbols nested in region definitions.
+        for (symbol_iterator SI=X.symbol_begin(), SE=X.symbol_end(); SI!=SE; ++SI)
+          LSymbols.insert(*SI);
     
-    if (!isa<loc::MemRegionVal>(X))
-      continue;
+        if (!isa<loc::MemRegionVal>(X))
+          break;
     
-    const loc::MemRegionVal& LVD = cast<loc::MemRegionVal>(X);
-    RegionRoots.push_back(cast<VarRegion>(LVD.getRegion()));
+        const loc::MemRegionVal& LVD = cast<loc::MemRegionVal>(X);
+        RegionRoots.push_back(LVD.getRegion());
+        break;
+      }
+      else if (const SubRegion* R = dyn_cast<SubRegion>(MR))
+        MR = R->getSuperRegion();
+      else
+        break;
+    }
   }
   
   // Remove dead variable bindings.  





More information about the cfe-commits mailing list