110 lines · c
1// RUN: rm -rf %t.pch %t.ll
2// RUN: %clang -x c-header %S/Inputs/ignored-pch.h -o %t.pch
3// RUN: %clang -S -emit-llvm %s -include-pch %t.pch -o %t.ll
4// RUN: ls %t.pch
5// RUN: ls %t.ll
6
7// RUN: rm -rf %t.pch %t.ll
8// RUN: %clang -x c-header %S/Inputs/ignored-pch.h -o %t.pch
9// RUN: %clang %s -emit-ast -include-pch %t.pch -o %t.ll
10// RUN: ls %t.pch
11// RUN: ls %t.ll
12
13// Check that -ignore-pch causes -emit-pch and -include-pch options to be ignored.
14// RUN: rm -rf %t.pch %t.ll
15// RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -o %t.pch
16// RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -o %t.ll
17// RUN: not ls %t.pch
18// RUN: ls %t.ll
19
20// RUN: rm -rf %t.pch %t.ll
21// RUN: %clang -emit-ast %s -include-pch %t.pch -ignore-pch -o %t.ll
22// RUN: not ls %t.ll
23
24// Check that -ignore-pch works for multiple PCH related options.
25// Test with -building-pch-with-obj.
26// RUN: rm -rf %t.pch %t.ll
27// RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -Xclang -building-pch-with-obj -o %t.pch
28// RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -Xclang -building-pch-with-obj -o %t.ll
29// RUN: not ls %t.pch
30// RUN: ls %t.ll
31
32// Test with -fallow-pch-with-compiler-errors.
33// RUN: rm -rf %t.pch %t.ll
34// RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -Xclang -fallow-pch-with-compiler-errors -o %t.pch
35// RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -Xclang -fallow-pch-with-compiler-errors -o %t.ll
36// RUN: not ls %t.pch
37// RUN: ls %t.ll
38
39// Test with -fallow-pch-with-different-modules-cache-path.
40// RUN: rm -rf %t.pch %t.ll
41// RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -Xclang -fallow-pch-with-different-modules-cache-path -o %t.pch
42// RUN: %clang -S -emit-llvm %s -ignore-pch -include-pch %t.pch -Xclang -fallow-pch-with-different-modules-cache-path -o %t.ll
43// RUN: not ls %t.pch
44// RUN: ls %t.ll
45
46// Test with -fpch-codegen.
47// RUN: rm -rf %t.pch %t.ll
48// RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -fpch-codegen -o %t.pch
49// RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -fpch-codegen -o %t.ll
50// RUN: not ls %t.pch
51// RUN: ls %t.ll
52
53// Test with -fpch-debuginfo.
54// RUN: rm -rf %t.pch %t.ll
55// RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -fpch-debuginfo -o %t.pch
56// RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -fpch-debuginfo -o %t.ll
57// RUN: not ls %t.pch
58// RUN: ls %t.ll
59
60// Test with -fpch-instantiate-templates.
61// RUN: rm -rf %t.pch %t.ll
62// RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -fpch-instantiate-templates -o %t.pch
63// RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -fpch-instantiate-templates -o %t.ll
64// RUN: not ls %t.pch
65// RUN: ls %t.ll
66
67// Test with -fno-pch-timestamp.
68// RUN: rm -rf %t.pch %t.ll
69// RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -Xclang -fno-pch-timestamp -o %t.pch
70// RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -Xclang -fno-pch-timestamp -o %t.ll
71// RUN: not ls %t.pch
72// RUN: ls %t.ll
73
74// Test with -fno-validate-pch.
75// RUN: rm -rf %t.pch %t.ll
76// RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -Xclang -fno-validate-pch -o %t.pch
77// RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -Xclang -fno-validate-pch -o %t.ll
78// RUN: not ls %t.pch
79// RUN: ls %t.ll
80
81// Test with -relocatable-pch.
82// RUN: rm -rf %t.pch %t.ll
83// RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -relocatable-pch -o %t.pch
84// RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -relocatable-pch -o %t.ll
85// RUN: not ls %t.pch
86// RUN: ls %t.ll
87
88// Test with -pch-through-hdrstop-create/-pch-through-hdrstop-use
89// RUN: rm -rf %t.pch %t.ll
90// RUN: %clang -x c-header %S/Inputs/ignored-pch.h -ignore-pch -Xclang -pch-through-hdrstop-create -o %t.pch
91// RUN: %clang -S -emit-llvm %s -include-pch %t.pch -ignore-pch -Xclang -pch-through-hdrstop-use -o %t.ll
92// RUN: not ls %t.pch
93// RUN: ls %t.ll
94
95
96// Test with AST dump output:
97// RUN: rm -rf %t.pch %t.ll
98// RUN: %clang -x c-header %S/Inputs/ignored-pch.h -o %t.pch
99// RUN: %clang %s -include-pch %t.pch -Xclang -ast-dump-all -c | FileCheck --check-prefix=CHECK-AST-PCH %s
100// RUN: %clang %s -include-pch %t.pch -ignore-pch -Xclang -ast-dump-all -c | FileCheck --check-prefix=CHECK-AST %s
101
102// CHECK-AST-PCH: <undeserialized declarations>
103// CHECK-AST-NOT: <undeserialized declarations>
104
105#pragma hdrstop
106#include "Inputs/ignored-pch.h"
107int main() {
108 return f();
109}
110