[cfe-commits] r126622 - in /cfe/trunk/lib/StaticAnalyzer: Checkers/ExprEngine.cpp Core/FlatStore.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Sun Feb 27 17:27:57 PST 2011


Author: akirtzidis
Date: Sun Feb 27 19:27:57 2011
New Revision: 126622

URL: http://llvm.org/viewvc/llvm-project?rev=126622&view=rev
Log:
[analyzer] ExprEngine should not depend on checkers for not crashing.

Modified:
    cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp
    cfe/trunk/lib/StaticAnalyzer/Core/FlatStore.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp?rev=126622&r1=126621&r2=126622&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp Sun Feb 27 19:27:57 2011
@@ -1322,7 +1322,7 @@
   const GRState* PrevState = builder.getState();
   SVal X = PrevState->getSVal(Condition);
 
-  if (X.isUnknown()) {
+  if (X.isUnknownOrUndef()) {
     // Give it a chance to recover from unknown.
     if (const Expr *Ex = dyn_cast<Expr>(Condition)) {
       if (Ex->getType()->isIntegerType()) {
@@ -1340,7 +1340,7 @@
       }
     }
     // If the condition is still unknown, give up.
-    if (X.isUnknown()) {
+    if (X.isUnknownOrUndef()) {
       builder.generateNode(MarkBranch(PrevState, Term, true), true);
       builder.generateNode(MarkBranch(PrevState, Term, false), false);
       return;
@@ -1858,7 +1858,8 @@
   if (Tmp.empty())
     return;
 
-  assert(!location.isUndef());
+  if (location.isUndef())
+    return;
 
   SaveAndRestore<ProgramPoint::Kind> OldSPointKind(Builder->PointKind,
                                                    ProgramPoint::PostStoreKind);
@@ -1918,7 +1919,8 @@
   if (Tmp.empty())
     return;
 
-  assert(!location.isUndef());
+  if (location.isUndef())
+    return;
 
   SaveAndRestore<ProgramPoint::Kind> OldSPointKind(Builder->PointKind);
 

Modified: cfe/trunk/lib/StaticAnalyzer/Core/FlatStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/FlatStore.cpp?rev=126622&r1=126621&r2=126622&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/FlatStore.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/FlatStore.cpp Sun Feb 27 19:27:57 2011
@@ -90,6 +90,19 @@
 }
 
 SVal FlatStoreManager::Retrieve(Store store, Loc L, QualType T) {
+  // For access to concrete addresses, return UnknownVal.  Checks
+  // for null dereferences (and similar errors) are done by checkers, not
+  // the Store.
+  // FIXME: We can consider lazily symbolicating such memory, but we really
+  // should defer this when we can reason easily about symbolicating arrays
+  // of bytes.
+  if (isa<loc::ConcreteInt>(L)) {
+    return UnknownVal();
+  }
+  if (!isa<loc::MemRegionVal>(L)) {
+    return UnknownVal();
+  }
+
   const MemRegion *R = cast<loc::MemRegionVal>(L).getRegion();
   RegionInterval RI = RegionToInterval(R);
   // FIXME: FlatStore should handle regions with unknown intervals.





More information about the cfe-commits mailing list