[clang] [analyzer] use `invalidateRegions()` in `VisitGCCAsmStmt` (PR #109838)

Balazs Benics via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 30 06:15:45 PDT 2024


================
@@ -10,8 +10,10 @@ void testRValueOutput() {
   int &ref = global;
   ref = 1;
   __asm__("" : "=r"(((int)(global))));  // don't crash on rvalue output operand
-  clang_analyzer_eval(global == 1); // expected-warning{{UNKNOWN}}
-  clang_analyzer_eval(ref == 1);    // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(global == 1); // expected-warning{{FALSE}}
+                                    // expected-warning at -1{{TRUE}}
+  clang_analyzer_eval(ref == 1);    // expected-warning{{FALSE}}
+                                    // expected-warning at -1{{TRUE}}
----------------
steakhal wrote:

Here global and ref always refers to the same underlying storage, thus we don't need to test both.
```suggestion
  int origVal = global;
  __asm__("" : "=r"(((int)(global))));  // don't crash on rvalue output operand
  int newVal = global; // Value "after" the invalidation.
  clang_analyzer_eval(origVal == newVal); // expected-warning{{TRUE}} expected-warning{{FALSE}}
```

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


More information about the cfe-commits mailing list