Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 1 | // Note: %s and %S must be preceded by --, otherwise it may be interpreted as a |
| 2 | // command-line option, e.g. on Mac where %s is commonly under /Users. |
| 3 | |
| 4 | // /Yc |
Nico Weber | 381ec2a | 2016-03-04 21:59:42 +0000 | [diff] [blame] | 5 | // RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \ |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 6 | // RUN: | FileCheck -check-prefix=CHECK-YC %s |
| 7 | // 1. Build .pch file. |
| 8 | // CHECK-YC: cc1 |
| 9 | // CHECK-YC: -emit-pch |
Hans Wennborg | 08c5a7b | 2018-06-25 13:23:49 +0000 | [diff] [blame] | 10 | // CHECK-YC: -building-pch-with-obj |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 11 | // CHECK-YC: -o |
| 12 | // CHECK-YC: pchfile.pch |
| 13 | // CHECK-YC: -x |
Richard Smith | dd4ad3d | 2016-08-30 19:06:26 +0000 | [diff] [blame] | 14 | // CHECK-YC: "c++-header" |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 15 | // 2. Use .pch file. |
| 16 | // CHECK-YC: cc1 |
| 17 | // CHECK-YC: -emit-obj |
Hans Wennborg | 08c5a7b | 2018-06-25 13:23:49 +0000 | [diff] [blame] | 18 | // CHECK-YC: -building-pch-with-obj |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 19 | // CHECK-YC: -include-pch |
| 20 | // CHECK-YC: pchfile.pch |
| 21 | |
| 22 | // /Yc /Fo |
| 23 | // /Fo overrides the .obj output filename, but not the .pch filename |
Nico Weber | 381ec2a | 2016-03-04 21:59:42 +0000 | [diff] [blame] | 24 | // RUN: %clang_cl -Werror /Fomyobj.obj /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \ |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 25 | // RUN: | FileCheck -check-prefix=CHECK-YCO %s |
| 26 | // 1. Build .pch file. |
| 27 | // CHECK-YCO: cc1 |
| 28 | // CHECK-YCO: -emit-pch |
Hans Wennborg | 08c5a7b | 2018-06-25 13:23:49 +0000 | [diff] [blame] | 29 | // CHECK-YCO: -building-pch-with-obj |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 30 | // CHECK-YCO: -o |
| 31 | // CHECK-YCO: pchfile.pch |
| 32 | // 2. Use .pch file. |
| 33 | // CHECK-YCO: cc1 |
| 34 | // CHECK-YCO: -emit-obj |
Hans Wennborg | 08c5a7b | 2018-06-25 13:23:49 +0000 | [diff] [blame] | 35 | // CHECK-YCO: -building-pch-with-obj |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 36 | // CHECK-YCO: -include-pch |
| 37 | // CHECK-YCO: pchfile.pch |
| 38 | // CHECK-YCO: -o |
| 39 | // CHECK-YCO: myobj.obj |
| 40 | |
| 41 | // /Yc /Y- |
| 42 | // /Y- disables pch generation |
Nico Weber | 381ec2a | 2016-03-04 21:59:42 +0000 | [diff] [blame] | 43 | // RUN: %clang_cl -Werror /Y- /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \ |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 44 | // RUN: | FileCheck -check-prefix=CHECK-YC-Y_ %s |
| 45 | // CHECK-YC-Y_-NOT: -emit-pch |
| 46 | // CHECK-YC-Y_-NOT: -include-pch |
| 47 | |
| 48 | // /Yu |
Nico Weber | 381ec2a | 2016-03-04 21:59:42 +0000 | [diff] [blame] | 49 | // RUN: %clang_cl -Werror /Yupchfile.h /FIpchfile.h /c -### -- %s 2>&1 \ |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 50 | // RUN: | FileCheck -check-prefix=CHECK-YU %s |
| 51 | // Use .pch file, but don't build it. |
| 52 | // CHECK-YU-NOT: -emit-pch |
Hans Wennborg | 08c5a7b | 2018-06-25 13:23:49 +0000 | [diff] [blame] | 53 | // CHECK-YU-NOT: -building-pch-with-obj |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 54 | // CHECK-YU: cc1 |
| 55 | // CHECK-YU: -emit-obj |
| 56 | // CHECK-YU: -include-pch |
| 57 | // CHECK-YU: pchfile.pch |
| 58 | |
| 59 | // /Yu /Y- |
Nico Weber | 381ec2a | 2016-03-04 21:59:42 +0000 | [diff] [blame] | 60 | // RUN: %clang_cl -Werror /Y- /Yupchfile.h /FIpchfile.h /c -### -- %s 2>&1 \ |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 61 | // RUN: | FileCheck -check-prefix=CHECK-YU-Y_ %s |
| 62 | // CHECK-YU-Y_-NOT: -emit-pch |
| 63 | // CHECK-YU-Y_-NOT: -include-pch |
| 64 | |
| 65 | // /Yc /Yu -- /Yc overrides /Yc if they both refer to the same file |
Nico Weber | 381ec2a | 2016-03-04 21:59:42 +0000 | [diff] [blame] | 66 | // RUN: %clang_cl -Werror /Ycpchfile.h /Yupchfile.h /FIpchfile.h /c -### -- %s 2>&1 \ |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 67 | // RUN: | FileCheck -check-prefix=CHECK-YC-YU %s |
| 68 | // 1. Build .pch file. |
| 69 | // CHECK-YC-YU: cc1 |
| 70 | // CHECK-YC-YU: -emit-pch |
Hans Wennborg | 08c5a7b | 2018-06-25 13:23:49 +0000 | [diff] [blame] | 71 | // CHECK-YC-YU: -building-pch-with-obj |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 72 | // CHECK-YC-YU: -o |
| 73 | // CHECK-YC-YU: pchfile.pch |
| 74 | // 2. Use .pch file. |
| 75 | // CHECK-YC-YU: cc1 |
| 76 | // CHECK-YC-YU: -emit-obj |
| 77 | // CHECK-YC-YU: -include-pch |
| 78 | // CHECK-YC-YU: pchfile.pch |
| 79 | |
| 80 | // If /Yc /Yu refer to different files, semantics are pretty wonky. Since this |
| 81 | // doesn't seem like something that's important in practice, just punt for now. |
Nico Weber | 381ec2a | 2016-03-04 21:59:42 +0000 | [diff] [blame] | 82 | // RUN: %clang_cl -Werror /Ycfoo1.h /Yufoo2.h /FIfoo1.h /FIfoo2.h /c -### -- %s 2>&1 \ |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 83 | // RUN: | FileCheck -check-prefix=CHECK-YC-YU-MISMATCH %s |
| 84 | // CHECK-YC-YU-MISMATCH: error: support for '/Yc' and '/Yu' with different filenames not implemented yet; flags ignored |
| 85 | |
| 86 | // Similarly, punt on /Yc with more than one input file. |
Nico Weber | 381ec2a | 2016-03-04 21:59:42 +0000 | [diff] [blame] | 87 | // RUN: %clang_cl -Werror /Ycfoo1.h /FIfoo1.h /c -### -- %s %s 2>&1 \ |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 88 | // RUN: | FileCheck -check-prefix=CHECK-YC-MULTIINPUT %s |
| 89 | // CHECK-YC-MULTIINPUT: error: support for '/Yc' with more than one source file not implemented yet; flag ignored |
| 90 | |
| 91 | // /Yc /Yu /Y- |
Nico Weber | 381ec2a | 2016-03-04 21:59:42 +0000 | [diff] [blame] | 92 | // RUN: %clang_cl -Werror /Ycpchfile.h /Yupchfile.h /FIpchfile.h /Y- /c -### -- %s 2>&1 \ |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 93 | // RUN: | FileCheck -check-prefix=CHECK-YC-YU-Y_ %s |
| 94 | // CHECK-YC-YU-Y_-NOT: -emit-pch |
| 95 | // CHECK-YC-YU-Y_-NOT: -include-pch |
| 96 | |
| 97 | // Test computation of pch filename in various cases. |
| 98 | |
| 99 | // /Yu /Fpout.pch => out.pch is filename |
Nico Weber | 381ec2a | 2016-03-04 21:59:42 +0000 | [diff] [blame] | 100 | // RUN: %clang_cl -Werror /Yupchfile.h /FIpchfile.h /Fpout.pch /c -### -- %s 2>&1 \ |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 101 | // RUN: | FileCheck -check-prefix=CHECK-YUFP1 %s |
| 102 | // Use .pch file, but don't build it. |
| 103 | // CHECK-YUFP1: -include-pch |
| 104 | // CHECK-YUFP1: out.pch |
| 105 | |
| 106 | // /Yu /Fpout => out.pch is filename (.pch gets added if no extension present) |
Nico Weber | 381ec2a | 2016-03-04 21:59:42 +0000 | [diff] [blame] | 107 | // RUN: %clang_cl -Werror /Yupchfile.h /FIpchfile.h /Fpout.pch /c -### -- %s 2>&1 \ |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 108 | // RUN: | FileCheck -check-prefix=CHECK-YUFP2 %s |
| 109 | // Use .pch file, but don't build it. |
| 110 | // CHECK-YUFP2: -include-pch |
| 111 | // CHECK-YUFP2: out.pch |
| 112 | |
| 113 | // /Yu /Fpout.bmp => out.bmp is filename (.pch not added when extension present) |
Nico Weber | 381ec2a | 2016-03-04 21:59:42 +0000 | [diff] [blame] | 114 | // RUN: %clang_cl -Werror /Yupchfile.h /FIpchfile.h /Fpout.bmp /c -### -- %s 2>&1 \ |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 115 | // RUN: | FileCheck -check-prefix=CHECK-YUFP3 %s |
| 116 | // Use .pch file, but don't build it. |
| 117 | // CHECK-YUFP3: -include-pch |
| 118 | // CHECK-YUFP3: out.bmp |
| 119 | |
| 120 | // /Yusub/dir.h => sub/dir.pch |
Nico Weber | 381ec2a | 2016-03-04 21:59:42 +0000 | [diff] [blame] | 121 | // RUN: %clang_cl -Werror /Yusub/pchfile.h /FIsub/pchfile.h /c -### -- %s 2>&1 \ |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 122 | // RUN: | FileCheck -check-prefix=CHECK-YUFP4 %s |
| 123 | // Use .pch file, but don't build it. |
| 124 | // CHECK-YUFP4: -include-pch |
| 125 | // CHECK-YUFP4: sub/pchfile.pch |
| 126 | |
| 127 | // /Yudir.h /Isub => dir.pch |
Nico Weber | 381ec2a | 2016-03-04 21:59:42 +0000 | [diff] [blame] | 128 | // RUN: %clang_cl -Werror /Yupchfile.h /FIpchfile.h /Isub /c -### -- %s 2>&1 \ |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 129 | // RUN: | FileCheck -check-prefix=CHECK-YUFP5 %s |
| 130 | // Use .pch file, but don't build it. |
| 131 | // CHECK-YUFP5: -include-pch |
| 132 | // CHECK-YUFP5: pchfile.pch |
| 133 | |
| 134 | // FIXME: /Fpdir: use dir/VCx0.pch when dir is directory, where x is major MSVS |
| 135 | // version in use. |
| 136 | |
| 137 | // Spot-check one use of /Fp with /Yc too, else trust the /Yu test cases above |
| 138 | // also all assume to /Yc. |
Nico Weber | 381ec2a | 2016-03-04 21:59:42 +0000 | [diff] [blame] | 139 | // RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /Fpsub/file.pch /c -### -- %s 2>&1 \ |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 140 | // RUN: | FileCheck -check-prefix=CHECK-YCFP %s |
| 141 | // 1. Build .pch file. |
| 142 | // CHECK-YCFP: cc1 |
| 143 | // CHECK-YCFP: -emit-pch |
| 144 | // CHECK-YCFP: -o |
| 145 | // CHECK-YCFP: sub/file.pch |
| 146 | // 2. Use .pch file. |
| 147 | // CHECK-YCFP: cc1 |
| 148 | // CHECK-YCFP: -emit-obj |
| 149 | // CHECK-YCFP: -include-pch |
| 150 | // CHECK-YCFP: sub/file.pch |
| 151 | |
| 152 | // /Ycfoo2.h /FIfoo1.h /FIfoo2.h /FIfoo3.h |
| 153 | // => foo1 and foo2 go into pch, foo3 into main compilation |
| 154 | // /Yc |
Nico Weber | 381ec2a | 2016-03-04 21:59:42 +0000 | [diff] [blame] | 155 | // RUN: %clang_cl -Werror /Ycfoo2.h /FIfoo1.h /FIfoo2.h /FIfoo3.h /c -### -- %s 2>&1 \ |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 156 | // RUN: | FileCheck -check-prefix=CHECK-YCFIFIFI %s |
| 157 | // 1. Build .pch file: Includes foo1.h (but NOT foo3.h) and compiles foo2.h |
| 158 | // CHECK-YCFIFIFI: cc1 |
| 159 | // CHECK-YCFIFIFI: -emit-pch |
Erich Keane | 76675de | 2018-07-05 17:22:13 +0000 | [diff] [blame] | 160 | // CHECK-YCFIFIFI: -pch-through-header=foo2.h |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 161 | // CHECK-YCFIFIFI: -include |
| 162 | // CHECK-YCFIFIFI: foo1.h |
Erich Keane | 76675de | 2018-07-05 17:22:13 +0000 | [diff] [blame] | 163 | // CHECK-YCFIFIFI: -include |
| 164 | // CHECK-YCFIFIFI: foo2.h |
| 165 | // CHECK-YCFIFIFI: -include |
| 166 | // CHECK-YCFIFIFI: foo3.h |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 167 | // CHECK-YCFIFIFI: -o |
| 168 | // CHECK-YCFIFIFI: foo2.pch |
| 169 | // CHECK-YCFIFIFI: -x |
Richard Smith | dd4ad3d | 2016-08-30 19:06:26 +0000 | [diff] [blame] | 170 | // CHECK-YCFIFIFI: "c++-header" |
Erich Keane | 76675de | 2018-07-05 17:22:13 +0000 | [diff] [blame] | 171 | // CHECK-YCFIFIFI: cl-pch.cpp |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 172 | // 2. Use .pch file: Inlucdes foo2.pch and foo3.h |
| 173 | // CHECK-YCFIFIFI: cc1 |
| 174 | // CHECK-YCFIFIFI: -emit-obj |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 175 | // CHECK-YCFIFIFI: -include-pch |
| 176 | // CHECK-YCFIFIFI: foo2.pch |
Erich Keane | 76675de | 2018-07-05 17:22:13 +0000 | [diff] [blame] | 177 | // CHECK-YCFIFIFI: -pch-through-header=foo2.h |
| 178 | // CHECK-YCFIFIFI: -include |
| 179 | // CHECK-YCFIFIFI: foo1.h |
| 180 | // CHECK-YCFIFIFI: -include |
| 181 | // CHECK-YCFIFIFI: foo2.h |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 182 | // CHECK-YCFIFIFI: -include |
| 183 | // CHECK-YCFIFIFI: foo3.h |
Erich Keane | 76675de | 2018-07-05 17:22:13 +0000 | [diff] [blame] | 184 | // CHECK-YCFIFIFI: -o |
| 185 | // CHECK-YCFIFIFI: cl-pch.obj |
| 186 | // CHECK-YCFIFIFI: -x |
| 187 | // CHECK-YCFIFIFI: "c++" |
| 188 | // CHECK-YCFIFIFI: cl-pch.cpp |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 189 | |
Erich Keane | 76675de | 2018-07-05 17:22:13 +0000 | [diff] [blame] | 190 | // /Yufoo2.h /FIfoo1.h /FIfoo2.h /FIfoo3.h |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 191 | // => foo1 foo2 filtered out, foo3 into main compilation |
Nico Weber | 381ec2a | 2016-03-04 21:59:42 +0000 | [diff] [blame] | 192 | // RUN: %clang_cl -Werror /Yufoo2.h /FIfoo1.h /FIfoo2.h /FIfoo3.h /c -### -- %s 2>&1 \ |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 193 | // RUN: | FileCheck -check-prefix=CHECK-YUFIFIFI %s |
| 194 | // Use .pch file, but don't build it. |
| 195 | // CHECK-YUFIFIFI-NOT: -emit-pch |
| 196 | // CHECK-YUFIFIFI: cc1 |
| 197 | // CHECK-YUFIFIFI: -emit-obj |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 198 | // CHECK-YUFIFIFI: -include-pch |
| 199 | // CHECK-YUFIFIFI: foo2.pch |
Erich Keane | 76675de | 2018-07-05 17:22:13 +0000 | [diff] [blame] | 200 | // CHECK-YUFIFIFI: -pch-through-header=foo2.h |
| 201 | // CHECK-YUFIFIFI: -include |
| 202 | // CHECK-YUFIFIFI: foo1.h |
| 203 | // CHECK-YUFIFIFI: -include |
| 204 | // CHECK-YUFIFIFI: foo2.h |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 205 | // CHECK-YUFIFIFI: -include |
| 206 | // CHECK-YUFIFIFI: foo3.h |
| 207 | |
Erich Keane | 76675de | 2018-07-05 17:22:13 +0000 | [diff] [blame] | 208 | // Test /Ycfoo.h / /Yufoo.h without /FIfoo.h |
Nico Weber | 381ec2a | 2016-03-04 21:59:42 +0000 | [diff] [blame] | 209 | // RUN: %clang_cl -Werror /Ycfoo.h /c -### -- %s 2>&1 \ |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 210 | // RUN: | FileCheck -check-prefix=CHECK-YC-NOFI %s |
Erich Keane | 76675de | 2018-07-05 17:22:13 +0000 | [diff] [blame] | 211 | // 1. Precompile |
| 212 | // CHECK-YC-NOFI: cc1 |
| 213 | // CHECK-YC-NOFI: -emit-pch |
| 214 | // CHECK-YC-NOFI: -pch-through-header=foo.h |
| 215 | // CHECK-YC-NOFI: -o |
| 216 | // CHECK-YC-NOFI: foo.pch |
| 217 | // CHECK-YC-NOFI: -x |
| 218 | // CHECK-YC-NOFI: c++-header |
| 219 | // CHECK-YC-NOFI: cl-pch.cpp |
| 220 | // 2. Build PCH object |
| 221 | // CHECK-YC-NOFI: cc1 |
| 222 | // CHECK-YC-NOFI: -emit-obj |
| 223 | // CHECK-YC-NOFI: -include-pch |
| 224 | // CHECK-YC-NOFI: foo.pch |
| 225 | // CHECK-YC-NOFI: -pch-through-header=foo.h |
| 226 | // CHECK-YC-NOFI: -x |
| 227 | // CHECK-YC-NOFI: c++ |
| 228 | // CHECK-YC-NOFI: cl-pch.cpp |
Nico Weber | 381ec2a | 2016-03-04 21:59:42 +0000 | [diff] [blame] | 229 | // RUN: %clang_cl -Werror /Yufoo.h /c -### -- %s 2>&1 \ |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 230 | // RUN: | FileCheck -check-prefix=CHECK-YU-NOFI %s |
Erich Keane | 76675de | 2018-07-05 17:22:13 +0000 | [diff] [blame] | 231 | // CHECK-YU-NOFI: cc1 |
| 232 | // CHECK-YU-NOFI: -emit-obj |
| 233 | // CHECK-YU-NOFI: -include-pch |
| 234 | // CHECK-YU-NOFI: foo.pch |
| 235 | // CHECK-YU-NOFI: -pch-through-header=foo.h |
| 236 | // CHECK-YU-NOFI: -x |
| 237 | // CHECK-YU-NOFI: c++ |
| 238 | // CHECK-YU-NOFI: cl-pch.cpp |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 239 | |
| 240 | // With an actual /I argument. |
Nico Weber | 381ec2a | 2016-03-04 21:59:42 +0000 | [diff] [blame] | 241 | // RUN: %clang_cl -Werror /Ifoo /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \ |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 242 | // RUN: | FileCheck -check-prefix=CHECK-YC-I3 %s |
| 243 | // 1. This writes pchfile.pch into the root dir, even if this will pick up |
| 244 | // foo/pchfile.h |
| 245 | // CHECK-YC-I3: cc1 |
| 246 | // CHECK-YC-I3: -emit-pch |
| 247 | // CHECK-YC-I3: -o |
| 248 | // CHECK-YC-I3: pchfile.pch |
| 249 | // 2. Use .pch file. |
| 250 | // CHECK-YC-I3: cc1 |
| 251 | // CHECK-YC-I3: -emit-obj |
| 252 | // CHECK-YC-I3: -include-pch |
| 253 | // CHECK-YC-I3: pchfile.pch |
| 254 | |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 255 | // But /FIfoo/bar.h /Ycfoo\bar.h does work, as does /FIfOo.h /Ycfoo.H |
Nico Weber | 381ec2a | 2016-03-04 21:59:42 +0000 | [diff] [blame] | 256 | // RUN: %clang_cl -Werror /YupchFILE.h /FI./pchfile.h /c -### -- %s 2>&1 \ |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 257 | // RUN: | FileCheck -check-prefix=CHECK-YU-CASE %s |
Erich Keane | 76675de | 2018-07-05 17:22:13 +0000 | [diff] [blame] | 258 | // CHECK-YU-CASE: -pch-through-header=pchFILE.h |
| 259 | // CHECK-YU-CASE: -include |
| 260 | // CHECK-YU-CASE: "./pchfile.h" |
| 261 | // RUN: %clang_cl -Werror /Yu./pchfile.h /FI.\\pchfile.h /c -### -- %s 2>&1 \ |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 262 | // RUN: | FileCheck -check-prefix=CHECK-YU-SLASH %s |
Erich Keane | 76675de | 2018-07-05 17:22:13 +0000 | [diff] [blame] | 263 | // CHECK-YU-SLASH: -pch-through-header=./pchfile.h |
| 264 | // CHECK-YU-SLASH: -include |
| 265 | // CHECK-YU-SLASH: ".{{[/\\]+}}pchfile.h" |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 266 | |
Mike Rice | 58df1af | 2018-09-11 17:10:44 +0000 | [diff] [blame] | 267 | // /Yc without an argument creates a PCH from the code before #pragma hdrstop. |
| 268 | // /Yu without an argument uses a PCH and starts compiling after the |
| 269 | // #pragma hdrstop. |
| 270 | // RUN: %clang_cl -Werror /Yc /Fpycnoarg.pch /c -### -- %s 2>&1 \ |
| 271 | // RUN: | FileCheck -check-prefix=CHECK-YC-NOARG %s |
| 272 | // 1. Create .pch file |
| 273 | // CHECK-YC-NOARG: cc1 |
| 274 | // CHECK-YC-NOARG: -emit-pch |
| 275 | // CHECK-YC-NOARG: -pch-through-hdrstop-create |
| 276 | // CHECK-YC-NOARG: -o |
| 277 | // CHECK-YC-NOARG: ycnoarg.pch |
| 278 | // CHECK-YC-NOARG: -x |
| 279 | // CHECK-YC-NOARG: "c++-header" |
| 280 | // CHECK-YC-NOARG: cl-pch.cpp |
| 281 | // 2. Use .pch file: Includes ycnoarg.pch |
| 282 | // CHECK-YC-NOARG: cc1 |
| 283 | // CHECK-YC-NOARG: -emit-obj |
| 284 | // CHECK-YC-NOARG: -include-pch |
| 285 | // CHECK-YC-NOARG: ycnoarg.pch |
| 286 | // CHECK-YC-NOARG: -pch-through-hdrstop-create |
| 287 | // CHECK-YC-NOARG: -o |
| 288 | // CHECK-YC-NOARG: cl-pch.obj |
| 289 | // CHECK-YC-NOARG: -x |
| 290 | // CHECK-YC-NOARG: "c++" |
| 291 | // CHECK-YC-NOARG: cl-pch.cpp |
| 292 | |
| 293 | // RUN: %clang_cl -Werror /Yu /Fpycnoarg.pch /c -### -- %s 2>&1 \ |
| 294 | // RUN: | FileCheck -check-prefix=CHECK-YU-NOARG %s |
| 295 | // Use .pch file, but don't build it. |
| 296 | // CHECK-YU-NOARG-NOT: -emit-pch |
| 297 | // CHECK-YU-NOARG: cc1 |
| 298 | // CHECK-YU-NOARG: -emit-obj |
| 299 | // CHECK-YU-NOARG: -include-pch |
| 300 | // CHECK-YU-NOARG: ycnoarg.pch |
| 301 | // CHECK-YU-NOARG: -pch-through-hdrstop-use |
| 302 | // CHECK-YU-NOARG: -o |
| 303 | // CHECK-YU-NOARG: cl-pch.obj |
| 304 | // CHECK-YU-NOARG: -x |
| 305 | // CHECK-YU-NOARG: "c++" |
| 306 | // CHECK-YU-NOARG: cl-pch.cpp |
| 307 | |
| 308 | // /Yc with no argument and no /FP |
| 309 | // RUN: %clang_cl -Werror /Yc /c -### -- %s 2>&1 \ |
| 310 | // RUN: | FileCheck -check-prefix=CHECK-YC-NOARG-NOFP %s |
| 311 | // 1. Create .pch file |
| 312 | // CHECK-YC-NOARG-NOFP: cc1 |
| 313 | // CHECK-YC-NOARG-NOFP: -emit-pch |
| 314 | // CHECK-YC-NOARG-NOFP: -pch-through-hdrstop-create |
| 315 | // CHECK-YC-NOARG-NOFP: -o |
| 316 | // CHECK-YC-NOARG-NOFP: cl-pch.pch |
| 317 | // CHECK-YC-NOARG-NOFP: -x |
| 318 | // CHECK-YC-NOARG-NOFP: "c++-header" |
| 319 | // CHECK-YC-NOARG-NOFP: cl-pch.cpp |
| 320 | // 2. Use .pch file: Includes cl-pch.pch |
| 321 | // CHECK-YC-NOARG-NOFP: cc1 |
| 322 | // CHECK-YC-NOARG-NOFP: -emit-obj |
| 323 | // CHECK-YC-NOARG-NOFP: -include-pch |
| 324 | // CHECK-YC-NOARG-NOFP: cl-pch.pch |
| 325 | // CHECK-YC-NOARG-NOFP: -pch-through-hdrstop-create |
| 326 | // CHECK-YC-NOARG-NOFP: -o |
| 327 | // CHECK-YC-NOARG-NOFP: cl-pch.obj |
| 328 | // CHECK-YC-NOARG-NOFP: -x |
| 329 | // CHECK-YC-NOARG-NOFP: "c++" |
| 330 | // CHECK-YC-NOARG-NOFP: cl-pch.cpp |
| 331 | |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 332 | // cl.exe warns on multiple /Yc, /Yu, /Fp arguments, but clang-cl silently just |
| 333 | // uses the last one. This is true for e.g. /Fo too, so not warning on this |
| 334 | // is self-consistent with clang-cl's flag handling. |
| 335 | |
| 336 | // Interaction with /fallback |
| 337 | |
| 338 | // /Yc /fallback => /Yc not passed on (but /FI is) |
Nico Weber | 381ec2a | 2016-03-04 21:59:42 +0000 | [diff] [blame] | 339 | // RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /Fpfoo.pch /fallback /c -### -- %s 2>&1 \ |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 340 | // RUN: | FileCheck -check-prefix=CHECK-YC-FALLBACK %s |
| 341 | // Note that in /fallback builds, if creation of the pch fails the main compile |
| 342 | // does still run so that /fallback can have an effect (this part is not tested) |
| 343 | // CHECK-YC-FALLBACK: cc1 |
| 344 | // CHECK-YC-FALLBACK: -emit-obj |
| 345 | // CHECK-YC-FALLBACK: -include-pch |
| 346 | // CHECK-YC-FALLBACK: foo.pch |
| 347 | // CHECK-YC-FALLBACK: || |
| 348 | // CHECK-YC-FALLBACK: cl.exe |
| 349 | // CHECK-YC-FALLBACK-NOT: -include-pch |
| 350 | // CHECK-YC-FALLBACK-NOT: /Ycpchfile.h |
| 351 | // CHECK-YC-FALLBACK: /FIpchfile.h |
| 352 | // CHECK-YC-FALLBACK-NOT: /Fpfoo.pch |
| 353 | |
| 354 | // /Yu /fallback => /Yu not passed on (but /FI is) |
Nico Weber | 381ec2a | 2016-03-04 21:59:42 +0000 | [diff] [blame] | 355 | // RUN: %clang_cl -Werror /Yupchfile.h /FIpchfile.h /Fpfoo.pch /fallback /c -### -- %s 2>&1 \ |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 356 | // RUN: | FileCheck -check-prefix=CHECK-YU-FALLBACK %s |
| 357 | // CHECK-YU-FALLBACK-NOT: -emit-pch |
| 358 | // CHECK-YU-FALLBACK: cc1 |
| 359 | // CHECK-YU-FALLBACK: -emit-obj |
| 360 | // CHECK-YU-FALLBACK: -include-pch |
| 361 | // CHECK-YU-FALLBACK: foo.pch |
| 362 | // CHECK-YU-FALLBACK: || |
| 363 | // CHECK-YU-FALLBACK: cl.exe |
| 364 | // CHECK-YU-FALLBACK-NOT: -include-pch |
| 365 | // CHECK-YU-FALLBACK-NOT: /Yupchfile.h |
| 366 | // CHECK-YU-FALLBACK: /FIpchfile.h |
| 367 | // CHECK-YU-FALLBACK-NOT: /Fpfoo.pch |
| 368 | |
| 369 | // /FI without /Yu => pch file not used, even if it exists (different from |
| 370 | // -include, which picks up .gch files if they exist). |
| 371 | // RUN: touch %t.pch |
Nico Weber | 381ec2a | 2016-03-04 21:59:42 +0000 | [diff] [blame] | 372 | // RUN: %clang_cl -Werror /FI%t.pch /Fp%t.pch /c -### -- %s 2>&1 \ |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 373 | // RUN: | FileCheck -check-prefix=CHECK-FI %s |
| 374 | // CHECK-FI-NOT: -include-pch |
| 375 | // CHECK-FI: -include |
| 376 | |
| 377 | // Test interaction of /Yc with language mode flags. |
| 378 | |
| 379 | // If /TC changes the input language to C, a c pch file should be produced. |
Nico Weber | 381ec2a | 2016-03-04 21:59:42 +0000 | [diff] [blame] | 380 | // RUN: %clang_cl /TC -Werror /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \ |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 381 | // RUN: | FileCheck -check-prefix=CHECK-YCTC %s |
| 382 | // CHECK-YCTC: cc1 |
| 383 | // CHECK-YCTC: -emit-pch |
| 384 | // CHECK-YCTC: -o |
| 385 | // CHECK-YCTC: pchfile.pch |
| 386 | // CHECK-YCTC: -x |
Nico Weber | ad2d8f3 | 2016-04-21 19:59:10 +0000 | [diff] [blame] | 387 | // CHECK-YCTC: "c" |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 388 | |
| 389 | // Also check lower-case /Tc variant. |
Nico Weber | 381ec2a | 2016-03-04 21:59:42 +0000 | [diff] [blame] | 390 | // RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /c -### /Tc%s 2>&1 \ |
Nico Weber | 2ca4be9 | 2016-03-01 23:16:44 +0000 | [diff] [blame] | 391 | // RUN: | FileCheck -check-prefix=CHECK-YCTc %s |
| 392 | // CHECK-YCTc: cc1 |
| 393 | // CHECK-YCTc: -emit-pch |
| 394 | // CHECK-YCTc: -o |
| 395 | // CHECK-YCTc: pchfile.pch |
| 396 | // CHECK-YCTc: -x |
| 397 | // CHECK-YCTc: "c" |
Nico Weber | ad2d8f3 | 2016-04-21 19:59:10 +0000 | [diff] [blame] | 398 | |
| 399 | // Don't crash when a non-source file is passed. |
Nico Weber | 3796093 | 2016-04-22 00:38:09 +0000 | [diff] [blame] | 400 | // RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /c -### -- %S/Inputs/file.prof 2>&1 \ |
Nico Weber | ad2d8f3 | 2016-04-21 19:59:10 +0000 | [diff] [blame] | 401 | // RUN: | FileCheck -check-prefix=CHECK-NoSource %s |
| 402 | // CHECK-NoSource: file.prof:{{.*}}input unused |
| 403 | |
Nico Weber | 39dc744 | 2016-08-30 14:24:28 +0000 | [diff] [blame] | 404 | // ...but if an explicit flag turns the file into a source file, handle it: |
Nico Weber | 3796093 | 2016-04-22 00:38:09 +0000 | [diff] [blame] | 405 | // RUN: %clang_cl /TP -Werror /Ycpchfile.h /FIpchfile.h /c -### -- %S/Inputs/file.prof 2>&1 \ |
Nico Weber | ad2d8f3 | 2016-04-21 19:59:10 +0000 | [diff] [blame] | 406 | // RUN: | FileCheck -check-prefix=CHECK-NoSourceTP %s |
| 407 | // CHECK-NoSourceTP: cc1 |
| 408 | // CHECK-NoSourceTP: -emit-pch |
| 409 | // CHECK-NoSourceTP: -o |
| 410 | // CHECK-NoSourceTP: pchfile.pch |
| 411 | // CHECK-NoSourceTP: -x |
| 412 | // CHECK-NoSourceTP: "c++" |
Erich Keane | eaca388 | 2018-08-17 13:43:39 +0000 | [diff] [blame] | 413 | |
| 414 | // If only preprocessing, PCH options are ignored. |
| 415 | // RUN: %clang_cl /P /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \ |
| 416 | // RUN: | FileCheck -check-prefix=CHECK-YC-P %s |
| 417 | // CHECK-YC-P-NOT: -emit-pch |
| 418 | // CHECK-YC-P-NOT: -include-pch |
| 419 | |
| 420 | // RUN: %clang_cl /E /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \ |
| 421 | // RUN: | FileCheck -check-prefix=CHECK-YC-E %s |
| 422 | // CHECK-YC-E-NOT: -emit-pch |
| 423 | // CHECK-YC-E-NOT: -include-pch |
| 424 | |
| 425 | // RUN: %clang_cl /P /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \ |
| 426 | // RUN: | FileCheck -check-prefix=CHECK-YU-P %s |
| 427 | // CHECK-YU-P-NOT: -emit-pch |
| 428 | // CHECK-YU-P-NOT: -include-pch |
| 429 | |
| 430 | // RUN: %clang_cl /E /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \ |
| 431 | // RUN: | FileCheck -check-prefix=CHECK-YU-E %s |
| 432 | // CHECK-YU-E-NOT: -emit-pch |
| 433 | // CHECK-YU-E-NOT: -include-pch |