clang-cl: Enable PCH flags by default.
authorNico Weber <nicolasweber@gmx.de>
Fri, 4 Mar 2016 21:59:42 +0000 (21:59 +0000)
committerNico Weber <nicolasweber@gmx.de>
Fri, 4 Mar 2016 21:59:42 +0000 (21:59 +0000)
Now that pragma comment and pragma detect_mismatch are implemented, this might
just work.

Some pragmas aren't serialized yet (from the top of my head: code_seg, bss_seg,
data_seg, const_seg, init_seg, section, vtordisp), but these are as far as I
know usually pushed and popped within the header and usually don't leak out.
If it turns out the current PCH support isn't good enough yet, we can turn it
off again.

llvm-svn: 262749

clang/include/clang/Driver/CLCompatOptions.td
clang/lib/Driver/Driver.cpp
clang/test/Driver/cl-pch-errorhandling.cpp
clang/test/Driver/cl-pch-search.cpp
clang/test/Driver/cl-pch.c
clang/test/Driver/cl-pch.cpp

index d7c8413..2604c65 100644 (file)
@@ -20,9 +20,6 @@ def cl_compile_Group : OptionGroup<"<clang-cl compile-only options>">,
 def cl_ignored_Group : OptionGroup<"<clang-cl ignored options>">,
   Group<cl_Group>;
 
-def cl_internal_Group : OptionGroup<"<clang-cl internal options>">,
-  Group<cl_Group>;
-
 class CLFlag<string name> : Option<["/", "-"], name, KIND_FLAG>,
   Group<cl_Group>, Flags<[CLOption, DriverOption]>;
 
@@ -32,9 +29,6 @@ class CLCompileFlag<string name> : Option<["/", "-"], name, KIND_FLAG>,
 class CLIgnoredFlag<string name> : Option<["/", "-"], name, KIND_FLAG>,
   Group<cl_ignored_Group>, Flags<[CLOption, DriverOption, HelpHidden]>;
 
-class CLInternalFlag<string name> : Option<["-"], name, KIND_FLAG>,
-  Group<cl_internal_Group>, Flags<[CLOption, DriverOption, HelpHidden]>;
-
 class CLJoined<string name> : Option<["/", "-"], name, KIND_JOINED>,
   Group<cl_Group>, Flags<[CLOption, DriverOption]>;
 
@@ -270,11 +264,6 @@ def _SLASH_Y_ : CLFlag<"Y-">,
 def _SLASH_Fp : CLJoined<"Fp">,
   HelpText<"Set pch filename (with /Yc and /Yu)">, MetaVarName<"<filename>">;
 
-// Internal:
-// FIXME: Once /Yc support is stable enough, turn it on by default (when /Yc
-// is passed) and remove this flag.
-def _SLASH_internal_enable_pch : CLInternalFlag<"internal-enable-pch">;
-
 // Ignored:
 
 def _SLASH_analyze_ : CLIgnoredFlag<"analyze-">;
index f8d6fc7..75dcfc9 100644 (file)
@@ -1503,14 +1503,6 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
     Args.eraseArg(options::OPT__SLASH_Yu);
     YcArg = YuArg = nullptr;
   }
-  // FIXME: For now, only enable pch support if an internal flag is passed too.
-  // Remove this once pch support has stabilitzed.
-  if (!Args.hasArg(options::OPT__SLASH_internal_enable_pch)) {
-    Args.eraseArg(options::OPT__SLASH_Fp);
-    Args.eraseArg(options::OPT__SLASH_Yc);
-    Args.eraseArg(options::OPT__SLASH_Yu);
-    YcArg = YuArg = nullptr;
-  }
 
   // Construct the actions to perform.
   ActionList LinkerInputs;
index ec06bb5..879c8cf 100644 (file)
@@ -6,7 +6,7 @@
 // code generation, which makes this test require an x86 backend.
 // REQUIRES: x86-registered-target
 
-// RUN: not %clang_cl -internal-enable-pch -Werror /Yc%S/Inputs/pchfile.h /FI%S/Inputs/pchfile.h /Fp%t.pch /c -DERR_HEADER -- %s 2>&1 \
+// RUN: not %clang_cl -Werror /Yc%S/Inputs/pchfile.h /FI%S/Inputs/pchfile.h /Fp%t.pch /c -DERR_HEADER -- %s 2>&1 \
 // RUN:   | FileCheck %s
 
 // CHECK: nope1
index b215fd7..118cf19 100644 (file)
@@ -3,4 +3,4 @@
 
 // REQUIRES: x86-registered-target
 // Check that pchfile.h next to to pchfile.cc is found correctly.
-// RUN: %clang_cl -internal-enable-pch -Werror /Ycpchfile.h /FIpchfile.h /c /Fo%t.obj /Fp%t.pch -- %S/Inputs/pchfile.cpp 
+// RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /c /Fo%t.obj /Fp%t.pch -- %S/Inputs/pchfile.cpp 
index df00fff..3372c18 100644 (file)
@@ -5,7 +5,7 @@
 // a few things for .c inputs.
 
 // /Yc with a .c file should build a c pch file.
-// RUN: %clang_cl -internal-enable-pch -Werror /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YC %s
 // CHECK-YC: cc1
 // CHECK-YC: -emit-pch
@@ -15,7 +15,7 @@
 // CHECK-YC: "c"
 
 // But not if /TP changes the input language to C++.
-// RUN: %clang_cl /TP -internal-enable-pch -Werror /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN: %clang_cl /TP -Werror /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YCTP %s
 // CHECK-YCTP: cc1
 // CHECK-YCTP: -emit-pch
@@ -25,7 +25,7 @@
 // CHECK-YCTP: "c++"
 
 // Except if a later /TC changes it back.
-// RUN: %clang_cl -internal-enable-pch -Werror /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YCTPTC %s
 // CHECK-YCTPTC: cc1
 // CHECK-YCTPTC: -emit-pch
@@ -35,7 +35,7 @@
 // CHECK-YCTPTC: "c"
 
 // Also check lower-case /Tp flag.
-// RUN: %clang_cl -internal-enable-pch -Werror /Tp%s /Ycpchfile.h /FIpchfile.h /c -### 2>&1 \
+// RUN: %clang_cl -Werror /Tp%s /Ycpchfile.h /FIpchfile.h /c -### 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YCTp %s
 // CHECK-YCTp: cc1
 // CHECK-YCTp: -emit-pch
index f415794..075fe82 100644 (file)
@@ -2,7 +2,7 @@
 // command-line option, e.g. on Mac where %s is commonly under /Users.
 
 // /Yc
-// RUN: %clang_cl -internal-enable-pch -Werror /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YC %s
 // 1. Build .pch file.
 // CHECK-YC: cc1
@@ -19,7 +19,7 @@
 
 // /Yc /Fo
 // /Fo overrides the .obj output filename, but not the .pch filename
-// RUN: %clang_cl -internal-enable-pch -Werror /Fomyobj.obj /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN: %clang_cl -Werror /Fomyobj.obj /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YCO %s
 // 1. Build .pch file.
 // CHECK-YCO: cc1
 
 // /Yc /Y-
 // /Y- disables pch generation
-// RUN: %clang_cl -internal-enable-pch -Werror /Y- /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN: %clang_cl -Werror /Y- /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YC-Y_ %s
 // CHECK-YC-Y_-NOT: -emit-pch
 // CHECK-YC-Y_-NOT: -include-pch
 
 // /Yu
-// RUN: %clang_cl -internal-enable-pch -Werror /Yupchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN: %clang_cl -Werror /Yupchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YU %s
 // Use .pch file, but don't build it.
 // CHECK-YU-NOT: -emit-pch
 // CHECK-YU: pchfile.pch
 
 // /Yu /Y-
-// RUN: %clang_cl -internal-enable-pch -Werror /Y- /Yupchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN: %clang_cl -Werror /Y- /Yupchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YU-Y_ %s
 // CHECK-YU-Y_-NOT: -emit-pch
 // CHECK-YU-Y_-NOT: -include-pch
 
 // /Yc /Yu -- /Yc overrides /Yc if they both refer to the same file
-// RUN: %clang_cl -internal-enable-pch -Werror /Ycpchfile.h /Yupchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN: %clang_cl -Werror /Ycpchfile.h /Yupchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YC-YU %s
 // 1. Build .pch file.
 // CHECK-YC-YU: cc1
 
 // If /Yc /Yu refer to different files, semantics are pretty wonky.  Since this
 // doesn't seem like something that's important in practice, just punt for now.
-// RUN: %clang_cl -internal-enable-pch -Werror /Ycfoo1.h /Yufoo2.h /FIfoo1.h /FIfoo2.h /c -### -- %s 2>&1 \
+// RUN: %clang_cl -Werror /Ycfoo1.h /Yufoo2.h /FIfoo1.h /FIfoo2.h /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YC-YU-MISMATCH %s
 // CHECK-YC-YU-MISMATCH: error: support for '/Yc' and '/Yu' with different filenames not implemented yet; flags ignored
 
 // Similarly, punt on /Yc with more than one input file.
-// RUN: %clang_cl -internal-enable-pch -Werror /Ycfoo1.h /FIfoo1.h /c -### -- %s %s 2>&1 \
+// RUN: %clang_cl -Werror /Ycfoo1.h /FIfoo1.h /c -### -- %s %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YC-MULTIINPUT %s
 // CHECK-YC-MULTIINPUT: error: support for '/Yc' with more than one source file not implemented yet; flag ignored
 
 // /Yc /Yu /Y-
-// RUN: %clang_cl -internal-enable-pch -Werror /Ycpchfile.h /Yupchfile.h /FIpchfile.h /Y- /c -### -- %s 2>&1 \
+// RUN: %clang_cl -Werror /Ycpchfile.h /Yupchfile.h /FIpchfile.h /Y- /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YC-YU-Y_ %s
 // CHECK-YC-YU-Y_-NOT: -emit-pch
 // CHECK-YC-YU-Y_-NOT: -include-pch
 // Test computation of pch filename in various cases.
 
 // /Yu /Fpout.pch => out.pch is filename
-// RUN: %clang_cl -internal-enable-pch -Werror /Yupchfile.h /FIpchfile.h /Fpout.pch /c -### -- %s 2>&1 \
+// RUN: %clang_cl -Werror /Yupchfile.h /FIpchfile.h /Fpout.pch /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YUFP1 %s
 // Use .pch file, but don't build it.
 // CHECK-YUFP1: -include-pch
 // CHECK-YUFP1: out.pch
 
 // /Yu /Fpout => out.pch is filename (.pch gets added if no extension present)
-// RUN: %clang_cl -internal-enable-pch -Werror /Yupchfile.h /FIpchfile.h /Fpout.pch /c -### -- %s 2>&1 \
+// RUN: %clang_cl -Werror /Yupchfile.h /FIpchfile.h /Fpout.pch /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YUFP2 %s
 // Use .pch file, but don't build it.
 // CHECK-YUFP2: -include-pch
 // CHECK-YUFP2: out.pch
 
 // /Yu /Fpout.bmp => out.bmp is filename (.pch not added when extension present)
-// RUN: %clang_cl -internal-enable-pch -Werror /Yupchfile.h /FIpchfile.h /Fpout.bmp /c -### -- %s 2>&1 \
+// RUN: %clang_cl -Werror /Yupchfile.h /FIpchfile.h /Fpout.bmp /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YUFP3 %s
 // Use .pch file, but don't build it.
 // CHECK-YUFP3: -include-pch
 // CHECK-YUFP3: out.bmp
 
 // /Yusub/dir.h => sub/dir.pch
-// RUN: %clang_cl -internal-enable-pch -Werror /Yusub/pchfile.h /FIsub/pchfile.h /c -### -- %s 2>&1 \
+// RUN: %clang_cl -Werror /Yusub/pchfile.h /FIsub/pchfile.h /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YUFP4 %s
 // Use .pch file, but don't build it.
 // CHECK-YUFP4: -include-pch
 // CHECK-YUFP4: sub/pchfile.pch
 
 // /Yudir.h /Isub => dir.pch
-// RUN: %clang_cl -internal-enable-pch -Werror /Yupchfile.h /FIpchfile.h /Isub /c -### -- %s 2>&1 \
+// RUN: %clang_cl -Werror /Yupchfile.h /FIpchfile.h /Isub /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YUFP5 %s
 // Use .pch file, but don't build it.
 // CHECK-YUFP5: -include-pch
 
 // Spot-check one use of /Fp with /Yc too, else trust the /Yu test cases above
 // also all assume to /Yc.
-// RUN: %clang_cl -internal-enable-pch -Werror /Ycpchfile.h /FIpchfile.h /Fpsub/file.pch /c -### -- %s 2>&1 \
+// RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /Fpsub/file.pch /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YCFP %s
 // 1. Build .pch file.
 // CHECK-YCFP: cc1
 // /Ycfoo2.h /FIfoo1.h /FIfoo2.h /FIfoo3.h
 // => foo1 and foo2 go into pch, foo3 into main compilation
 // /Yc
-// RUN: %clang_cl -internal-enable-pch -Werror /Ycfoo2.h /FIfoo1.h /FIfoo2.h /FIfoo3.h /c -### -- %s 2>&1 \
+// RUN: %clang_cl -Werror /Ycfoo2.h /FIfoo1.h /FIfoo2.h /FIfoo3.h /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YCFIFIFI %s
 // 1. Build .pch file: Includes foo1.h (but NOT foo3.h) and compiles foo2.h
 // CHECK-YCFIFIFI: cc1
 
 // /Yucfoo2.h /FIfoo1.h /FIfoo2.h /FIfoo3.h
 // => foo1 foo2 filtered out, foo3 into main compilation
-// RUN: %clang_cl -internal-enable-pch -Werror /Yufoo2.h /FIfoo1.h /FIfoo2.h /FIfoo3.h /c -### -- %s 2>&1 \
+// RUN: %clang_cl -Werror /Yufoo2.h /FIfoo1.h /FIfoo2.h /FIfoo3.h /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YUFIFIFI %s
 // Use .pch file, but don't build it.
 // CHECK-YUFIFIFI-NOT: -emit-pch
 // CHECK-YUFIFIFI: foo3.h
 
 // FIXME: Implement support for /Ycfoo.h / /Yufoo.h without /FIfoo.h
-// RUN: %clang_cl -internal-enable-pch -Werror /Ycfoo.h /c -### -- %s 2>&1 \
+// RUN: %clang_cl -Werror /Ycfoo.h /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YC-NOFI %s
 // CHECK-YC-NOFI: error: support for '/Yc' without a corresponding /FI flag not implemented yet; flag ignored
-// RUN: %clang_cl -internal-enable-pch -Werror /Yufoo.h /c -### -- %s 2>&1 \
+// RUN: %clang_cl -Werror /Yufoo.h /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YU-NOFI %s
 // CHECK-YU-NOFI: error: support for '/Yu' without a corresponding /FI flag not implemented yet; flag ignored
 
 // these test cases all should stay failures as they fail with cl.exe.
 
 // Check that ./ isn't canonicalized away.
-// RUN: %clang_cl -internal-enable-pch -Werror /Ycpchfile.h /FI./pchfile.h /c -### -- %s 2>&1 \
+// RUN: %clang_cl -Werror /Ycpchfile.h /FI./pchfile.h /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YC-I1 %s
 // CHECK-YC-I1: support for '/Yc' without a corresponding /FI flag not implemented yet; flag ignored
 
 // Check that ./ isn't canonicalized away.
-// RUN: %clang_cl -internal-enable-pch -Werror /Yc./pchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN: %clang_cl -Werror /Yc./pchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YC-I2 %s
 // CHECK-YC-I2: support for '/Yc' without a corresponding /FI flag not implemented yet; flag ignored
 
 // With an actual /I argument.
-// RUN: %clang_cl -internal-enable-pch -Werror /Ifoo /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN: %clang_cl -Werror /Ifoo /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YC-I3 %s
 // 1. This writes pchfile.pch into the root dir, even if this will pick up
 //    foo/pchfile.h
 // CHECK-YC-I3: pchfile.pch
 
 // Check that ./ isn't canonicalized away for /Yu either.
-// RUN: %clang_cl -internal-enable-pch -Werror /Yupchfile.h /FI./pchfile.h /c -### -- %s 2>&1 \
+// RUN: %clang_cl -Werror /Yupchfile.h /FI./pchfile.h /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YU-I1 %s
 // CHECK-YU-I1: support for '/Yu' without a corresponding /FI flag not implemented yet; flag ignored
 
 // But /FIfoo/bar.h /Ycfoo\bar.h does work, as does /FIfOo.h /Ycfoo.H
 // FIXME: This part isn't implemented yet. The following two tests should not
 // show an error but do regular /Yu handling.
-// RUN: %clang_cl -internal-enable-pch -Werror /YupchFILE.h /FI./pchfile.h /c -### -- %s 2>&1 \
+// RUN: %clang_cl -Werror /YupchFILE.h /FI./pchfile.h /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YU-CASE %s
 // CHECK-YU-CASE: support for '/Yu' without a corresponding /FI flag not implemented yet; flag ignored
-// RUN: %clang_cl -internal-enable-pch -Werror /Yu./pchfile.h /FI.\pchfile.h /c -### -- %s 2>&1 \
+// RUN: %clang_cl -Werror /Yu./pchfile.h /FI.\pchfile.h /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YU-SLASH %s
 // CHECK-YU-SLASH: support for '/Yu' without a corresponding /FI flag not implemented yet; flag ignored
 
 // Interaction with /fallback
 
 // /Yc /fallback => /Yc not passed on (but /FI is)
-// RUN: %clang_cl -internal-enable-pch -Werror /Ycpchfile.h /FIpchfile.h /Fpfoo.pch /fallback /c -### -- %s 2>&1 \
+// RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /Fpfoo.pch /fallback /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YC-FALLBACK %s
 // Note that in /fallback builds, if creation of the pch fails the main compile
 // does still run so that /fallback can have an effect (this part is not tested)
 // CHECK-YC-FALLBACK-NOT: /Fpfoo.pch
 
 // /Yu /fallback => /Yu not passed on (but /FI is)
-// RUN: %clang_cl -internal-enable-pch -Werror /Yupchfile.h /FIpchfile.h /Fpfoo.pch /fallback /c -### -- %s 2>&1 \
+// RUN: %clang_cl -Werror /Yupchfile.h /FIpchfile.h /Fpfoo.pch /fallback /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YU-FALLBACK %s
 // CHECK-YU-FALLBACK-NOT: -emit-pch
 // CHECK-YU-FALLBACK: cc1
 // /FI without /Yu => pch file not used, even if it exists (different from
 // -include, which picks up .gch files if they exist).
 // RUN: touch %t.pch
-// RUN: %clang_cl -internal-enable-pch -Werror /FI%t.pch /Fp%t.pch /c -### -- %s 2>&1 \
+// RUN: %clang_cl -Werror /FI%t.pch /Fp%t.pch /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-FI %s
 // CHECK-FI-NOT: -include-pch
 // CHECK-FI: -include
 // Test interaction of /Yc with language mode flags.
 
 // If /TC changes the input language to C, a c pch file should be produced.
-// RUN: %clang_cl /TC -internal-enable-pch -Werror /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN: %clang_cl /TC -Werror /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YCTC %s
 // CHECK-YCTC: cc1
 // CHECK-YCTC: -emit-pch
 // CHECK-YCTP: "c"
 
 // Also check lower-case /Tc variant.
-// RUN: %clang_cl -internal-enable-pch -Werror /Ycpchfile.h /FIpchfile.h /c -### /Tc%s 2>&1 \
+// RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /c -### /Tc%s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-YCTc %s
 // CHECK-YCTc: cc1
 // CHECK-YCTc: -emit-pch