[clang] [analyzer] Untangle subcheckers of CStringChecker (PR #186802)

Balázs Benics via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 16 08:13:13 PDT 2026


================
@@ -870,12 +870,23 @@ void doNotInvalidateWhenPassedToSystemCalls(char *s) {
   strlen(p);
   strcpy(p, s);
   strcpy(s, p);
+  // FIXME: We should stop analysis here, even if we emit no warnings, since
+  // overlapping buffers for strycpy is a fatal error.
   strcpy(p, p);
   memcpy(p, s, 1);
   memcpy(s, p, 1);
   memcpy(p, p, 1);
 } // expected-warning {{leak}}
 
+void doNotInvalidateWhenPassedToSystemCalls2(char *s) {
+  char *p = malloc(12);
+  // FIXME: We should stop analysis here, even if we emit no warnings, since
+  // overlapping buffers for strycpy is a fatal error.
+  int a[4] = {0};
+  memcpy(a+2, a+1, 8);
+  (void)p;
+} // expected-warning {{leak}}
+
----------------
steakhal wrote:

When I read this test, I didn't get what invalidation the title is talking about.
If the execution would sink, the leak warning would go away, right? But how does that relate to invalidation?

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


More information about the cfe-commits mailing list