Skip to content

Commit acb803e

Browse files
committed
Validate user headers even if -fmodules-validate-once-per-build-session
is enabled. Unlike system headers, we want to be more careful about modifications to user headers, because it's still easy to edit a header while you're building. llvm-svn: 221634
1 parent 45f4f8b commit acb803e

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

clang/lib/Serialization/ASTReader.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2302,9 +2302,7 @@ ASTReader::ReadControlBlock(ModuleFile &F,
23022302

23032303
// All user input files reside at the index range [0, NumUserInputs), and
23042304
// system input files reside at [NumUserInputs, NumInputs).
2305-
if (!DisableValidation &&
2306-
(ValidateSystemInputs || !HSOpts.ModulesValidateOncePerBuildSession ||
2307-
F.InputFilesValidationTimestamp <= HSOpts.BuildSessionTimestamp)) {
2305+
if (!DisableValidation) {
23082306
bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0;
23092307

23102308
// If we are reading a module, we will create a verification timestamp,
@@ -2314,6 +2312,7 @@ ASTReader::ReadControlBlock(ModuleFile &F,
23142312
unsigned N = NumUserInputs;
23152313
if (ValidateSystemInputs ||
23162314
(HSOpts.ModulesValidateOncePerBuildSession &&
2315+
F.InputFilesValidationTimestamp <= HSOpts.BuildSessionTimestamp &&
23172316
F.Kind == MK_ImplicitModule))
23182317
N = NumInputs;
23192318

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

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,53 @@
66
// RUN: mkdir -p %t/modules-to-compare
77

88
// ===
9-
// Create a module with system headers.
9+
// Create a module. We will use -I or -isystem to determine whether to treat
10+
// foo.h as a system header.
1011
// RUN: echo 'void meow(void);' > %t/Inputs/foo.h
11-
// RUN: echo 'module Foo [system] { header "foo.h" }' > %t/Inputs/module.map
12+
// RUN: echo 'module Foo { header "foo.h" }' > %t/Inputs/module.map
1213

1314
// ===
1415
// Compile the module.
15-
// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s
16+
// RUN: %clang_cc1 -cc1 -fmodules -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
17+
// RUN: %clang_cc1 -cc1 -fmodules -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
1618
// RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp
19+
// RUN: ls -R %t/modules-cache-user | grep Foo.pcm.timestamp
1720
// RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-before.pcm
21+
// RUN: cp %t/modules-cache-user/Foo.pcm %t/modules-to-compare/Foo-before-user.pcm
1822

1923
// ===
2024
// Use it, and make sure that we did not recompile it.
21-
// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s
25+
// RUN: %clang_cc1 -cc1 -fmodules -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
26+
// RUN: %clang_cc1 -cc1 -fmodules -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
2227
// RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp
28+
// RUN: ls -R %t/modules-cache-user | grep Foo.pcm.timestamp
2329
// RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm
30+
// RUN: cp %t/modules-cache-user/Foo.pcm %t/modules-to-compare/Foo-after-user.pcm
2431

2532
// RUN: diff %t/modules-to-compare/Foo-before.pcm %t/modules-to-compare/Foo-after.pcm
33+
// RUN: diff %t/modules-to-compare/Foo-before-user.pcm %t/modules-to-compare/Foo-after-user.pcm
2634

2735
// ===
2836
// Change the sources.
2937
// RUN: echo 'void meow2(void);' > %t/Inputs/foo.h
3038

3139
// ===
32-
// Use the module, and make sure that we did not recompile it, even though the sources changed.
33-
// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session %s
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.
42+
// RUN: %clang_cc1 -cc1 -fmodules -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
43+
// RUN: %clang_cc1 -cc1 -fmodules -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
3444
// RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp
45+
// RUN: ls -R %t/modules-cache-user | grep Foo.pcm.timestamp
3546
// RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm
47+
// RUN: cp %t/modules-cache-user/Foo.pcm %t/modules-to-compare/Foo-after-user.pcm
3648

3749
// RUN: diff %t/modules-to-compare/Foo-before.pcm %t/modules-to-compare/Foo-after.pcm
50+
// When foo.h is a user header, we will always validate it.
51+
// RUN: not diff %t/modules-to-compare/Foo-before-user.pcm %t/modules-to-compare/Foo-after-user.pcm
3852

3953
// ===
4054
// Recompile the module if the today's date is before 01 January 2030.
41-
// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -I %t/Inputs -fbuild-session-timestamp=1893456000 -fmodules-validate-once-per-build-session %s
55+
// RUN: %clang_cc1 -cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -fsyntax-only -isystem %t/Inputs -fbuild-session-timestamp=1893456000 -fmodules-validate-once-per-build-session %s
4256
// RUN: ls -R %t/modules-cache | grep Foo.pcm.timestamp
4357
// RUN: cp %t/modules-cache/Foo.pcm %t/modules-to-compare/Foo-after.pcm
4458

0 commit comments

Comments
 (0)