summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Analysis/GRExprEngine.cpp12
-rw-r--r--clang/test/Analysis/misc-ps-eager-assume.m16
2 files changed, 26 insertions, 2 deletions
diff --git a/clang/lib/Analysis/GRExprEngine.cpp b/clang/lib/Analysis/GRExprEngine.cpp
index 6d360ed5033..1f47bc7f331 100644
--- a/clang/lib/Analysis/GRExprEngine.cpp
+++ b/clang/lib/Analysis/GRExprEngine.cpp
@@ -394,9 +394,17 @@ void GRExprEngine::Visit(Stmt* S, NodeTy* Pred, NodeSet& Dst) {
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;
+ }
}
}
diff --git a/clang/test/Analysis/misc-ps-eager-assume.m b/clang/test/Analysis/misc-ps-eager-assume.m
index c36ae8f4d63..4dd8f2536c4 100644
--- a/clang/test/Analysis/misc-ps-eager-assume.m
+++ b/clang/test/Analysis/misc-ps-eager-assume.m
@@ -61,3 +61,19 @@ void handle_symbolic_cast_in_condition(void) {
[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
+}
OpenPOWER on IntegriCloud