guansong updated this revision to Diff 91718.
guansong added a comment.
Thanks, update as suggested.
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);
+ // -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();
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);
+ // -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();
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits