- Notifications
You must be signed in to change notification settings - Fork 15.3k
[clang] Support header shadowing diagnostics in Clang header search #162491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Jinjie-Huang wants to merge 7 commits into llvm:main Choose a base branch from Jinjie-Huang:users/huangjinjie/clang_include_multi_candidates
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
+139 −0
Open
Changes from all commits
Commits
Show all changes
7 commits Select commit Hold shift + click to select a range
2928471 header shadowing diagnostics
Jinjie-Huang b0d265d update release note
Jinjie-Huang cde15fa Suppress check for system headers
Jinjie-Huang 0312677 Identify if a file is a system header by its path
Jinjie-Huang 8765436 Ignore diagnostics from system headers.
Jinjie-Huang 923e57e fix nits
Jinjie-Huang 6d30e45 modify diagnostics information, use 'others including ...'
Jinjie-Huang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| // RUN: rm -rf %t | ||
| // RUN: split-file %s %t | ||
| | ||
| /// Check that: | ||
| /// - Quoted includes ("...") trigger the diagnostic. | ||
| /// - System headers are ignored. | ||
| /// - #include_next does not cause a duplicate warning. | ||
| // RUN: %clang_cc1 -Wshadow-header -Eonly %t/main.c -I %t/include1 -I %t/include2 \ | ||
| // RUN: -isystem %t/system1 -isystem %t/system2 2>&1 | FileCheck %s --check-prefix=SHADOWING | ||
| | ||
| // SHADOWING: {{.*}} warning: multiple candidates for header 'header.h' found; directory '{{.*}}include1' chosen, ignoring others including '{{.*}}include2' [-Wshadow-header] | ||
| // SHADOWING: warning: include1/header.h included! | ||
| // SHADOWING-NOT: {{.*}} warning: multiple candidates for header 'header.h' found; directory '{{.*}}include2' chosen, ignoring others including '{{.*}}include1' [-Wshadow-header] | ||
| // SHADOWING: warning: include2/header.h included! | ||
| // SHADOWING-NOT: {{.*}} warning: multiple candidates for header 'stdio.h' found; directory '{{.*}}system1' chosen, ignoring others including '{{.*}}system2' [-Wshadow-header] | ||
| // SHADOWING: warning: system1/stdio.h included! | ||
| | ||
| /// Check that the diagnostic is only performed once in MSVC compatibility mode. | ||
| // RUN: %clang_cc1 -fms-compatibility -Wshadow-header -Eonly %t/t.c 2>&1 | FileCheck %s --check-prefix=SHADOWING-MS | ||
| | ||
| // SHADOWING-MS: {{.*}} warning: multiple candidates for header 't3.h' found; directory '{{.*}}foo' chosen, ignoring others including '{{.*}}' [-Wshadow-header] | ||
| // SHADOWING-MS-NOT: {{.*}} warning: multiple candidates for header 't3.h' found; directory '{{.*}}' chosen, ignoring others including '{{.*}}foo' [-Wshadow-header] | ||
| // SHADOWING-MS: warning: Found foo/t3.h. | ||
| | ||
| //--- main.c | ||
| #include "header.h" | ||
| #include <stdio.h> | ||
| | ||
| //--- include1/header.h | ||
| #warning include1/header.h included! | ||
| #include_next "header.h" | ||
| | ||
| //--- include2/header.h | ||
| #warning include2/header.h included! | ||
| | ||
| //--- system1/stdio.h | ||
| #warning system1/stdio.h included! | ||
| | ||
| //--- system2/stdio.h | ||
| #warning system2/stdio.h included! | ||
| | ||
| | ||
| /// Used to test when running in MSVC compatibility | ||
| //--- t.c | ||
| #include "foo/t1.h" | ||
| | ||
| //--- foo/t1.h | ||
| #include "bar/t2.h" | ||
| | ||
| //--- foo/bar/t2.h | ||
| #include "t3.h" | ||
| | ||
| //--- foo/t3.h | ||
| #warning Found foo/t3.h. | ||
| | ||
| //--- t3.h | ||
| #warning Found t3.h. |
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.