[cfe-commits] r79952 - in /cfe/trunk: include/clang/Analysis/PathSensitive/ConstraintManager.h include/clang/Analysis/PathSensitive/SVals.h lib/Analysis/GRExprEngineInternalChecks.cpp

Ted Kremenek kremenek at apple.com
Mon Aug 24 15:47:35 PDT 2009


Author: kremenek
Date: Mon Aug 24 17:47:34 2009
New Revision: 79952

URL: http://llvm.org/viewvc/llvm-project?rev=79952&view=rev
Log:
ConstraintManager::AssumeDual now accepts a 'DefinedSVal' instead of 'SVal' for
the condition. This eliminates a source of bugs where the client doesn't
correctly reason about undefined or unknown values. This fixes PR 4759.

Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/ConstraintManager.h
    cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h
    cfe/trunk/lib/Analysis/GRExprEngineInternalChecks.cpp

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

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/ConstraintManager.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/ConstraintManager.h Mon Aug 24 17:47:34 2009
@@ -37,7 +37,7 @@
                                        SVal UpperBound, bool Assumption) = 0;
   
   std::pair<const GRState*, const GRState*> AssumeDual(const GRState *state,
-                                                       SVal Cond) {
+                                                       DefinedSVal Cond) {
     return std::make_pair(Assume(state, Cond, true),
                           Assume(state, Cond, false));    
   }

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

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h Mon Aug 24 17:47:34 2009
@@ -177,7 +177,7 @@
 protected:
   DefinedSVal(const void* d, bool isLoc, unsigned ValKind)
     : SVal(d, isLoc, ValKind) {}
-  
+public:
   // Implement isa<T> support.
   static inline bool classof(const SVal *V) {
     return !V->isUnknownOrUndef();

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

==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngineInternalChecks.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngineInternalChecks.cpp Mon Aug 24 17:47:34 2009
@@ -575,10 +575,15 @@
       if (!Att->isNonNull(idx))
         continue;
       
+      const SVal &V = state->getSVal(*I);
+      const DefinedSVal *DV = dyn_cast<DefinedSVal>(&V);
+      
+      if (!DV)
+        continue;
+      
       ConstraintManager &CM = C.getConstraintManager();
       const GRState *stateNotNull, *stateNull;
-      llvm::tie(stateNotNull, stateNull) = CM.AssumeDual(state,
-                                                         state->getSVal(*I));
+      llvm::tie(stateNotNull, stateNull) = CM.AssumeDual(state, *DV);
       
       if (stateNull && !stateNotNull) {
         // Generate an error node.  Check for a null node in case





More information about the cfe-commits mailing list