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

Qiu Chaofan via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 24 00:37:18 PST 2025


================
@@ -959,6 +959,10 @@ def warn_quoted_include_in_framework_header : Warning<
 def warn_framework_include_private_from_public : Warning<
   "public framework header includes private framework header '%0'"
   >, InGroup<FrameworkIncludePrivateFromPublic>;
+def warn_header_shadowing : Warning<
+  "multiple candidates for header '%0' found; "
+  "directory '%1' chosen, ignoring '%2' and others">,
+  InGroup<ShadowHeader>, DefaultIgnore;
----------------
ecnelises wrote:

I'm still thinking about whether here needs change if `len(shadowed headers) == 1`.

Maybe write as following:

```
def warn_header_shadowing : Warning<
  "multiple candidates for header '%0' found; "
  "directory '%1' chosen, ignoring '%2'%select{| and others}3"">,
  InGroup<ShadowHeader>, DefaultIgnore;
```

then in Cpp code:

```cpp
Diags.Report(IncludeLoc, diag::warn_header_shadowing)
            << Filename << (*FE).getDir().getName()
            << IncluderAndDir.second.getName()
            << (Count > 1);
```

But this is not a blocker.

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


More information about the cfe-commits mailing list