[cfe-commits] r115158 - in /cfe/trunk: include/clang/Basic/DiagnosticDriverKinds.td lib/Driver/Tools.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Thu Sep 30 09:53:47 PDT 2010


Author: akirtzidis
Date: Thu Sep 30 11:53:47 2010
New Revision: 115158

URL: http://llvm.org/viewvc/llvm-project?rev=115158&view=rev
Log:
Driver: Ignore the found PCH file if its '-include' is not the first one.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
    cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=115158&r1=115157&r2=115158&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Thu Sep 30 11:53:47 2010
@@ -102,5 +102,7 @@
   InGroup<Deprecated>;
 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'">;
 
 }

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=115158&r1=115157&r2=115158&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Sep 30 11:53:47 2010
@@ -212,11 +212,15 @@
   // wonky, but we include looking for .gch so we can support seamless
   // replacement into a build system already set up to be generating
   // .gch files.
+  bool RenderedImplicitInclude = false;
   for (arg_iterator it = Args.filtered_begin(options::OPT_clang_i_Group),
          ie = Args.filtered_end(); it != ie; ++it) {
     const Arg *A = it;
 
     if (A->getOption().matches(options::OPT_include)) {
+      bool IsFirstImplicitInclude = !RenderedImplicitInclude;
+      RenderedImplicitInclude = true;
+
       // Use PCH if the user requested it.
       bool UsePCH = D.CCCUsePCH;
 
@@ -250,13 +254,19 @@
       }
 
       if (FoundPCH || FoundPTH) {
-        A->claim();
-        if (UsePCH)
-          CmdArgs.push_back("-include-pch");
-        else
-          CmdArgs.push_back("-include-pth");
-        CmdArgs.push_back(Args.MakeArgString(P.str()));
-        continue;
+        if (IsFirstImplicitInclude) {
+          A->claim();
+          if (UsePCH)
+            CmdArgs.push_back("-include-pch");
+          else
+            CmdArgs.push_back("-include-pth");
+          CmdArgs.push_back(Args.MakeArgString(P.str()));
+          continue;
+        } else {
+          // Ignore the PCH if not first on command line and emit warning.
+          D.Diag(clang::diag::warn_drv_pch_not_first_include)
+              << P.str() << A->getAsString(Args);
+        }
       }
     }
 





More information about the cfe-commits mailing list