[clang] [analyzer] tryRearrange: don't "cancel out" symbol in BO_Add (PR #237160)

DonĂ¡t Nagy via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 2 00:19:50 PST 2026


================
@@ -1026,3 +1026,12 @@ void unsigned_concrete_int_no_crash(void) {
   clang_analyzer_express(y); // expected-warning {{$y}}
   clang_analyzer_express(x == y); // expected-warning {{$x + 1U == $y + 1U}}
 }
+
+void add_shifted_same_symbol(void) {
+  int x = f();
+  clang_analyzer_denote(x, "$x");
+  clang_analyzer_express((x + 1) + (x + 2)); // expected-warning{{$x + $x + 3}}
+  clang_analyzer_express((x + 1) + x); // expected-warning{{$x + $x + 1}}
----------------
NagyDonat wrote:

Yes, in this particular example dump/regex would also work, because we only have one conjured symbol. However, practically all other tests in this file _need_ express to distinguish several conjured symbols, so I prefer express for the sake of consistency.

> Maybe later we should improve it to print parentheses, but it would break the tests that rely on it (roughly 500 calls in 8 test files).

I'll probably either implement this or ask an intern to implement this in the foreseeable future, and then express will become a stable and elegant tool.

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


More information about the cfe-commits mailing list