[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


================
@@ -40,7 +42,19 @@ void testInlineAsmMemcpyUninit(void)
 {
     int a[10], b[10] = {}, c;
     MyMemcpy(&a[1], &b[1], sizeof(b) - sizeof(b[1]));
-    c = a[0]; // expected-warning{{Assigned value is garbage or undefined}}
+    c = a[0]; // FIXME: should be warning about uninitialized value, but invalidateRegions() also
----------------
steakhal wrote:

I suppose it all boils down to what the assembly block does. I don't think there is anything fundamentally preventing us refining what gets invalidated other than actually parsing and understanding the asm block.

Invalidating everything is a good default choice; however, frequently we can do better than that.
IDK how the `MyMemcpy` works in your test, but it could model the invalidation similar to how the StreamChecker goes smart about it in `tryToInvalidateFReadBufferByElements` [here](https://github.com/llvm/llvm-project/blob/2e3c7dbbcbfa37ae83251bb3da388df772680689/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp#L1108-1147).

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


More information about the cfe-commits mailing list