[clang][dataflow] Strengthen flow condition assertions.
authorMartin Braenne <mboehme@google.com>
Tue, 18 Jul 2023 11:28:09 +0000 (11:28 +0000)
committerMartin Braenne <mboehme@google.com>
Tue, 18 Jul 2023 13:41:43 +0000 (13:41 +0000)
Instead of asserting merely that the flow condition doesn't imply that a variable is true, make the stronger assertion that the flow condition implies that the variable is false.

Reviewed By: ymandel, xazax.hun

Differential Revision: https://reviews.llvm.org/D155067

clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

index e280045..291f832 100644 (file)
@@ -3619,7 +3619,8 @@ TEST(TransferTest, BooleanEquality) {
         EXPECT_TRUE(EnvThen.flowConditionImplies(BarValThen));
 
         auto &BarValElse = getFormula(*BarDecl, EnvElse);
-        EXPECT_FALSE(EnvElse.flowConditionImplies(BarValElse));
+        EXPECT_TRUE(
+            EnvElse.flowConditionImplies(EnvElse.arena().makeNot(BarValElse)));
       });
 }
 
@@ -3650,7 +3651,8 @@ TEST(TransferTest, BooleanInequality) {
         ASSERT_THAT(BarDecl, NotNull());
 
         auto &BarValThen = getFormula(*BarDecl, EnvThen);
-        EXPECT_FALSE(EnvThen.flowConditionImplies(BarValThen));
+        EXPECT_TRUE(
+            EnvThen.flowConditionImplies(EnvThen.arena().makeNot(BarValThen)));
 
         auto &BarValElse = getFormula(*BarDecl, EnvElse);
         EXPECT_TRUE(EnvElse.flowConditionImplies(BarValElse));