Skip to content

Commit 4b5f240

Browse files
committed
[modules] Make a module map referenced by a system map a system one too.
Mimic the behavior of including headers where a system includer makes an includee a system header too. rdar://84049469 Differential Revision: https://reviews.llvm.org/D111476 (cherry picked from commit d0e7bdc208491fd5d4245878c1ec2962694e2baa)
1 parent bd9eb1b commit 4b5f240

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

clang/lib/Lex/ModuleMap.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2186,7 +2186,7 @@ void ModuleMapParser::parseExternModuleDecl() {
21862186
}
21872187
if (auto File = SourceMgr.getFileManager().getFile(FileNameRef))
21882188
Map.parseModuleMapFile(
2189-
*File, /*IsSystem=*/false,
2189+
*File, IsSystem,
21902190
Map.HeaderInfo.getHeaderSearchOpts().ModuleMapFileHomeIsCwd
21912191
? Directory
21922192
: (*File)->getDir(),

clang/test/Modules/fmodules-validate-once-per-build-session.c

+26-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "foo.h"
2+
#include "bar.h"
23

34
// Clear the module cache.
45
// RUN: rm -rf %t
@@ -9,51 +10,74 @@
910
// Create a module. We will use -I or -isystem to determine whether to treat
1011
// foo.h as a system header.
1112
// RUN: echo 'void meow(void);' > %t/Inputs/foo.h
13+
// RUN: echo 'void woof(void);' > %t/Inputs/bar.h
1214
// RUN: echo 'module Foo { header "foo.h" }' > %t/Inputs/module.map
15+
// RUN: echo 'extern module Bar "bar.modulemap"' >> %t/Inputs/module.map
16+
// RUN: echo 'module Bar { header "bar.h" }' > %t/Inputs/bar.modulemap
1317

1418
// ===
1519
// Compile the module.
1620
// RUN: %clang_cc1 -cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -isystem %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s
1721
// RUN: %clang_cc1 -cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/modules-cache-user -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s
1822
// RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp
23+
// RUN: ls -R %t/modules-cache | grep Bar.pcm.timestamp
1924
// RUN: ls -R %t/modules-cache-user | grep Foo.pcm.timestamp
25+
// RUN: ls -R %t/modules-cache-user | grep Bar.pcm.timestamp
2026
// RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-before.pcm
27+
// RUN: cp %t/modules-cache/Bar.pcm %t/modules-to-compare/Bar-before.pcm
2128
// RUN: cp %t/modules-cache-user/Foo.pcm %t/modules-to-compare/Foo-before-user.pcm
29+
// RUN: cp %t/modules-cache-user/Bar.pcm %t/modules-to-compare/Bar-before-user.pcm
2230

2331
// ===
2432
// Use it, and make sure that we did not recompile it.
2533
// RUN: %clang_cc1 -cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -isystem %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s
2634
// RUN: %clang_cc1 -cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/modules-cache-user -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s
2735
// RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp
36+
// RUN: ls -R %t/modules-cache | grep Bar.pcm.timestamp
2837
// RUN: ls -R %t/modules-cache-user | grep Foo.pcm.timestamp
38+
// RUN: ls -R %t/modules-cache-user | grep Bar.pcm.timestamp
2939
// RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm
40+
// RUN: cp %t/modules-cache/Bar.pcm %t/modules-to-compare/Bar-after.pcm
3041
// RUN: cp %t/modules-cache-user/Foo.pcm %t/modules-to-compare/Foo-after-user.pcm
42+
// RUN: cp %t/modules-cache-user/Bar.pcm %t/modules-to-compare/Bar-after-user.pcm
3143

3244
// RUN: diff %t/modules-to-compare/Foo-before.pcm %t/modules-to-compare/Foo-after.pcm
45+
// RUN: diff %t/modules-to-compare/Bar-before.pcm %t/modules-to-compare/Bar-after.pcm
3346
// RUN: diff %t/modules-to-compare/Foo-before-user.pcm %t/modules-to-compare/Foo-after-user.pcm
47+
// RUN: diff %t/modules-to-compare/Bar-before-user.pcm %t/modules-to-compare/Bar-after-user.pcm
3448

3549
// ===
3650
// Change the sources.
3751
// RUN: echo 'void meow2(void);' > %t/Inputs/foo.h
52+
// RUN: echo 'module Bar { header "bar.h" export * }' > %t/Inputs/bar.modulemap
3853

3954
// ===
40-
// Use the module, and make sure that we did not recompile it if foo.h is a
41-
// system header, even though the sources changed.
55+
// Use the module, and make sure that we did not recompile it if foo.h or
56+
// module.map are system files, even though the sources changed.
4257
// RUN: %clang_cc1 -cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -isystem %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s
4358
// RUN: %clang_cc1 -cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/modules-cache-user -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s
4459
// RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp
60+
// RUN: ls -R %t/modules-cache | grep Bar.pcm.timestamp
4561
// RUN: ls -R %t/modules-cache-user | grep Foo.pcm.timestamp
62+
// RUN: ls -R %t/modules-cache-user | grep Bar.pcm.timestamp
4663
// RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm
64+
// RUN: cp %t/modules-cache/Bar.pcm %t/modules-to-compare/Bar-after.pcm
4765
// RUN: cp %t/modules-cache-user/Foo.pcm %t/modules-to-compare/Foo-after-user.pcm
66+
// RUN: cp %t/modules-cache-user/Bar.pcm %t/modules-to-compare/Bar-after-user.pcm
4867

4968
// RUN: diff %t/modules-to-compare/Foo-before.pcm %t/modules-to-compare/Foo-after.pcm
69+
// RUN: diff %t/modules-to-compare/Bar-before.pcm %t/modules-to-compare/Bar-after.pcm
5070
// When foo.h is a user header, we will always validate it.
5171
// RUN: not diff %t/modules-to-compare/Foo-before-user.pcm %t/modules-to-compare/Foo-after-user.pcm
72+
// RUN: not diff %t/modules-to-compare/Bar-before-user.pcm %t/modules-to-compare/Bar-after-user.pcm
5273

5374
// ===
5475
// Recompile the module if the today's date is before 01 January 2100.
5576
// RUN: %clang_cc1 -cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -isystem %t/Inputs -fbuild-session-timestamp=4102441200 -fmodules-validate-once-per-build-session %s
5677
// RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp
78+
// RUN: ls -R %t/modules-cache | grep Bar.pcm.timestamp
5779
// RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm
80+
// RUN: cp %t/modules-cache/Bar.pcm %t/modules-to-compare/Bar-after.pcm
5881

5982
// RUN: not diff %t/modules-to-compare/Foo-before.pcm %t/modules-to-compare/Foo-after.pcm
83+
// RUN: not diff %t/modules-to-compare/Bar-before.pcm %t/modules-to-compare/Bar-after.pcm

0 commit comments

Comments
 (0)