summaryrefslogtreecommitdiff
path: root/test/Modules/validate-system-headers.m
blob: d05fae777bb15c1f0a883a135a0e615b70a62fa6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// RUN: rm -rf %t/ModuleCache
// RUN: mkdir -p %t/Inputs/usr/include
// RUN: touch %t/Inputs/usr/include/foo.h
// RUN: echo 'module Foo [system] { header "foo.h" }' > %t/Inputs/usr/include/module.map

////
// Build a module using a system header
// 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
// RUN: cp %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved

////
// Modify the system header, and confirm that we don't notice without -fmodules-validate-system-headers.
// The pcm file in the cache should fail to validate.
// RUN: echo ' ' >> %t/Inputs/usr/include/foo.h
// 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
// RUN: diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved

////
// Now make sure we rebuild the module when -fmodules-validate-system-headers is set.
// 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
// RUN: not diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved


////
// This should override -fmodules-validate-once-per-build-session
// RUN: cp %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved
// 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
// RUN: diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved

// Modify the system header...
// RUN: echo ' ' >> %t/Inputs/usr/include/foo.h

// Don't recompile due to -fmodules-validate-once-per-build-session
// 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
// RUN: diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved

// Now add -fmodules-validate-system-headers and rebuild
// 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
// RUN: not diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved

@import Foo;