[cfe-commits] r106085 - /cfe/trunk/lib/Checker/StreamChecker.cpp

Zhongxing Xu xuzhongxing at gmail.com
Tue Jun 15 22:56:39 PDT 2010


Author: zhongxingxu
Date: Wed Jun 16 00:56:39 2010
New Revision: 106085

URL: http://llvm.org/viewvc/llvm-project?rev=106085&view=rev
Log:
Although arguments can not be undefined when we get here, they can still be
unknown.

Modified:
    cfe/trunk/lib/Checker/StreamChecker.cpp

Modified: cfe/trunk/lib/Checker/StreamChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/StreamChecker.cpp?rev=106085&r1=106084&r2=106085&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/StreamChecker.cpp (original)
+++ cfe/trunk/lib/Checker/StreamChecker.cpp Wed Jun 16 00:56:39 2010
@@ -98,19 +98,21 @@
   const GRState *state = C.getState();
 
   // Assume CallAndMessageChecker has been run.
-  const DefinedSVal &StreamVal=cast<DefinedSVal>(state->getSVal(CE->getArg(3)));
+  SVal StreamVal = state->getSVal(CE->getArg(3));
 
-  ConstraintManager &CM = C.getConstraintManager();
-  const GRState *stateNotNull, *stateNull;
-  llvm::tie(stateNotNull, stateNull) = CM.AssumeDual(state, StreamVal);
+  if (const DefinedSVal *DV = cast<DefinedSVal>(&StreamVal)) {
+    ConstraintManager &CM = C.getConstraintManager();
+    const GRState *stateNotNull, *stateNull;
+    llvm::tie(stateNotNull, stateNull) = CM.AssumeDual(state, *DV);
 
-  if (!stateNotNull && stateNull) {
-    if (ExplodedNode *N = C.GenerateSink(stateNull)) {
-      if (!BT_nullfp)
-        BT_nullfp = new BuiltinBug("NULL stream pointer",
-                                   "Stream pointer might be NULL.");
-      BugReport *R = new BugReport(*BT_nullfp, BT_nullfp->getDescription(), N);
-      C.EmitReport(R);
+    if (!stateNotNull && stateNull) {
+      if (ExplodedNode *N = C.GenerateSink(stateNull)) {
+        if (!BT_nullfp)
+          BT_nullfp = new BuiltinBug("NULL stream pointer",
+                                     "Stream pointer might be NULL.");
+        BugReport *R =new BugReport(*BT_nullfp, BT_nullfp->getDescription(), N);
+        C.EmitReport(R);
+      }
     }
   }
 }





More information about the cfe-commits mailing list