[clang] [NFC][analyzer] Add regression tests from bisection commits to the CSA's test suite (PR #241058)

Benedek Kaibas via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 12 02:11:49 PST 2026


https://github.com/benedekaibas updated https://github.com/llvm/llvm-project/pull/241058

>From f6f289b9d2d3eeb81b9d2fa0fa31bce97855f150 Mon Sep 17 00:00:00 2001
From: benedekaibas <kaibas01 at allegheny.edu>
Date: Wed, 11 Nov 2026 00:37:03 +0100
Subject: [PATCH 1/7] [NFC][analyzer] Add regression tests from bisection
 commits to the CSA's test suite

---
 clang/test/Analysis/builtin-functions.cpp     | 27 +++++++++++++
 clang/test/Analysis/div-zero.cpp              | 15 ++++++++
 .../test/Analysis/errno-stdlibraryfunctions.c | 38 +++++++++++++++++++
 clang/test/Analysis/inner-pointer.cpp         |  9 +++++
 clang/test/Analysis/loop-assumptions.c        | 22 +++++++++--
 clang/test/Analysis/mpichecker.cpp            |  9 +++++
 .../Analysis/mutually_exclusive_null_fp.cpp   |  8 ++++
 clang/test/Analysis/placement-new.cpp         | 12 ++++++
 .../Analysis/plist-macros-with-expansion.cpp  | 28 ++++++++++++++
 .../Analysis/retain-release-region-store.m    | 29 ++++++++++++++
 clang/test/Analysis/trivial-copy-struct.cpp   | 26 ++++++++++++-
 clang/test/Analysis/vla.c                     | 22 +++++++++++
 12 files changed, 240 insertions(+), 5 deletions(-)

diff --git a/clang/test/Analysis/builtin-functions.cpp b/clang/test/Analysis/builtin-functions.cpp
index f7bafabd23cbcc..91fe38a648857f 100644
--- a/clang/test/Analysis/builtin-functions.cpp
+++ b/clang/test/Analysis/builtin-functions.cpp
@@ -120,3 +120,30 @@ void test_constant_p(void *ptr) {
   clang_analyzer_eval(__builtin_constant_p(k - 3) == 1); // expected-warning {{TRUE}}
   clang_analyzer_eval(__builtin_constant_p(ptr == 0)); // expected-warning {{FALSE}}
 }
+
+#ifdef _WIN32
+namespace GH39448 {
+struct A { int someApi(); };
+
+int testAssert(A* a) {
+  __assume(a != nullptr);
+  return a->someApi();
+}
+
+int testAssert2(int* a) {
+  __assume(a != nullptr);
+  return *a;
+}
+
+int testAssert3(A* a) {
+  __assume(a);
+  return a->someApi();
+}
+
+int testAssert4(int* a) {
+  __assume(a);
+  return *a;
+}
+
+} // namespace GH39448
+#endif
diff --git a/clang/test/Analysis/div-zero.cpp b/clang/test/Analysis/div-zero.cpp
index c756f24dec86b0..83f597ad0ae08b 100644
--- a/clang/test/Analysis/div-zero.cpp
+++ b/clang/test/Analysis/div-zero.cpp
@@ -109,3 +109,18 @@ int t6() {
   return 1 / (f.x - 32); // expected-warning {{Division by zero}}
 }
 }
+
+namespace GH40797 {
+typedef __typeof(sizeof(int)) size_t;
+typedef long ssize_t;
+
+ssize_t read(int fd, void *buf, size_t count);
+
+ssize_t read_n(void *p, size_t size, size_t n) {
+  size_t len = n * size;
+  if (size && len / size != n)
+    return 0;
+  return len ? read(0, p, len) / size : 0; // no-warning
+}
+
+} // namespace GH40797
diff --git a/clang/test/Analysis/errno-stdlibraryfunctions.c b/clang/test/Analysis/errno-stdlibraryfunctions.c
index 72d167f68a1f49..c0b437e17dfe22 100644
--- a/clang/test/Analysis/errno-stdlibraryfunctions.c
+++ b/clang/test/Analysis/errno-stdlibraryfunctions.c
@@ -4,6 +4,7 @@
 // RUN:   -analyzer-checker=unix.StdCLibraryFunctions \
 // RUN:   -analyzer-checker=apiModeling.Errno \
 // RUN:   -analyzer-checker=unix.Errno \
+// RUN:   -analyzer-checker=unix.Malloc \
 // RUN:   -analyzer-config unix.StdCLibraryFunctions:ModelPOSIX=true
 
 #include "Inputs/errno_var.h"
@@ -175,3 +176,40 @@ void errno_realpath(char *Path, char *Buf) {
     if (errno) {} // expected-warning{{An undefined value may be read from 'errno'}}
   }
 }
+
+#define PATH_MAX 4096
+#define AF_UNIX 1
+#define SOCK_SEQPACKET 5
+#define SOCK_CLOEXEC 02000000
+
+void *malloc(size_t);
+void free(void *);
+int dosomething(char *);
+
+int GH43015_connect_socket(char **mname) {
+  int ret;
+  *mname = (char *)malloc(PATH_MAX);
+
+  int fd = socket(AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC, 0);
+  if (fd < 0) {
+    ret = errno;
+    free(*mname);
+    return ret;
+  }
+
+  {
+    ret = recv(fd, *mname, PATH_MAX, 0);
+    if (ret > 0) return 0;
+  }
+  close(fd);
+  return ret;
+}
+
+int GH43015(void) {
+  char *mname;
+  int ret = GH43015_connect_socket(&mname);
+  if (ret)
+    return ret;
+
+  return dosomething(mname); // no-warning
+}
diff --git a/clang/test/Analysis/inner-pointer.cpp b/clang/test/Analysis/inner-pointer.cpp
index 4cb194409412c6..30081457364c3f 100644
--- a/clang/test/Analysis/inner-pointer.cpp
+++ b/clang/test/Analysis/inner-pointer.cpp
@@ -25,6 +25,8 @@ T *__addressof(T &arg);
 
 char *data(std::string &c);
 
+string to_string(int);
+
 } // end namespace std
 
 void consume(const char *) {}
@@ -437,3 +439,10 @@ void no_CXXRecordDecl() {
 void checkReference(std::string &s) {
   const char *c = s.c_str();
 }
+
+const char *GH59870(int value) {
+  thread_local std::string retval;
+
+  retval = std::to_string(value);
+  return retval.c_str(); // no-warning
+}
diff --git a/clang/test/Analysis/loop-assumptions.c b/clang/test/Analysis/loop-assumptions.c
index b61ed8815e3f6e..55a9e28525295f 100644
--- a/clang/test/Analysis/loop-assumptions.c
+++ b/clang/test/Analysis/loop-assumptions.c
@@ -1,12 +1,12 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection \
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection \
 // RUN:     -verify=expected,noassumeone,eagerlyassume,combo %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection \
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection \
 // RUN:     -analyzer-config eagerly-assume=false \
 // RUN:     -verify=expected,noassumeone,noeagerlyassume,combo %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection \
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection \
 // RUN:     -analyzer-config assume-at-least-one-iteration=true \
 // RUN:     -verify=expected,eagerlyassume,combo %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection \
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection \
 // RUN:     -analyzer-config assume-at-least-one-iteration=true,eagerly-assume=false \
 // RUN:     -verify=expected,noeagerlyassume %s
 
@@ -260,3 +260,17 @@ void onlyLoopConditions(int arg) {
 
   clang_analyzer_dump(i); // expected-warning {{1}} expected-warning {{2}} expected-warning {{3}} expected-warning {{4}}
 }
+
+void GH20099(const unsigned char n) {
+
+  int buf[2][4] = {{0,0,0,0},{0,0,0,0}};
+  unsigned char j,k,l,x;
+
+  for (l = n - 1; l >= 1; l--)
+    x = 0;
+
+  for (j = n - 1; j >= 1; j--) {
+    for (k = 0; k <= j - 1; k++)
+      x = buf[k][j]; // no-warning
+  }
+}
diff --git a/clang/test/Analysis/mpichecker.cpp b/clang/test/Analysis/mpichecker.cpp
index f2fd6c0951a2fd..514167233320d5 100644
--- a/clang/test/Analysis/mpichecker.cpp
+++ b/clang/test/Analysis/mpichecker.cpp
@@ -380,3 +380,12 @@ void externFunctions2() {
   void callNonblockingExtern(MPI_Request *req);
   callNonblockingExtern(&req);
 }
+
+bool contains();
+void GH64647() {
+  if (contains()) {
+    MPI_Request request_item;
+    MPI_Wait(&request_item, MPI_STATUS_IGNORE); // expected-warning {{Request 'request_item' has no matching nonblocking call.}}
+	}
+	GH64647();
+}
diff --git a/clang/test/Analysis/mutually_exclusive_null_fp.cpp b/clang/test/Analysis/mutually_exclusive_null_fp.cpp
index e74e4e7be3580b..ac4c1bc04a25c1 100644
--- a/clang/test/Analysis/mutually_exclusive_null_fp.cpp
+++ b/clang/test/Analysis/mutually_exclusive_null_fp.cpp
@@ -22,3 +22,11 @@ int compare(Data &a, Data &b) {
 
   return compare(*aData, *bData); // no-warning
 }
+
+void GH3206(char* a, char* b) {
+  if (a != b) {
+    if (a != nullptr || b == nullptr) {
+			a[0] = '\0'; // no-warning
+		}
+  }
+}
diff --git a/clang/test/Analysis/placement-new.cpp b/clang/test/Analysis/placement-new.cpp
index 292ea40b150b88..d8629433d83d29 100644
--- a/clang/test/Analysis/placement-new.cpp
+++ b/clang/test/Analysis/placement-new.cpp
@@ -485,3 +485,15 @@ void test22() {
 }
 
 } // namespace testStructAlign
+
+namespace GH56264 {
+struct S {
+  int x;
+};
+
+void test() {
+  S arr[4];
+  ::new (arr + 1) S[1]; // no-warning
+}
+
+} // namespace GH56264
diff --git a/clang/test/Analysis/plist-macros-with-expansion.cpp b/clang/test/Analysis/plist-macros-with-expansion.cpp
index d57bb0f2dd2651..c41d7f2e29c230 100644
--- a/clang/test/Analysis/plist-macros-with-expansion.cpp
+++ b/clang/test/Analysis/plist-macros-with-expansion.cpp
@@ -948,3 +948,31 @@ int bz44493(void) {
 // CHECK-NEXT:   <key>expansion</key><string>--(a );</string>
 // CHECK-NEXT:  </dict>
 // CHECK-NEXT: </array>
+
+const char *traceid(const char *);
+int trace(int, const char *, int, ...);
+#define TRACE_CALL(tracelevel, ...)  { __VA_ARGS__; }
+
+#define TRACE(tracelevel, str, ...) \
+  TRACE_CALL((tracelevel), trace((0), traceid("formatstr " str), 0, tracelevel, __VA_ARGS__))
+
+#define TRACE_WRAPPER TRACE
+
+void GH47932(void* Context_p)
+{
+  int localvar;
+  TRACE_WRAPPER(localvar, "localvar=%u ", 0); // expected-warning {{4th function call argument is an uninitialized value}}
+}
+// CHECK:      <key>macro_expansions</key>
+// CHECK-NEXT: <array>
+// CHECK-NEXT:  <dict>
+// CHECK-NEXT:   <key>location</key>
+// CHECK-NEXT:   <dict>
+// CHECK-NEXT:    <key>line</key><integer>964</integer>
+// CHECK-NEXT:    <key>col</key><integer>3</integer>
+// CHECK-NEXT:    <key>file</key><integer>0</integer>
+// CHECK-NEXT:   </dict>
+// CHECK-NEXT:   <key>name</key><string>TRACE_WRAPPER(localvar, "localvar=%u ", 0)</string>
+// CHECK-NEXT:   <key>expansion</key><string>{trace ((0),traceid ("formatstr ""localvar=%u "),0,localvar ,0);}</string>
+// CHECK-NEXT:  </dict>
+// CHECK-NEXT: </array>
diff --git a/clang/test/Analysis/retain-release-region-store.m b/clang/test/Analysis/retain-release-region-store.m
index 2418c9a5383d19..1f6a96cb82a513 100644
--- a/clang/test/Analysis/retain-release-region-store.m
+++ b/clang/test/Analysis/retain-release-region-store.m
@@ -255,3 +255,32 @@ void R8261992_test(R8261992 *tc) {
   *p = 0xDEADBEEF; // expected-warning{{null}}
 }
 
+extern CFStringRef CFStringCreateCopy(CFAllocatorRef, CFStringRef) __attribute__((cf_returns_retained));
+extern CFStringRef exampleString;
+CFStringRef GH19340_Strings[2][2];
+
+ at interface GH19340_StringCache : NSObject {
+  CFStringRef strings[2];
+  CFStringRef moreStrings[2][2];
+}
+ at end
+
+ at implementation GH19340_StringCache
+- (CFStringRef)stringAtZ:(int)z {
+  if (!strings[z])
+    strings[z] = CFStringCreateCopy(kCFAllocatorDefault, exampleString);
+  return strings[z]; // no-warning
+}
+
+- (CFStringRef)stringAtX:(int)x y:(int)y {
+  if (!moreStrings[x][y])
+    moreStrings[x][y] = CFStringCreateCopy(kCFAllocatorDefault, exampleString);
+  return moreStrings[x][y]; // no-warning
+}
+
+- (CFStringRef)staticStringAtX:(int)x y:(int)y {
+  if (!GH19340_Strings[x][y])
+    GH19340_Strings[x][y] = CFStringCreateCopy(kCFAllocatorDefault, exampleString);
+  return GH19340_Strings[x][y]; // no-warning
+}
+ at end
diff --git a/clang/test/Analysis/trivial-copy-struct.cpp b/clang/test/Analysis/trivial-copy-struct.cpp
index b2da777541aba9..e8102834ac37a8 100644
--- a/clang/test/Analysis/trivial-copy-struct.cpp
+++ b/clang/test/Analysis/trivial-copy-struct.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,debug.ExprInspection -verify %s
 
 template <typename T> void clang_analyzer_dump(T);
 template <typename T> void clang_analyzer_value(T);
@@ -99,3 +99,27 @@ void nestedLazyCompoundVal(List* n) {
   }
   delete w;
 }
+
+struct GH60694_Node { GH60694_Node *parent; };
+
+void GH60694(GH60694_Node *a, GH60694_Node *b) {
+  if (a->parent)
+    return;
+  *a = *b;
+  a->parent->parent = 0;
+}
+
+void free(void *);
+
+struct GH26595_List { GH26595_List *next; };
+
+GH26595_List *GH26595(GH26595_List *item) {
+  GH26595_List *next = item->next;
+  if (next) {
+    *item = *next;
+    free(next);
+    return item->next; // no-warning
+  }
+
+  return item;
+}
diff --git a/clang/test/Analysis/vla.c b/clang/test/Analysis/vla.c
index e32fe63c931400..f1c5058c653e35 100644
--- a/clang/test/Analysis/vla.c
+++ b/clang/test/Analysis/vla.c
@@ -151,3 +151,25 @@ void b(void) {
       foo();
   }
 } // no-crash
+
+float GH49330(int nValues, int x) {
+  int sqr = nValues * nValues;
+  float array[sqr];
+
+  for(unsigned long i = 0; i < sqr; ++i) {
+    array[i] = 0;
+  }
+
+  float sum = 0;
+  for (int i = 0; i < nValues; i++){
+    for (int j = 0; j < nValues; j++) {
+      sum += x * array[i + nValues * j]; // no-warning
+    }
+  }
+
+  if ( x < 12 ) {
+    GH49330(nValues, x+1);
+  }
+
+  return sum;
+}

>From 756496a6acfb8d5f0c267067569178fff6d79503 Mon Sep 17 00:00:00 2001
From: benedekaibas <kaibas01 at allegheny.edu>
Date: Wed, 11 Nov 2026 20:59:36 +0100
Subject: [PATCH 2/7] Add comments and reduce size of some of the test cases.

---
 clang/lib/Analysis/CFG.cpp                    |  2 +-
 clang/test/Analysis/builtin-functions.cpp     | 16 +++----
 .../test/Analysis/errno-stdlibraryfunctions.c | 42 ++++---------------
 clang/test/Analysis/inner-pointer.cpp         |  7 ++++
 clang/test/Analysis/loop-assumptions.c        | 10 +++++
 clang/test/Analysis/mpichecker.cpp            |  4 +-
 .../Analysis/mutually_exclusive_null_fp.cpp   |  6 ++-
 clang/test/Analysis/placement-new.cpp         | 23 +++++-----
 .../Analysis/retain-release-region-store.m    |  4 ++
 clang/test/Analysis/trivial-copy-struct.cpp   |  7 ++++
 clang/test/Analysis/vla.c                     | 15 ++++---
 11 files changed, 70 insertions(+), 66 deletions(-)

diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index 1c69f5d71583f5..4d6bf0ba8bd9b5 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -2411,7 +2411,7 @@ CFGBlock *CFGBuilder::Visit(Stmt * S, AddStmtChoice asc,
       // FIXME: The expression inside a CXXDefaultArgExpr is owned by the
       // called function's declaration, not by the caller. If we simply add
       // this expression to the CFG, we could end up with the same Expr
-      // appearing multiple times (GH13757).
+      // appearing multiple times (PR13385).
       //
       // It's likewise possible for multiple CXXDefaultInitExprs for the same
       // expression to be used in the same function (through aggregate
diff --git a/clang/test/Analysis/builtin-functions.cpp b/clang/test/Analysis/builtin-functions.cpp
index 91fe38a648857f..fa693ca35c25fb 100644
--- a/clang/test/Analysis/builtin-functions.cpp
+++ b/clang/test/Analysis/builtin-functions.cpp
@@ -125,24 +125,24 @@ void test_constant_p(void *ptr) {
 namespace GH39448 {
 struct A { int someApi(); };
 
-int testAssert(A* a) {
+void testAssert(A* a) {
   __assume(a != nullptr);
-  return a->someApi();
+  clang_analyzer_eval(a != nullptr); // expected-warning {{TRUE}}
 }
 
-int testAssert2(int* a) {
+void testAssert2(int* a) {
   __assume(a != nullptr);
-  return *a;
+  clang_analyzer_eval(a != nullptr); // expected-warning {{TRUE}}
 }
 
-int testAssert3(A* a) {
+void testAssert3(A* a) {
   __assume(a);
-  return a->someApi();
+  clang_analyzer_eval(a != nullptr); // expected-warning {{TRUE}}
 }
 
-int testAssert4(int* a) {
+void testAssert4(int* a) {
   __assume(a);
-  return *a;
+  clang_analyzer_eval(a != nullptr); // expected-warning {{TRUE}}
 }
 
 } // namespace GH39448
diff --git a/clang/test/Analysis/errno-stdlibraryfunctions.c b/clang/test/Analysis/errno-stdlibraryfunctions.c
index c0b437e17dfe22..4baa07cec444be 100644
--- a/clang/test/Analysis/errno-stdlibraryfunctions.c
+++ b/clang/test/Analysis/errno-stdlibraryfunctions.c
@@ -4,7 +4,6 @@
 // RUN:   -analyzer-checker=unix.StdCLibraryFunctions \
 // RUN:   -analyzer-checker=apiModeling.Errno \
 // RUN:   -analyzer-checker=unix.Errno \
-// RUN:   -analyzer-checker=unix.Malloc \
 // RUN:   -analyzer-config unix.StdCLibraryFunctions:ModelPOSIX=true
 
 #include "Inputs/errno_var.h"
@@ -177,39 +176,12 @@ void errno_realpath(char *Path, char *Buf) {
   }
 }
 
-#define PATH_MAX 4096
-#define AF_UNIX 1
-#define SOCK_SEQPACKET 5
-#define SOCK_CLOEXEC 02000000
-
-void *malloc(size_t);
-void free(void *);
-int dosomething(char *);
-
-int GH43015_connect_socket(char **mname) {
-  int ret;
-  *mname = (char *)malloc(PATH_MAX);
-
-  int fd = socket(AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC, 0);
-  if (fd < 0) {
-    ret = errno;
-    free(*mname);
-    return ret;
-  }
-
-  {
-    ret = recv(fd, *mname, PATH_MAX, 0);
-    if (ret > 0) return 0;
+// A failed socket() sets errno to a non-zero value, so a caller that returns
+// errno on the failure path cannot return zero. GH43015 reported a false
+// use-after-free in clang 18.1.0. Since clang 19.1.0 the false positive is
+// no longer present.
+void GH43015(void) {
+  if (socket(1, 2, 3) < 0) {
+    clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}}
   }
-  close(fd);
-  return ret;
-}
-
-int GH43015(void) {
-  char *mname;
-  int ret = GH43015_connect_socket(&mname);
-  if (ret)
-    return ret;
-
-  return dosomething(mname); // no-warning
 }
diff --git a/clang/test/Analysis/inner-pointer.cpp b/clang/test/Analysis/inner-pointer.cpp
index 30081457364c3f..861221b353fa2a 100644
--- a/clang/test/Analysis/inner-pointer.cpp
+++ b/clang/test/Analysis/inner-pointer.cpp
@@ -440,6 +440,13 @@ void checkReference(std::string &s) {
   const char *c = s.c_str();
 }
 
+// In Clang 14.0.0 cplusplus.InnerPointer reported a false
+// positive at the return statement:
+// "Inner pointer of container used after re/deallocation".
+// The underlying issue was fixed and since Clang 15.0.0 the
+// false positive is no longer present. 'retval' has thread
+// storage duration, so it outlives the call and the pointer
+// returned by c_str() stays valid.
 const char *GH59870(int value) {
   thread_local std::string retval;
 
diff --git a/clang/test/Analysis/loop-assumptions.c b/clang/test/Analysis/loop-assumptions.c
index 55a9e28525295f..67359a631fb86a 100644
--- a/clang/test/Analysis/loop-assumptions.c
+++ b/clang/test/Analysis/loop-assumptions.c
@@ -261,6 +261,16 @@ void onlyLoopConditions(int arg) {
   clang_analyzer_dump(i); // expected-warning {{1}} expected-warning {{2}} expected-warning {{3}} expected-warning {{4}}
 }
 
+// In Clang 19.1.0 the analyzer reported that:
+// "Assigned value is garbage or undefined" for `int buf [2][4]`. Since it is
+// possible to receive a large number for `n` the report itself is plausible.
+// #119388 ensures that if the loop condition is opaque and there were at
+// least two iterations, the analyzer does not make the assumption that it
+// can enter the third iteration.
+// Before Clang 20.1.0 the plausbile was present because when the loop
+// iterated over a two or more elements data structure the analyzer could not
+// understand the loop condition and assumed that there might be a
+// third, fourth, etc. iteration.
 void GH20099(const unsigned char n) {
 
   int buf[2][4] = {{0,0,0,0},{0,0,0,0}};
diff --git a/clang/test/Analysis/mpichecker.cpp b/clang/test/Analysis/mpichecker.cpp
index 514167233320d5..9f856285343295 100644
--- a/clang/test/Analysis/mpichecker.cpp
+++ b/clang/test/Analysis/mpichecker.cpp
@@ -381,9 +381,9 @@ void externFunctions2() {
   callNonblockingExtern(&req);
 }
 
-bool contains();
+bool coin();
 void GH64647() {
-  if (contains()) {
+  if (coin()) {
     MPI_Request request_item;
     MPI_Wait(&request_item, MPI_STATUS_IGNORE); // expected-warning {{Request 'request_item' has no matching nonblocking call.}}
 	}
diff --git a/clang/test/Analysis/mutually_exclusive_null_fp.cpp b/clang/test/Analysis/mutually_exclusive_null_fp.cpp
index ac4c1bc04a25c1..74bad31101e95a 100644
--- a/clang/test/Analysis/mutually_exclusive_null_fp.cpp
+++ b/clang/test/Analysis/mutually_exclusive_null_fp.cpp
@@ -23,10 +23,12 @@ int compare(Data &a, Data &b) {
   return compare(*aData, *bData); // no-warning
 }
 
-void GH3206(char* a, char* b) {
+void GH3206(char *a, char *b) {
   if (a != b) {
     if (a != nullptr || b == nullptr) {
-			a[0] = '\0'; // no-warning
+      // no-warning: 'a' is checked against null and even if 'b' is null the
+      // outer if statement rules out entering with both 'a' and 'b' being null.
+			a[0] = '\0';
 		}
   }
 }
diff --git a/clang/test/Analysis/placement-new.cpp b/clang/test/Analysis/placement-new.cpp
index d8629433d83d29..a06a85f296caf1 100644
--- a/clang/test/Analysis/placement-new.cpp
+++ b/clang/test/Analysis/placement-new.cpp
@@ -202,6 +202,17 @@ void f2() {
   alignas(S) unsigned char buffer2[sizeof(S) * N + sizeof(int)]; 
   ::new (buffer2) S[N]; // no-warning: See comments above
 }
+
+void f3() {
+  struct S {
+    int x;
+  };
+
+  // Same as f1() above, but the storage is an offset into an existing array.
+  // Reported as GH56264 and fixed by #150161.
+  S arr[4];
+  ::new (arr + 1) S[1]; // no-warning: See comments above
+}
 } // namespace testArrayTypesAllocation
 
 namespace testStructAlign {
@@ -485,15 +496,3 @@ void test22() {
 }
 
 } // namespace testStructAlign
-
-namespace GH56264 {
-struct S {
-  int x;
-};
-
-void test() {
-  S arr[4];
-  ::new (arr + 1) S[1]; // no-warning
-}
-
-} // namespace GH56264
diff --git a/clang/test/Analysis/retain-release-region-store.m b/clang/test/Analysis/retain-release-region-store.m
index 1f6a96cb82a513..36d724d0fc0c5a 100644
--- a/clang/test/Analysis/retain-release-region-store.m
+++ b/clang/test/Analysis/retain-release-region-store.m
@@ -255,6 +255,10 @@ void R8261992_test(R8261992 *tc) {
   *p = 0xDEADBEEF; // expected-warning{{null}}
 }
 
+// #133381 removed the early return for BaseRegions of the ElementRegion types
+// and returned MemRegionVal instead. Before that the store to
+// 'moreStrings[x][y]' was dropped, so the retained string looked unreachable
+// and the RetainCount checker reported a potential leak.
 extern CFStringRef CFStringCreateCopy(CFAllocatorRef, CFStringRef) __attribute__((cf_returns_retained));
 extern CFStringRef exampleString;
 CFStringRef GH19340_Strings[2][2];
diff --git a/clang/test/Analysis/trivial-copy-struct.cpp b/clang/test/Analysis/trivial-copy-struct.cpp
index e8102834ac37a8..66afef26e579f0 100644
--- a/clang/test/Analysis/trivial-copy-struct.cpp
+++ b/clang/test/Analysis/trivial-copy-struct.cpp
@@ -100,6 +100,13 @@ void nestedLazyCompoundVal(List* n) {
   delete w;
 }
 
+// In some cases SymbolRegions were wrapped by ElementRegions in
+// some they weren't. That is why the analyzer did not recognize
+// if two regions are referring to the same entity whic could
+// lead to unreachable paths discovered and also false reports.
+// D132142 resolved this issue while D132143 made
+// LazyCompoundVals to only appear as default bindings in the
+// RegionStore. This applies to both GH60694 and GH26595.
 struct GH60694_Node { GH60694_Node *parent; };
 
 void GH60694(GH60694_Node *a, GH60694_Node *b) {
diff --git a/clang/test/Analysis/vla.c b/clang/test/Analysis/vla.c
index f1c5058c653e35..c91c01b0f73f74 100644
--- a/clang/test/Analysis/vla.c
+++ b/clang/test/Analysis/vla.c
@@ -152,6 +152,12 @@ void b(void) {
   }
 } // no-crash
 
+// Clang 13.0.1 reported "The right operand of '*' is a garbage value"
+// for 'sum += x * array[i + nValues * j]' which was a false positive.
+// The symbol simplification mechanism was not able to handle cases
+// when a symbol was simplified to a concrete integer.
+// D110913 resolved this issue and since Clang 14.0.0 the false
+// positive is gone.
 float GH49330(int nValues, int x) {
   int sqr = nValues * nValues;
   float array[sqr];
@@ -163,13 +169,10 @@ float GH49330(int nValues, int x) {
   float sum = 0;
   for (int i = 0; i < nValues; i++){
     for (int j = 0; j < nValues; j++) {
-      sum += x * array[i + nValues * j]; // no-warning
+      // no-warning: The loops initialize all 'sqr' elements and the
+      // index stays within 'nValues * nValues'.
+      sum += x * array[i + nValues * j];
     }
   }
-
-  if ( x < 12 ) {
-    GH49330(nValues, x+1);
-  }
-
   return sum;
 }

>From 53d111512f10c2c36f5d9e995355fee2469d4206 Mon Sep 17 00:00:00 2001
From: benedekaibas <kaibas01 at allegheny.edu>
Date: Wed, 11 Nov 2026 21:11:41 +0100
Subject: [PATCH 3/7] Remove leftover PR number from revert testing.

---
 clang/lib/Analysis/CFG.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index 4d6bf0ba8bd9b5..1c69f5d71583f5 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -2411,7 +2411,7 @@ CFGBlock *CFGBuilder::Visit(Stmt * S, AddStmtChoice asc,
       // FIXME: The expression inside a CXXDefaultArgExpr is owned by the
       // called function's declaration, not by the caller. If we simply add
       // this expression to the CFG, we could end up with the same Expr
-      // appearing multiple times (PR13385).
+      // appearing multiple times (GH13757).
       //
       // It's likewise possible for multiple CXXDefaultInitExprs for the same
       // expression to be used in the same function (through aggregate

>From 497e22a8787e52dc0b83d580ef2cfc14442985d7 Mon Sep 17 00:00:00 2001
From: benedekaibas <kaibas01 at allegheny.edu>
Date: Wed, 11 Nov 2026 21:33:47 +0100
Subject: [PATCH 4/7] Add short explanation.

---
 clang/test/Analysis/div-zero.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/Analysis/div-zero.cpp b/clang/test/Analysis/div-zero.cpp
index 83f597ad0ae08b..1e6f7cb36419ef 100644
--- a/clang/test/Analysis/div-zero.cpp
+++ b/clang/test/Analysis/div-zero.cpp
@@ -120,7 +120,7 @@ ssize_t read_n(void *p, size_t size, size_t n) {
   size_t len = n * size;
   if (size && len / size != n)
     return 0;
-  return len ? read(0, p, len) / size : 0; // no-warning
+  return len ? read(0, p, len) / size : 0; // no-warning: size can't be zero, thus no div by zero
 }
 
 } // namespace GH40797

>From 827c2ab48382ae1ffd571bfa96554cc1889c2426 Mon Sep 17 00:00:00 2001
From: benedekaibas <kaibas01 at allegheny.edu>
Date: Thu, 12 Nov 2026 10:31:19 +0100
Subject: [PATCH 5/7] Fix indentation

---
 clang/test/Analysis/mutually_exclusive_null_fp.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/Analysis/mutually_exclusive_null_fp.cpp b/clang/test/Analysis/mutually_exclusive_null_fp.cpp
index 74bad31101e95a..caa29f30e7a52d 100644
--- a/clang/test/Analysis/mutually_exclusive_null_fp.cpp
+++ b/clang/test/Analysis/mutually_exclusive_null_fp.cpp
@@ -28,7 +28,7 @@ void GH3206(char *a, char *b) {
     if (a != nullptr || b == nullptr) {
       // no-warning: 'a' is checked against null and even if 'b' is null the
       // outer if statement rules out entering with both 'a' and 'b' being null.
-			a[0] = '\0';
-		}
+      a[0] = '\0';
+    }
   }
 }

>From 29acd3e645dd611fcd60831442f0ca22f7028e10 Mon Sep 17 00:00:00 2001
From: Benedek Kaibas <82393336+benedekaibas at users.noreply.github.com>
Date: Thu, 12 Nov 2026 11:11:27 +0100
Subject: [PATCH 6/7] Update clang/test/Analysis/loop-assumptions.c
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Donát Nagy <donat.nagy at ericsson.com>
---
 clang/test/Analysis/loop-assumptions.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/Analysis/loop-assumptions.c b/clang/test/Analysis/loop-assumptions.c
index 67359a631fb86a..24521ea1881cdd 100644
--- a/clang/test/Analysis/loop-assumptions.c
+++ b/clang/test/Analysis/loop-assumptions.c
@@ -267,7 +267,7 @@ void onlyLoopConditions(int arg) {
 // #119388 ensures that if the loop condition is opaque and there were at
 // least two iterations, the analyzer does not make the assumption that it
 // can enter the third iteration.
-// Before Clang 20.1.0 the plausbile was present because when the loop
+// Before Clang 20.1.0 the plausible path was present because when the loop
 // iterated over a two or more elements data structure the analyzer could not
 // understand the loop condition and assumed that there might be a
 // third, fourth, etc. iteration.

>From f0e19ef38e007e662d74c298eeb25d85b5d07fb6 Mon Sep 17 00:00:00 2001
From: Benedek Kaibas <82393336+benedekaibas at users.noreply.github.com>
Date: Thu, 12 Nov 2026 11:11:37 +0100
Subject: [PATCH 7/7] Update clang/test/Analysis/trivial-copy-struct.cpp
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Donát Nagy <donat.nagy at ericsson.com>
---
 clang/test/Analysis/trivial-copy-struct.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/Analysis/trivial-copy-struct.cpp b/clang/test/Analysis/trivial-copy-struct.cpp
index 66afef26e579f0..39a0d274121480 100644
--- a/clang/test/Analysis/trivial-copy-struct.cpp
+++ b/clang/test/Analysis/trivial-copy-struct.cpp
@@ -102,7 +102,7 @@ void nestedLazyCompoundVal(List* n) {
 
 // In some cases SymbolRegions were wrapped by ElementRegions in
 // some they weren't. That is why the analyzer did not recognize
-// if two regions are referring to the same entity whic could
+// if two regions are referring to the same entity which could
 // lead to unreachable paths discovered and also false reports.
 // D132142 resolved this issue while D132143 made
 // LazyCompoundVals to only appear as default bindings in the



More information about the cfe-commits mailing list