[cfe-commits] r59151 - in /cfe/trunk: include/clang/Analysis/PathSensitive/Store.h lib/Analysis/BasicStore.cpp lib/Analysis/RegionStore.cpp

Ted Kremenek kremenek at apple.com
Wed Nov 12 11:18:45 PST 2008


Author: kremenek
Date: Wed Nov 12 13:18:35 2008
New Revision: 59151

URL: http://llvm.org/viewvc/llvm-project?rev=59151&view=rev
Log:
StoreManager::BindDecl now takes an SVal* for the initialization value instead of an Expr* (which can be null).  Lazy symbolication of conjured symbols is now the sole responsibility of GRExprEngine.

Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/Store.h
    cfe/trunk/lib/Analysis/BasicStore.cpp
    cfe/trunk/lib/Analysis/RegionStore.cpp

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/Store.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/Store.h?rev=59151&r1=59150&r2=59151&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/Store.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/Store.h Wed Nov 12 13:18:35 2008
@@ -91,10 +91,8 @@
                      llvm::SmallVectorImpl<const MemRegion*>& RegionRoots,
                      LiveSymbolsTy& LSymbols, DeadSymbolsTy& DSymbols) = 0;
 
-  virtual Store BindDecl(Store store,
-                         const VarDecl* VD, Expr* Ex, 
-                         SVal InitVal = UndefinedVal(), 
-                         unsigned Count = 0) = 0;
+  virtual Store BindDecl(Store store, const VarDecl* VD, SVal* InitVal,
+                         unsigned Count) = 0;
 
   virtual void print(Store store, std::ostream& Out,
                      const char* nl, const char *sep) = 0;

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

==============================================================================
--- cfe/trunk/lib/Analysis/BasicStore.cpp (original)
+++ cfe/trunk/lib/Analysis/BasicStore.cpp Wed Nov 12 13:18:35 2008
@@ -76,8 +76,7 @@
 
   void iterBindings(Store store, BindingsHandler& f);
 
-  Store BindDecl(Store store, const VarDecl* VD, Expr* Ex,
-                 SVal InitVal = UndefinedVal(), unsigned Count = 0);
+  Store BindDecl(Store store, const VarDecl* VD, SVal* InitVal, unsigned Count);
 
   static inline VarBindingsTy GetVarBindings(Store store) {
     return VarBindingsTy(static_cast<const VarBindingsTy::TreeTy*>(store));
@@ -358,11 +357,11 @@
   return St;
 }
 
-Store BasicStoreManager::BindDecl(Store store, const VarDecl* VD, Expr* Ex,
-                                  SVal InitVal, unsigned Count) {
+Store BasicStoreManager::BindDecl(Store store, const VarDecl* VD,
+                                  SVal* InitVal, unsigned Count) {
+                 
   BasicValueFactory& BasicVals = StateMgr.getBasicVals();
-  SymbolManager& SymMgr = StateMgr.getSymbolManager();
-  
+                 
   // BasicStore does not model arrays and structs.
   if (VD->getType()->isArrayType() || VD->getType()->isStructureType())
     return store;
@@ -386,7 +385,7 @@
       //   —if it has pointer type, it is initialized to a null pointer; 
       //   —if it has arithmetic type, it is initialized to (positive or 
       //     unsigned) zero;
-      if (!Ex) {
+      if (!InitVal) {
         QualType T = VD->getType();
         if (Loc::IsLocType(T))
           store = Bind(store, getLoc(VD),
@@ -398,24 +397,14 @@
           // assert(0 && "ignore other types of variables");
         }
       } else {
-        store = Bind(store, getLoc(VD), InitVal);
+        store = Bind(store, getLoc(VD), *InitVal);
       }
     }
   } else {
     // Process local scalar variables.
     QualType T = VD->getType();
     if (Loc::IsLocType(T) || T->isIntegerType()) {
-      SVal V = Ex ? InitVal : UndefinedVal();
-
-      if (Ex && InitVal.isUnknown()) {
-        // EXPERIMENTAL: "Conjured" symbols.
-        SymbolID Sym = SymMgr.getConjuredSymbol(Ex, Count);
-
-        V = Loc::IsLocType(Ex->getType())
-          ? cast<SVal>(loc::SymbolVal(Sym))
-          : cast<SVal>(nonloc::SymbolVal(Sym));
-      }
-
+      SVal V = InitVal ? *InitVal : UndefinedVal();
       store = Bind(store, getLoc(VD), V);
     }
   }

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

==============================================================================
--- cfe/trunk/lib/Analysis/RegionStore.cpp (original)
+++ cfe/trunk/lib/Analysis/RegionStore.cpp Wed Nov 12 13:18:35 2008
@@ -85,8 +85,7 @@
                            llvm::SmallVectorImpl<const MemRegion*>& RegionRoots,
                            LiveSymbolsTy& LSymbols, DeadSymbolsTy& DSymbols);
 
-  Store BindDecl(Store store, const VarDecl* VD, Expr* Ex, SVal InitVal, 
-                 unsigned Count);
+  Store BindDecl(Store store, const VarDecl* VD, SVal* InitVal, unsigned Count);
 
   static inline RegionBindingsTy GetRegionBindings(Store store) {
    return RegionBindingsTy(static_cast<const RegionBindingsTy::TreeTy*>(store));
@@ -356,10 +355,10 @@
   return St;
 }
 
-Store RegionStoreManager::BindDecl(Store store, const VarDecl* VD, Expr* Ex,
-                                   SVal InitVal, unsigned Count) {
+Store RegionStoreManager::BindDecl(Store store, const VarDecl* VD,
+                                   SVal* InitVal, unsigned Count) {
+  
   BasicValueFactory& BasicVals = StateMgr.getBasicVals();
-  SymbolManager& SymMgr = StateMgr.getSymbolManager();
 
   if (VD->hasGlobalStorage()) {
     // Static global variables should not be visited here.
@@ -367,7 +366,7 @@
              VD->isFileVarDecl()));
     // Process static variables.
     if (VD->getStorageClass() == VarDecl::Static) {
-      if (!Ex) {
+      if (!InitVal) {
         // Only handle pointer and integer static variables.
 
         QualType T = VD->getType();
@@ -382,7 +381,7 @@
 
         // Other types of static local variables are not handled yet.
       } else {
-        store = Bind(store, getVarLoc(VD), InitVal);
+        store = Bind(store, getVarLoc(VD), *InitVal);
       }
     }
   } else {
@@ -393,27 +392,20 @@
     VarRegion* VR = MRMgr.getVarRegion(VD);
 
     if (Loc::IsLocType(T) || T->isIntegerType()) {
-      SVal V = Ex ? InitVal : UndefinedVal();
-      if (Ex && InitVal.isUnknown()) {
-        // "Conjured" symbols.
-        SymbolID Sym = SymMgr.getConjuredSymbol(Ex, Count);
-        V = Loc::IsLocType(Ex->getType())
-          ? cast<SVal>(loc::SymbolVal(Sym))
-          : cast<SVal>(nonloc::SymbolVal(Sym));
-      }
+      SVal V = InitVal ? *InitVal : UndefinedVal();
       store = Bind(store, loc::MemRegionVal(VR), V);
-
-    } else if (T->isArrayType()) {
-      if (!Ex)
+    }
+    else if (T->isArrayType()) {
+      if (!InitVal)
         store = BindArrayToVal(store, VR, UndefinedVal());
       else
-        store = InitializeArray(store, VR, InitVal);
-
-    } else if (T->isStructureType()) {
-      if (!Ex)
+        store = InitializeArray(store, VR, *InitVal);
+    }
+    else if (T->isStructureType()) {
+      if (!InitVal)
         store = BindStructToVal(store, VR, UndefinedVal());
       else
-        store = InitializeStruct(store, VR, InitVal);
+        store = InitializeStruct(store, VR, *InitVal);
     }
 
     // Other types of local variables are not handled yet.





More information about the cfe-commits mailing list