]> granicus.if.org Git - clang/commitdiff
Add '-include-pch' option to the driver, so it can get passed to the cc1 driver.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 15 Oct 2010 18:49:01 +0000 (18:49 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 15 Oct 2010 18:49:01 +0000 (18:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116605 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticDriverKinds.td
include/clang/Driver/Options.td
lib/Driver/Tools.cpp
test/Driver/pth.c

index 19011ace7f27c35c658f0230c6cc7c7591e96ceb..a7c30a744d2f2bceebc5a29c38c819ec6745489b 100644 (file)
@@ -102,5 +102,7 @@ def warn_drv_objc_gc_unsupported : Warning<
   "Objective-C garbage collection is not supported on this platform, ignoring '%0'">;
 def warn_drv_pch_not_first_include : Warning<
   "precompiled header '%0' was ignored because '%1' is not first '-include'">;
+def warn_drv_pch_missing_language : Warning<
+  "ignoring argument '%0' due to missing precompiled header '%1' for language '%2'">;
 
 }
index cfb9c81b574cf6426a8f87e1d3f99b4c2975e183..ab87d57d4353b1f5593f02f3043e567cc35d46b3 100644 (file)
@@ -426,6 +426,7 @@ def iframework : JoinedOrSeparate<"-iframework">, Group<clang_i_Group>;
 def imacros : JoinedOrSeparate<"-imacros">, Group<clang_i_Group>;
 def image__base : Separate<"-image_base">;
 def include_ : JoinedOrSeparate<"-include">, Group<clang_i_Group>, EnumName<"include">;
+def include_pch : Separate<"-include-pch">, Group<clang_i_Group>;
 def init : Separate<"-init">;
 def install__name : Separate<"-install_name">;
 def integrated_as : Flag<"-integrated-as">, Flags<[DriverOption]>;
index 229cf608f3f0dc753fae606127f1d02f55cb87a4..fd57cffbc5436876b01d2383c0d028eab179b5b1 100644 (file)
@@ -256,6 +256,16 @@ void Clang::AddPreprocessingOptions(const Driver &D,
       if (FoundPCH || FoundPTH) {
         if (IsFirstImplicitInclude) {
           A->claim();
+          if (P.isDirectory()) {
+            // Expect to find a precompiled header matching the current input type
+            P.appendComponent(types::getTypeName(Inputs[0].getType()));
+            if (!P.exists()) {
+              D.Diag(clang::diag::warn_drv_pch_missing_language)
+                  << A->getAsString(Args) << P.str()
+                  << types::getTypeName(Inputs[0].getType());
+              continue;
+            }
+          }
           if (UsePCH)
             CmdArgs.push_back("-include-pch");
           else
index 9c47c5599376a2fef41f95fcaebb7abbd5948e9a..d6ed90423b62d80c922e1276b7187159929718fd 100644 (file)
 // RUN: FileCheck -check-prefix CHECK2 -input-file %t.log %s
 
 // CHECK2: "{{.*}}/clang{{.*}}" "-cc1" {{.*}}"-include-pth" "{{.*}}.h.pth" {{.*}}"-x" "c" "{{.*}}pth.c"
+
+// RUN: mkdir -p %t.pth
+// RUN: %clang -ccc-pch-is-pth -x c-header %s -o %t.pth/c -### 2> %t.log
+// RUN: FileCheck -check-prefix CHECK3 -input-file %t.log %s
+
+// CHECK3: "{{.*}}/clang{{.*}}" "-cc1" {{.*}} "-o" "{{.*}}.pth/c" "-x" "c-header" "{{.*}}pth.c"
+
+// RUN: rm -f %t.pth/c
+// RUN: %clang -ccc-pch-is-pth -E -include %t %s -### 2> %t.log
+// RUN: echo "DONE" >> %t.log
+// RUN: FileCheck -check-prefix CHECK4 -input-file %t.log %s
+
+// CHECK4: {{.*}} ignoring argument '-include {{.*}}' due to missing precompiled header '{{.*}}.pth/c' for language 'c'
+// CHECK4-NOT: -include-pth
+// CHECK4: DONE
+
+// RUN: touch %t.pth/c
+// RUN: %clang -ccc-pch-is-pth -E -include %t %s -### 2> %t.log
+// RUN: FileCheck -check-prefix CHECK5 -input-file %t.log %s
+
+// CHECK5: "{{.*}}/clang{{.*}}" "-cc1" {{.*}}"-include-pth" "{{.*}}.pth/c" {{.*}}"-x" "c" "{{.*}}pth.c"