[clang] [analyzer] Improve solver (PR #112583)

Balazs Benics via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 18 04:49:44 PDT 2024


================
@@ -50,31 +50,10 @@ void test2() {
   b = d;
   a -= d;
 
-  if (a != 0)
-    return;
-
-  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
 
-  /* The BASELINE passes these checks ('wrning' is used to avoid lit to match)
-  // The parent state is already infeasible, look at this contradiction:
-  clang_analyzer_eval(b > 0);  // expected-wrning{{FALSE}}
-  clang_analyzer_eval(b <= 0); // expected-wrning{{FALSE}}
-  // Crashes with expensive checks.
-  if (b > 0) {
-    clang_analyzer_warnIfReached(); // no-warning, OK
+  if (a != 0)
     return;
-  }
-  // Should not be reachable.
-  clang_analyzer_warnIfReached(); // expected-wrning{{REACHABLE}}
-  */
 
-  // The parent state is already infeasible, but we realize that only if b is
-  // constrained.
-  clang_analyzer_eval(b > 0);  // expected-warning{{UNKNOWN}}
-  clang_analyzer_eval(b <= 0); // expected-warning{{UNKNOWN}}
-  if (b > 0) {
-    clang_analyzer_warnIfReached(); // no-warning
-    return;
-  }
-  clang_analyzer_warnIfReached(); // no-warning
+  clang_analyzer_warnIfReached(); // no-warning: Even the parent state is unreachable.
----------------
steakhal wrote:

Fixed.

https://github.com/llvm/llvm-project/pull/112583


More information about the cfe-commits mailing list