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

Guansong Zhang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 15 14:11:43 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL297890: enable -save-temps with -finclude-defult-header (authored by guansong).

Changed prior to commit:
  https://reviews.llvm.org/D30743?vs=91718&id=91935#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30743

Files:
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/test/Driver/include-default-header.cl


Index: cfe/trunk/test/Driver/include-default-header.cl
===================================================================
--- cfe/trunk/test/Driver/include-default-header.cl
+++ cfe/trunk/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: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -4268,7 +4268,19 @@
 
   // Forward -Xclang arguments to -cc1, and -mllvm arguments to the LLVM option
   // parser.
-  Args.AddAllArgValues(CmdArgs, options::OPT_Xclang);
+  // -finclude-default-header flag is for preprocessor,
+  // do not pass it to other cc1 commands when save-temps is enabled
+  if (C.getDriver().isSaveTempsEnabled() &&
+      !isa<PreprocessJobAction>(JA)) {
+    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.91935.patch
Type: text/x-patch
Size: 1332 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170315/e6585d3b/attachment.bin>


More information about the cfe-commits mailing list