xref: /minix3/external/bsd/llvm/dist/clang/test/Modules/validate-system-headers.m (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc// RUN: rm -rf %t/ModuleCache
2*0a6a1f1dSLionel Sambuc// RUN: mkdir -p %t/Inputs/usr/include
3*0a6a1f1dSLionel Sambuc// RUN: touch %t/Inputs/usr/include/foo.h
4*0a6a1f1dSLionel Sambuc// RUN: echo 'module Foo [system] { header "foo.h" }' > %t/Inputs/usr/include/module.map
5*0a6a1f1dSLionel Sambuc
6*0a6a1f1dSLionel Sambuc////
7*0a6a1f1dSLionel Sambuc// Build a module using a system header
8*0a6a1f1dSLionel Sambuc// RUN: %clang_cc1 -isystem %t/Inputs/usr/include -fmodules -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s
9*0a6a1f1dSLionel Sambuc// RUN: cp %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved
10*0a6a1f1dSLionel Sambuc
11*0a6a1f1dSLionel Sambuc////
12*0a6a1f1dSLionel Sambuc// Modify the system header, and confirm that we don't notice without -fmodules-validate-system-headers.
13*0a6a1f1dSLionel Sambuc// The pcm file in the cache should fail to validate.
14*0a6a1f1dSLionel Sambuc// RUN: echo ' ' >> %t/Inputs/usr/include/foo.h
15*0a6a1f1dSLionel Sambuc// RUN: %clang_cc1 -isystem %t/Inputs/usr/include -fmodules -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s
16*0a6a1f1dSLionel Sambuc// RUN: diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved
17*0a6a1f1dSLionel Sambuc
18*0a6a1f1dSLionel Sambuc////
19*0a6a1f1dSLionel Sambuc// Now make sure we rebuild the module when -fmodules-validate-system-headers is set.
20*0a6a1f1dSLionel Sambuc// RUN: %clang_cc1 -isystem %t/Inputs/usr/include -fmodules -fmodules-validate-system-headers -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s
21*0a6a1f1dSLionel Sambuc// RUN: not diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved
22*0a6a1f1dSLionel Sambuc
23*0a6a1f1dSLionel Sambuc
24*0a6a1f1dSLionel Sambuc////
25*0a6a1f1dSLionel Sambuc// This should override -fmodules-validate-once-per-build-session
26*0a6a1f1dSLionel Sambuc// RUN: cp %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved
27*0a6a1f1dSLionel Sambuc// RUN: %clang_cc1 -isystem %t/Inputs/usr/include -fmodules -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
28*0a6a1f1dSLionel Sambuc// RUN: diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved
29*0a6a1f1dSLionel Sambuc
30*0a6a1f1dSLionel Sambuc// Modify the system header...
31*0a6a1f1dSLionel Sambuc// RUN: echo ' ' >> %t/Inputs/usr/include/foo.h
32*0a6a1f1dSLionel Sambuc
33*0a6a1f1dSLionel Sambuc// Don't recompile due to -fmodules-validate-once-per-build-session
34*0a6a1f1dSLionel Sambuc// RUN: %clang_cc1 -isystem %t/Inputs/usr/include -fmodules -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
35*0a6a1f1dSLionel Sambuc// RUN: diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved
36*0a6a1f1dSLionel Sambuc
37*0a6a1f1dSLionel Sambuc// Now add -fmodules-validate-system-headers and rebuild
38*0a6a1f1dSLionel Sambuc// RUN: %clang_cc1 -isystem %t/Inputs/usr/include -fmodules -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*0a6a1f1dSLionel Sambuc// RUN: not diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved
40*0a6a1f1dSLionel Sambuc
41*0a6a1f1dSLionel Sambuc@import Foo;
42