Skip to content

Commit a6ebd30

Browse files
committed
[modules] Allow to validate system headers less often with -fmodules-validate-once-per-build-session.
Make flags `-fmodules-validate-system-headers` and `-fmodules-validate-once-per-build-session` orthogonal, so they have their own independent responsibilities - if system headers should be validated and how often. rdar://87988889 Differential Revision: https://reviews.llvm.org/D135232
1 parent 86771d0 commit a6ebd30

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

clang/lib/Serialization/ASTReader.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2639,12 +2639,11 @@ ASTReader::ReadControlBlock(ModuleFile &F,
26392639
// so we verify all input files. Otherwise, verify only user input
26402640
// files.
26412641

2642-
unsigned N = NumUserInputs;
2643-
if (ValidateSystemInputs ||
2644-
(HSOpts.ModulesValidateOncePerBuildSession &&
2645-
F.InputFilesValidationTimestamp <= HSOpts.BuildSessionTimestamp &&
2646-
F.Kind == MK_ImplicitModule))
2647-
N = NumInputs;
2642+
unsigned N = ValidateSystemInputs ? NumInputs : NumUserInputs;
2643+
if (HSOpts.ModulesValidateOncePerBuildSession &&
2644+
F.InputFilesValidationTimestamp > HSOpts.BuildSessionTimestamp &&
2645+
F.Kind == MK_ImplicitModule)
2646+
N = NumUserInputs;
26482647

26492648
for (unsigned I = 0; I < N; ++I) {
26502649
InputFile IF = getInputFile(F, I+1, Complain);

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
// ===
1919
// Compile the module.
20-
// 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
21-
// 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
20+
// RUN: %clang_cc1 -cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -isystem %t/Inputs -fmodules-validate-system-headers -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s
21+
// RUN: %clang_cc1 -cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/modules-cache-user -fsyntax-only -I %t/Inputs -fmodules-validate-system-headers -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s
2222
// RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp
2323
// RUN: ls -R %t/modules-cache | grep Bar.pcm.timestamp
2424
// RUN: ls -R %t/modules-cache-user | grep Foo.pcm.timestamp
@@ -30,8 +30,8 @@
3030

3131
// ===
3232
// Use it, and make sure that we did not recompile it.
33-
// 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
34-
// 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
33+
// RUN: %clang_cc1 -cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -isystem %t/Inputs -fmodules-validate-system-headers -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s
34+
// RUN: %clang_cc1 -cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/modules-cache-user -fsyntax-only -I %t/Inputs -fmodules-validate-system-headers -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s
3535
// RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp
3636
// RUN: ls -R %t/modules-cache | grep Bar.pcm.timestamp
3737
// RUN: ls -R %t/modules-cache-user | grep Foo.pcm.timestamp
@@ -54,8 +54,8 @@
5454
// ===
5555
// Use the module, and make sure that we did not recompile it if foo.h or
5656
// module.map are system files, even though the sources changed.
57-
// 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
58-
// 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
57+
// RUN: %clang_cc1 -cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -isystem %t/Inputs -fmodules-validate-system-headers -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s
58+
// RUN: %clang_cc1 -cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/modules-cache-user -fsyntax-only -I %t/Inputs -fmodules-validate-system-headers -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s
5959
// RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp
6060
// RUN: ls -R %t/modules-cache | grep Bar.pcm.timestamp
6161
// RUN: ls -R %t/modules-cache-user | grep Foo.pcm.timestamp
@@ -73,7 +73,7 @@
7373

7474
// ===
7575
// Recompile the module if the today's date is before 01 January 2100.
76-
// 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
76+
// RUN: %clang_cc1 -cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -isystem %t/Inputs -fmodules-validate-system-headers -fbuild-session-timestamp=4102441200 -fmodules-validate-once-per-build-session %s
7777
// RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp
7878
// RUN: ls -R %t/modules-cache | grep Bar.pcm.timestamp
7979
// RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm

clang/test/Modules/validate-system-headers.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
// RUN: %clang_cc1 -isystem %t/Inputs/usr/include -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session
3535
// RUN: diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved
3636

37-
// Now add -fmodules-validate-system-headers and rebuild
37+
// Now add -fmodules-validate-system-headers and rebuild. No recompilation due to -fmodules-validate-once-per-build-session
3838
// RUN: %clang_cc1 -isystem %t/Inputs/usr/include -fmodules -fimplicit-module-maps -fmodules-validate-system-headers -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session
39-
// RUN: not diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved
39+
// RUN: diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved
4040

4141
@import Foo;

0 commit comments

Comments
 (0)