[cfe-commits] r67245 - in /cfe/trunk: lib/Analysis/BasicStore.cpp lib/Analysis/SVals.cpp test/Analysis/misc-ps.m

Ted Kremenek kremenek at apple.com
Wed Mar 18 15:10:29 PDT 2009


Author: kremenek
Date: Wed Mar 18 17:10:22 2009
New Revision: 67245

URL: http://llvm.org/viewvc/llvm-project?rev=67245&view=rev
Log:
Fix crash reported in <rdar://problem/6695527>. We now have
SVal::GetRValueSymbolVal do the checking if we can symbolicate a type instead of
having BasicStoreManager do it (which wasn't always doing the check
consistently). Having this check in SVal::GetRValueSymbolVal keeps the check in
one centralized place.

Modified:
    cfe/trunk/lib/Analysis/BasicStore.cpp
    cfe/trunk/lib/Analysis/SVals.cpp
    cfe/trunk/test/Analysis/misc-ps.m

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

==============================================================================
--- cfe/trunk/lib/Analysis/BasicStore.cpp (original)
+++ cfe/trunk/lib/Analysis/BasicStore.cpp Wed Mar 18 17:10:22 2009
@@ -526,19 +526,15 @@
       if (VD->getStorageClass() == VarDecl::Static)
         continue;
 
-      // Only handle pointers and integers for now.
-      QualType T = VD->getType();
-      if (Loc::IsLocType(T) || T->isIntegerType()) {
-        // Initialize globals and parameters to symbolic values.
-        // Initialize local variables to undefined.
-        const MemRegion *R = StateMgr.getRegion(VD);
-        SVal X = (VD->hasGlobalStorage() || isa<ParmVarDecl>(VD) ||
-                  isa<ImplicitParamDecl>(VD))
-              ? SVal::GetRValueSymbolVal(StateMgr.getSymbolManager(), R)
-              : UndefinedVal();
+      // Initialize globals and parameters to symbolic values.
+      // Initialize local variables to undefined.
+      const MemRegion *R = StateMgr.getRegion(VD);
+      SVal X = (VD->hasGlobalStorage() || isa<ParmVarDecl>(VD) ||
+                isa<ImplicitParamDecl>(VD))
+            ? SVal::GetRValueSymbolVal(StateMgr.getSymbolManager(), R)
+            : UndefinedVal();
 
-        St = BindInternal(St, Loc::MakeVal(R), X);
-      }
+      St = BindInternal(St, Loc::MakeVal(R), X);
     }
   }
   return St;

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

==============================================================================
--- cfe/trunk/lib/Analysis/SVals.cpp (original)
+++ cfe/trunk/lib/Analysis/SVals.cpp Wed Mar 18 17:10:22 2009
@@ -324,11 +324,18 @@
 SVal SVal::GetRValueSymbolVal(SymbolManager& SymMgr, const MemRegion* R) {
   SymbolRef sym = SymMgr.getRegionRValueSymbol(R);
                                 
-  if (const TypedRegion* TR = dyn_cast<TypedRegion>(R))
-    if (Loc::IsLocType(TR->getRValueType(SymMgr.getContext())))
+  if (const TypedRegion* TR = dyn_cast<TypedRegion>(R)) {
+    QualType T = TR->getRValueType(SymMgr.getContext());
+    
+    if (Loc::IsLocType(T))
       return Loc::MakeVal(sym);
   
-  return NonLoc::MakeVal(sym);
+    // Only handle integers for now.
+    if (T->isIntegerType())
+      return NonLoc::MakeVal(sym);
+  }
+
+  return UnknownVal();
 }
 
 nonloc::LocAsInteger nonloc::LocAsInteger::Make(BasicValueFactory& Vals, Loc V,

Modified: cfe/trunk/test/Analysis/misc-ps.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps.m?rev=67245&r1=67244&r2=67245&view=diff

==============================================================================
--- cfe/trunk/test/Analysis/misc-ps.m (original)
+++ cfe/trunk/test/Analysis/misc-ps.m Wed Mar 18 17:10:22 2009
@@ -195,3 +195,9 @@
 // PR 3780 - This tests that StmtIterator isn't broken for VLAs in DeclGroups.
 void pr3780(int sz) { typedef double MAT[sz][sz]; }
 
+// <rdar://problem/6695527> - Test that we don't symbolicate doubles before
+// we are ready to do something with them.
+int rdar6695527(double x) {
+  if (!x) { return 0; }
+  return 1;
+}





More information about the cfe-commits mailing list