-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[clang][modules] Allow module maps with textual headers to be non-affecting #89441
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
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9165d60
[clang][modules] Allow module map files with textual header be non-af…
jansvoboda11 17b1860
[clang][modules] Mark 'use'd modules as affecting
jansvoboda11 9eeea3f
[clang][modules] Do consider module maps of included textual headers …
jansvoboda11 ddc6bf9
Reject all non-included headers from that are !isCompilingModuleHeade…
jansvoboda11 2993a63
Don't add modules for textual headers to `ModulesToProcess`
jansvoboda11 b03c34f
**Locally** included
jansvoboda11 1228f5c
Fix test on Windows
jansvoboda11 14ac904
Split out HFI conditions
jansvoboda11 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
26 changes: 26 additions & 0 deletions
26
clang/test/Modules/prune-non-affecting-module-map-files-textual.c
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,26 @@ | ||
// This test checks that a module map with a textual header can be marked as | ||
// non-affecting. | ||
|
||
// RUN: rm -rf %t && mkdir %t | ||
// RUN: split-file %s %t | ||
|
||
//--- A.modulemap | ||
module A { textual header "A.h" } | ||
//--- B.modulemap | ||
module B { header "B.h" export * } | ||
//--- A.h | ||
typedef int A_int; | ||
//--- B.h | ||
#include "A.h" | ||
typedef A_int B_int; | ||
|
||
// RUN: %clang_cc1 -fmodules -emit-module %t/A.modulemap -fmodule-name=A -o %t/A.pcm \ | ||
// RUN: -fmodule-map-file=%t/A.modulemap -fmodule-map-file=%t/B.modulemap | ||
|
||
// RUN: %clang_cc1 -fmodules -emit-module %t/B.modulemap -fmodule-name=B -o %t/B0.pcm \ | ||
// RUN: -fmodule-map-file=%t/A.modulemap -fmodule-map-file=%t/B.modulemap -fmodule-file=%t/A.pcm | ||
|
||
// RUN: %clang_cc1 -fmodules -emit-module %t/B.modulemap -fmodule-name=B -o %t/B1.pcm \ | ||
// RUN: -fmodule-map-file=%t/B.modulemap -fmodule-file=%t/A.pcm | ||
|
||
// RUN: diff %t/B0.pcm %t/B1.pcm |
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.
This is a useful test, I think there are a couple of other affecting-ness properties that are important to test:
I tried to cover these in https://github.com/llvm/llvm-project/pull/89729/files#diff-2eed05f9a85bc5a79b9651ee0f23e5f1494e94a2f32e093847aa6dae5ce5d839 - it might be nice to add these as a second test here (I can do it as a followup if you prefer)
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.
This patch unfortunately doesn't pass that test (on line 44) due to this: when computing affecting module maps for B, "A.h" makes it through the
HFI
filter, module A is added toModulesToProcess
and the module map for its import X is considered affecting.I tried splitting up that logic so that we consider imports and undeclared uses only of the current module and its submodules. That doesn't work either, because
PP.alreadyIncluded("X.h")
returnstrue
, since it checks the global (cross-module) state, not the local state. This might be possible with #71117. Until then, I think we need some "has this been included locally" state that's local to the current TU. Maybe that can live inHeaderFileInfo
as per your patch, or as aPreprocessor
state.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.
Should work with b03c34f.
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.
(And thanks for the extended test case!)