[PATCH] D30743: enable -save-temps with -finclude-defult-header

Guansong Zhang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 13 11:54:28 PDT 2017


guansong updated this revision to Diff 91600.

https://reviews.llvm.org/D30743

Files:
  lib/Driver/Tools.cpp
  test/Driver/include-default-header.cl


Index: test/Driver/include-default-header.cl
===================================================================
--- /dev/null
+++ test/Driver/include-default-header.cl
@@ -0,0 +1,4 @@
+// RUN: %clang -v -save-temps -x cl -Xclang -cl-std=CL2.0 -Xclang -finclude-default-header -target amdgcn -S -c %s
+
+void test() {}
+
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5285,7 +5285,20 @@
 
   // Forward -Xclang arguments to -cc1, and -mllvm arguments to the LLVM option
   // parser.
-  Args.AddAllArgValues(CmdArgs, options::OPT_Xclang);
+  if (C.getDriver().isSaveTempsEnabled() &&
+      !isa<PreprocessJobAction>(JA)) {
+    // -finclude-default-header flag is for preprocessor,
+    // do not pass it to other cc1 commands when save-temps is enabled
+    for (auto Arg : Args.filtered(options::OPT_Xclang)) {
+      Arg->claim();
+      if (StringRef(Arg->getValue()) != "-finclude-default-header")
+        CmdArgs.push_back(Arg->getValue());
+    }
+  }
+  else {
+    Args.AddAllArgValues(CmdArgs, options::OPT_Xclang);
+  }
+
   for (const Arg *A : Args.filtered(options::OPT_mllvm)) {
     A->claim();
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30743.91600.patch
Type: text/x-patch
Size: 1217 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170313/6283f629/attachment.bin>


More information about the cfe-commits mailing list