[all-commits] [llvm/llvm-project] 689b3c: [clang] Support header shadowing diagnostics in Cl...
Jinjie Huang via All-commits
all-commits at lists.llvm.org
Tue Dec 2 22:08:42 PST 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 689b3cc7c700b1687cf4aaaf4ef2c81a4e988917
https://github.com/llvm/llvm-project/commit/689b3cc7c700b1687cf4aaaf4ef2c81a4e988917
Author: Jinjie Huang <huangjinjie at bytedance.com>
Date: 2025-12-03 (Wed, 03 Dec 2025)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/include/clang/Basic/DiagnosticGroups.td
M clang/include/clang/Basic/DiagnosticLexKinds.td
M clang/include/clang/Lex/HeaderSearch.h
M clang/lib/Lex/HeaderSearch.cpp
A clang/test/Preprocessor/header-shadowing.c
Log Message:
-----------
[clang] Support header shadowing diagnostics in Clang header search (#162491)
When including a header file, multiple files with the same name may
exist across different search paths, like:
|-- main.cpp
|-- **header.h**
|-- include
| └── **header.h**
The compiler usually picks the first match it finds (typically following
MSVC rules for current/include-chain paths first, then regular -I
paths), which may not be the user’s intended header.
This silent behavior can lead to subtle runtime API mismatches or
increase the cost of resolving errors such as “error: use of undeclared
identifier”, especially in large projects.
Therefore, this patch tries to provide a diagnostic message without
changing the current header selection. It does this by performing an
additional search for duplicate filenames across all search paths (both
MSVC rules and standard paths). This informs the user about a potential
"header shadowing" issue and clarifies which header path was actually
used.
Since header searching is much cheaper than file loading, the added
overhead should be within an acceptable range -- assuming the diagnostic
message is valuable.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list