-
Notifications
You must be signed in to change notification settings - Fork 14.2k
[clang][modules] Stop eagerly reading files with diagnostic pragmas #87442
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
Merged
jansvoboda11
merged 1 commit into
llvm:main
from
jansvoboda11:pragma-diagnostic-mappings-side-effect
Apr 10, 2024
Merged
Changes from all commits
Commits
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// This test demonstrates how -fmodule-map-file-home-is-cwd with -fmodules-embed-all-files | ||
// extend the importer search paths by relying on the side effects of pragma diagnostic | ||
// mappings deserialization. | ||
|
||
// RUN: rm -rf %t | ||
// RUN: split-file %s %t | ||
|
||
//--- dir1/a.modulemap | ||
module a { header "a.h" } | ||
//--- dir1/a.h | ||
#include "search.h" | ||
// The first compilation is configured such that -I search does contain the search.h header. | ||
//--- dir1/search/search.h | ||
#pragma clang diagnostic push | ||
#pragma clang diagnostic ignored "-Wparentheses" | ||
#pragma clang diagnostic pop | ||
// RUN: cd %t/dir1 && %clang_cc1 -fmodules -I search \ | ||
// RUN: -emit-module -fmodule-name=a a.modulemap -o %t/a.pcm \ | ||
// RUN: -fmodules-embed-all-files -fmodule-map-file-home-is-cwd | ||
|
||
//--- dir2/b.modulemap | ||
module b { header "b.h" } | ||
//--- dir2/b.h | ||
#include "search.h" // expected-error{{'search.h' file not found}} | ||
// The second compilation is configured such that -I search is an empty directory. | ||
// However, since b.pcm simply embeds the headers as "search/search.h", this compilation | ||
// ends up seeing it too. This relies solely on ASTReader::ReadPragmaDiagnosticMappings() | ||
// eagerly reading the corresponding INPUT_FILE record before header search happens. | ||
// Removing the eager deserialization makes this header invisible and so does removing | ||
// the pragma directives. | ||
// RUN: mkdir %t/dir2/search | ||
// RUN: cd %t/dir2 && %clang_cc1 -fmodules -I search \ | ||
// RUN: -emit-module -fmodule-name=b b.modulemap -o %t/b.pcm \ | ||
// RUN: -fmodule-file=%t/a.pcm -verify |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexfh This is basically minimized reproducer you provided in https://reviews.llvm.org/D137213. I don't think it's reasonable to expect this to work.