[cfe-commits] r64527 - /cfe/trunk/lib/Analysis/GRExprEngine.cpp

Ted Kremenek kremenek at apple.com
Fri Feb 13 17:54:58 PST 2009


Author: kremenek
Date: Fri Feb 13 19:54:57 2009
New Revision: 64527

URL: http://llvm.org/viewvc/llvm-project?rev=64527&view=rev
Log:
Use GRTransferFuncs::EvalBind when processing variable initializations.

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

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

==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Fri Feb 13 19:54:57 2009
@@ -1794,28 +1794,6 @@
     const GRState* state = GetState(*I);
     unsigned Count = Builder->getCurrentBlockCount();
 
-    // Decls without InitExpr are not initialized explicitly.
-    if (InitEx) {
-      SVal InitVal = GetSVal(state, InitEx);
-      QualType T = VD->getType();
-      
-      // Recover some path-sensitivity if a scalar value evaluated to
-      // UnknownVal.
-      if (InitVal.isUnknown()) {
-        if (Loc::IsLocType(T)) {
-          SymbolRef Sym = SymMgr.getConjuredSymbol(InitEx, Count);        
-          InitVal = loc::SymbolVal(Sym);
-        }
-        else if (T->isIntegerType() && T->isScalarType()) {
-          SymbolRef Sym = SymMgr.getConjuredSymbol(InitEx, Count);        
-          InitVal = nonloc::SymbolVal(Sym);                    
-        }
-      }        
-      
-      state = StateMgr.BindDecl(state, VD, InitVal);
-    } else
-      state = StateMgr.BindDeclWithNoInit(state, VD);
-    
     // Check if 'VD' is a VLA and if so check if has a non-zero size.
     QualType T = getContext().getCanonicalType(VD->getType());
     if (VariableArrayType* VLA = dyn_cast<VariableArrayType>(T)) {
@@ -1831,10 +1809,10 @@
         }
         continue;
       }
-
+      
       bool isFeasibleZero = false;
       const GRState* ZeroSt =  Assume(state, Size, false, isFeasibleZero);
-            
+      
       bool isFeasibleNotZero = false;
       state = Assume(state, Size, true, isFeasibleNotZero);
       
@@ -1849,8 +1827,38 @@
       if (!isFeasibleNotZero)
         continue;      
     }
-
-    MakeNode(Dst, DS, *I, state);
+    
+    // Decls without InitExpr are not initialized explicitly.
+    if (InitEx) {
+      SVal InitVal = GetSVal(state, InitEx);
+      QualType T = VD->getType();
+      
+      // Recover some path-sensitivity if a scalar value evaluated to
+      // UnknownVal.
+      if (InitVal.isUnknown()) {
+        if (Loc::IsLocType(T)) {
+          SymbolRef Sym = SymMgr.getConjuredSymbol(InitEx, Count);        
+          InitVal = loc::SymbolVal(Sym);
+        }
+        else if (T->isIntegerType() && T->isScalarType()) {
+          SymbolRef Sym = SymMgr.getConjuredSymbol(InitEx, Count);        
+          InitVal = nonloc::SymbolVal(Sym);                    
+        }
+      }        
+      
+      state = StateMgr.BindDecl(state, VD, InitVal);
+      
+      // The next thing to do is check if the GRTransferFuncs object wants to
+      // update the state based on the new binding.  If the GRTransferFunc
+      // object doesn't do anything, just auto-propagate the current state.
+      GRStmtNodeBuilderRef BuilderRef(Dst, *Builder, *this, *I, state, DS,true);
+      getTF().EvalBind(BuilderRef, loc::MemRegionVal(StateMgr.getRegion(VD)),
+                       InitVal);      
+    } 
+    else {
+      state = StateMgr.BindDeclWithNoInit(state, VD);
+      MakeNode(Dst, DS, *I, state);
+    }
   }
 }
 





More information about the cfe-commits mailing list