[clang] [analyzer] Fix 'bstring.c' test on Mingw (PR #192252)
Balázs Benics via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 15 06:26:32 PDT 2026
https://github.com/steakhal updated https://github.com/llvm/llvm-project/pull/192252
>From fc60581db8e6d5e7c2f1c22cd7be63a1a8eb3cfa Mon Sep 17 00:00:00 2001
From: Balazs Benics <benicsbalazs at gmail.com>
Date: Wed, 15 Apr 2026 13:42:55 +0100
Subject: [PATCH 1/2] [analyzer] Fix 'bstring.c' test on Mingw
We can't just `_WIN32` macro because it's not present on Mingw.
Addresses https://github.com/llvm/llvm-project/pull/191061#issuecomment-4250948488
---
clang/test/Analysis/bstring.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/Analysis/bstring.c b/clang/test/Analysis/bstring.c
index f343aaec43307..7e2ee1af006af 100644
--- a/clang/test/Analysis/bstring.c
+++ b/clang/test/Analysis/bstring.c
@@ -539,7 +539,7 @@ void nocrash_on_locint_offset(void *addr, void* from, struct S s) {
void nocrash_on_empty_struct_memcpy(void) {
struct {} a[10];
__builtin_memcpy(&a[2], a, 2); // no-crash
-#if !defined(_WIN32)
+#if defined(__GNUC__)
// expected-warning at -2 {{'memcpy' will always overflow; destination buffer has size 0, but size argument is 2}}
// expected-warning at -3 {{Memory copy function overflows the destination buffer}}
#endif
>From 72f83d4e57089d8c14d0dfe641c1764881fdccf7 Mon Sep 17 00:00:00 2001
From: Balazs Benics <benicsbalazs at gmail.com>
Date: Wed, 15 Apr 2026 14:26:13 +0100
Subject: [PATCH 2/2] Fix the test again
---
clang/test/Analysis/bstring.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/Analysis/bstring.c b/clang/test/Analysis/bstring.c
index 7e2ee1af006af..810241accffa2 100644
--- a/clang/test/Analysis/bstring.c
+++ b/clang/test/Analysis/bstring.c
@@ -539,7 +539,7 @@ void nocrash_on_locint_offset(void *addr, void* from, struct S s) {
void nocrash_on_empty_struct_memcpy(void) {
struct {} a[10];
__builtin_memcpy(&a[2], a, 2); // no-crash
-#if defined(__GNUC__)
+#if !defined(_WIN32) || defined(__MINGW32__)
// expected-warning at -2 {{'memcpy' will always overflow; destination buffer has size 0, but size argument is 2}}
// expected-warning at -3 {{Memory copy function overflows the destination buffer}}
#endif
More information about the cfe-commits
mailing list