-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang][modules] Only modulemaps of included textual headers are affecting #89729
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
sam-mccall
wants to merge
2
commits into
llvm:main
Choose a base branch
from
sam-mccall:textual-non-affecting
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.
Open
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
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
47 changes: 47 additions & 0 deletions
47
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,47 @@ | ||
// 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 | ||
|
||
//--- X.modulemap | ||
module X { textual header "X.h" } | ||
//--- X.h | ||
typedef int X_int; | ||
|
||
//--- Y.modulemap | ||
module Y { textual header "Y.h" } | ||
//--- Y.h | ||
typedef int Y_int; | ||
|
||
//--- A.modulemap | ||
module A { header "A.h" export * } | ||
//--- A.h | ||
#include "X.h" | ||
|
||
// RUN: %clang_cc1 -fmodules -emit-module %t/A.modulemap -fmodule-name=A -o %t/A0.pcm \ | ||
// RUN: -fmodule-map-file=%t/X.modulemap | ||
// RUN: %clang_cc1 -fsyntax-only -module-file-info %t/A0.pcm | FileCheck %s --check-prefix=A0 --implicit-check-not=Y.modulemap | ||
// A0: Input file: {{.*}}/X.modulemap | ||
|
||
// RUN: %clang_cc1 -fmodules -emit-module %t/A.modulemap -fmodule-name=A -o %t/A1.pcm \ | ||
// RUN: -fmodule-map-file=%t/X.modulemap -fmodule-map-file=%t/Y.modulemap | ||
// RUN: %clang_cc1 -fsyntax-only -module-file-info %t/A0.pcm | FileCheck %s --check-prefix=A1 \ | ||
// RUN: --implicit-check-not=Y.modulemap | ||
// A1: Input file: {{.*}}/X.modulemap | ||
|
||
// RUN: diff %t/A0.pcm %t/A1.pcm | ||
|
||
//--- B.modulemap | ||
module B { header "B.h" export * } | ||
//--- B.h | ||
#include "A.h" | ||
typedef X_int B_int; | ||
|
||
// RUN: %clang_cc1 -fmodules -emit-module %t/B.modulemap -fmodule-name=B -o %t/B.pcm \ | ||
// RUN: -fmodule-file=A=%t/A0.pcm \ | ||
// RUN: -fmodule-map-file=%t/A.modulemap -fmodule-map-file=%t/X.modulemap -fmodule-map-file=%t/Y.modulemap | ||
// RUN: %clang_cc1 -fsyntax-only -module-file-info %t/B.pcm | FileCheck %s --check-prefix=B \ | ||
// RUN: --implicit-check-not=X.modulemap --implicit-check-not=Y.modulemap | ||
// B: Input file: {{.*}}/B.modulemap | ||
|
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.
The documentation for
isCompilingModuleHeader
says:To me this means this should set only for headers that semantically belong to the current module, not headers that happen to be compiled with it due to being textual.
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.
Oops, I meant to alter that description in this patch, it seems that change got lost.
At this point,
isCompilingModuleHeader
is used only for this "is affecting" check, and for a heuristic related to translating#include
into#import
. The latter only cares about modular headers, so it seems reasonable to change the semantics for textual headers to something more useful. (But I do need to be careful we're only setting this for textual modular headers).