-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[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
Changes from all commits
9165d60
17b1860
9eeea3f
ddc6bf9
2993a63
b03c34f
1228f5c
14ac904
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// This test checks that a module map with a textual header can be marked as | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. (And thanks for the extended test case!) |
||
// 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 |
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.
I'd consider placing this at the end of HandleHeaderIncludeOrImport rather than here:
Concretely I don't see a case where this doesn't work though, up to you.
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.
I agree, I wanted to colocate this with call to
Preprocessor::markIncluded()
. If we find a better way of doing things, we can move both of them.