[clang] [clang] Support header shadowing diagnostics in Clang header search (PR #162491)

Qiu Chaofan via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 2 23:26:26 PST 2025


================
@@ -0,0 +1,14 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -Wheader-shadowing -Eonly %t/main.c -I %t/include  2>&1 | FileCheck %s --check-prefix=SHADOWING
+// SHADOWING: {{.*}} warning: multiple candidates for header 'header.h' found;
+
+//--- main.c
+#include "header.h"
----------------
ecnelises wrote:

Better use clang's builtin verify mechanism as other clang tests do.

```suggestion
// RUN: %clang_cc1 -Wheader-shadowing -Eonly %t/main.c -I %t/include -verify

//--- main.c
#include "header.h" // expected-warning-re{{multiple candidates for header 'header.h' found; using the one from '{{[^']+}}', shadowed by '{{[^']+}}/include'}}
```

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


More information about the cfe-commits mailing list