[cfe-commits] r67260 - in /cfe/trunk: lib/Analysis/GRExprEngine.cpp test/Analysis/misc-ps-eager-assume.m

Ted Kremenek kremenek at apple.com
Wed Mar 18 16:49:27 PDT 2009


Author: kremenek
Date: Wed Mar 18 18:49:26 2009
New Revision: 67260

URL: http://llvm.org/viewvc/llvm-project?rev=67260&view=rev
Log:
Fix PR 3836 by eagerly assuming symbolic constraints returned by unary '!'.

Modified:
    cfe/trunk/lib/Analysis/GRExprEngine.cpp
    cfe/trunk/test/Analysis/misc-ps-eager-assume.m

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

==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Wed Mar 18 18:49:26 2009
@@ -394,9 +394,17 @@
       VisitLValue(cast<StringLiteral>(S), Pred, Dst);
       break;
       
-    case Stmt::UnaryOperatorClass:
-      VisitUnaryOperator(cast<UnaryOperator>(S), Pred, Dst, false);
+    case Stmt::UnaryOperatorClass: {
+      UnaryOperator *U = cast<UnaryOperator>(S);
+      if (EagerlyAssume && (U->getOpcode() == UnaryOperator::LNot)) {
+        NodeSet Tmp;
+        VisitUnaryOperator(U, Pred, Tmp, false);
+        EvalEagerlyAssume(Dst, Tmp, U);
+      }
+      else
+        VisitUnaryOperator(U, Pred, Dst, false);
       break;
+    }
   }
 }
 

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

==============================================================================
--- cfe/trunk/test/Analysis/misc-ps-eager-assume.m (original)
+++ cfe/trunk/test/Analysis/misc-ps-eager-assume.m Wed Mar 18 18:49:26 2009
@@ -61,3 +61,19 @@
 
   [pool drain];
 }
+
+// From PR 3836 (http://llvm.org/bugs/show_bug.cgi?id=3836)
+//
+// In this test case, the double '!' works fine with our symbolic constraints,
+// but we don't support comparing SymConstraint != SymConstraint.  By eagerly
+// assuming the truth of !!a or !!b, we can compare these values directly.
+//
+void pr3836(int *a, int *b) {
+  if (!!a != !!b) /* one of them is NULL */
+    return;
+  if (!a && !b) /* both are NULL */
+    return;
+      
+  *a = 1; // no-warning
+  *b = 1; // no-warning
+}





More information about the cfe-commits mailing list