Clang Project

clang_source_code/test/Driver/cl-pch.c
1// REQUIRES: system-windows
2//
3// RUN: rm -rf %t
4// RUN: mkdir %t
5//
6// Note: %s and %S must be preceded by --, otherwise it may be interpreted as a
7// command-line option, e.g. on Mac where %s is commonly under /Users.
8
9// The main test for clang-cl pch handling is cl-pch.cpp.  This file only checks
10// a few things for .c inputs.
11
12// /Yc with a .c file should build a c pch file.
13// RUN: %clang_cl -Werror /Yc%S/Inputs/pchfile.h /FI%S/Inputs/pchfile.h /c /Fo%t/pchfile.obj /Fp%t/pchfile.pch -v -- %s 2>&1 \
14// RUN:   | FileCheck -check-prefix=CHECK-YC %s
15// CHECK-YC: cc1{{.* .*}}-emit-pch
16// CHECK-YC-SAME: -o
17// CHECK-YC-SAME: pchfile.pch
18// CHECK-YC-SAME: -x
19// CHECK-YC-SAME: c-header
20
21// But not if /TP changes the input language to C++.
22// RUN: %clang_cl /TP -Werror /Yc%S/Inputs/pchfile.h /FI%S/Inputs/pchfile.h /c /Fo%t/pchfile.obj /Fp%t/pchfile.pch -v -- %s 2>&1 \
23// RUN:   | FileCheck -check-prefix=CHECK-YCTP %s
24// CHECK-YCTP: cc1{{.* .*}}-emit-pch
25// CHECK-YCTP-SAME: -o
26// CHECK-YCTP-SAME: pchfile.pch
27// CHECK-YCTP-SAME: -x
28// CHECK-YCTP-SAME: c++-header
29
30// Except if a later /TC changes it back.
31// RUN: %clang_cl -Werror /Yc%S/Inputs/pchfile.h /FI%S/Inputs/pchfile.h /c /Fo%t/pchfile.obj /Fp%t/pchfile.pch -v -- %s 2>&1 \
32// RUN:   | FileCheck -check-prefix=CHECK-YCTPTC %s
33// CHECK-YCTPTC: cc1{{.* .*}}-emit-pch
34// CHECK-YCTPTC-SAME: -o
35// CHECK-YCTPTC-SAME: pchfile.pch
36// CHECK-YCTPTC-SAME: -x
37// CHECK-YCTPTC-SAME: c-header
38
39// Also check lower-case /Tp flag.
40// RUN: %clang_cl -Werror /Tp%s /Yc%S/Inputs/pchfile.h /FI%S/Inputs/pchfile.h /c /Fo%t/pchfile.obj /Fp%t/pchfile.pch -v 2>&1 \
41// RUN:   | FileCheck -check-prefix=CHECK-YCTp %s
42// CHECK-YCTp: cc1{{.* .*}}-emit-pch
43// CHECK-YCTp-SAME: -o
44// CHECK-YCTp-SAME: pchfile.pch
45// CHECK-YCTp-SAME: -x
46// CHECK-YCTp-SAME: c++-header
47