<div dir="ltr">Many thanks!<div><br></div><div>Regards</div><div><br></div><div>Guansong</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 15, 2017 at 7:55 PM, Eric Christopher <span dir="ltr"><<a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Guansong,<div><br></div><div>So this wasn't quite the right way to write this testcase. You really wanted a CHECK/CHECK-NOT line along with the actual commands. You also didn't want to (as you noticed later) depend on full compilation. You can check for this sort of thing in the future by using the -### command line option to get the subcommands that clang -would- invoke if it were actually going to do it.</div><div><br></div><div>I've gone ahead and fixed this thusly:</div><div><div>Committing to <a href="https://llvm.org/svn/llvm-project/cfe/trunk" target="_blank">https://llvm.org/svn/llvm-<wbr>project/cfe/trunk</a> ...</div><div><span class="m_-4895029564489343043Apple-tab-span" style="white-space:pre-wrap"> </span>M<span class="m_-4895029564489343043Apple-tab-span" style="white-space:pre-wrap"> </span>test/Driver/<a href="http://include-default-header.cl" target="_blank">include-default-<wbr>header.cl</a></div><div>Committed r297917</div></div><div><br></div><div>Thanks!</div><div><br></div><div>-eric</div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Mar 15, 2017 at 2:09 PM Guansong Zhang via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: guansong<br class="m_-4895029564489343043gmail_msg">
Date: Wed Mar 15 15:57:11 2017<br class="m_-4895029564489343043gmail_msg">
New Revision: 297890<br class="m_-4895029564489343043gmail_msg">
<br class="m_-4895029564489343043gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=297890&view=rev" rel="noreferrer" class="m_-4895029564489343043gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=297890&view=rev</a><br class="m_-4895029564489343043gmail_msg">
Log:<br class="m_-4895029564489343043gmail_msg">
enable -save-temps with -finclude-defult-header<br class="m_-4895029564489343043gmail_msg">
<br class="m_-4895029564489343043gmail_msg">
Currently the two flags can not work together.<br class="m_-4895029564489343043gmail_msg">
<br class="m_-4895029564489343043gmail_msg">
To illustrate the issue, we can have an one line file <a href="http://a.cl" rel="noreferrer" class="m_-4895029564489343043gmail_msg" target="_blank">a.cl</a> contains only an empty function<br class="m_-4895029564489343043gmail_msg">
<br class="m_-4895029564489343043gmail_msg">
cat <a href="http://a.cl" rel="noreferrer" class="m_-4895029564489343043gmail_msg" target="_blank">a.cl</a><br class="m_-4895029564489343043gmail_msg">
<br class="m_-4895029564489343043gmail_msg">
void test(){}<br class="m_-4895029564489343043gmail_msg">
<br class="m_-4895029564489343043gmail_msg">
Then use<br class="m_-4895029564489343043gmail_msg">
<br class="m_-4895029564489343043gmail_msg">
clang -v -save-temps -x cl -Xclang -cl-std=CL2.0 -Xclang -finclude-default-header -target amdgcn -S -c <a href="http://a.cl" rel="noreferrer" class="m_-4895029564489343043gmail_msg" target="_blank">a.cl</a><br class="m_-4895029564489343043gmail_msg">
<br class="m_-4895029564489343043gmail_msg">
we will get redefinition errors for various things.<br class="m_-4895029564489343043gmail_msg">
<br class="m_-4895029564489343043gmail_msg">
The reason is that the -finclude-default-header flag is not meant to be on cc1 command other than the preprocessor.<br class="m_-4895029564489343043gmail_msg">
<br class="m_-4895029564489343043gmail_msg">
The fix is modeled after the code just below the change to filter the -finclude-default-header flag out when we are not in the preprocess phase.<br class="m_-4895029564489343043gmail_msg">
<br class="m_-4895029564489343043gmail_msg">
Differential Revision: <a href="https://reviews.llvm.org/D30743" rel="noreferrer" class="m_-4895029564489343043gmail_msg" target="_blank">https://reviews.llvm.org/<wbr>D30743</a><br class="m_-4895029564489343043gmail_msg">
<br class="m_-4895029564489343043gmail_msg">
Added:<br class="m_-4895029564489343043gmail_msg">
cfe/trunk/test/Driver/<a href="http://include-default-header.cl" rel="noreferrer" class="m_-4895029564489343043gmail_msg" target="_blank">include-<wbr>default-header.cl</a><br class="m_-4895029564489343043gmail_msg">
Modified:<br class="m_-4895029564489343043gmail_msg">
cfe/trunk/lib/Driver/<wbr>ToolChains/Clang.cpp<br class="m_-4895029564489343043gmail_msg">
<br class="m_-4895029564489343043gmail_msg">
Modified: cfe/trunk/lib/Driver/<wbr>ToolChains/Clang.cpp<br class="m_-4895029564489343043gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=297890&r1=297889&r2=297890&view=diff" rel="noreferrer" class="m_-4895029564489343043gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Driver/<wbr>ToolChains/Clang.cpp?rev=<wbr>297890&r1=297889&r2=297890&<wbr>view=diff</a><br class="m_-4895029564489343043gmail_msg">
==============================<wbr>==============================<wbr>==================<br class="m_-4895029564489343043gmail_msg">
--- cfe/trunk/lib/Driver/<wbr>ToolChains/Clang.cpp (original)<br class="m_-4895029564489343043gmail_msg">
+++ cfe/trunk/lib/Driver/<wbr>ToolChains/Clang.cpp Wed Mar 15 15:57:11 2017<br class="m_-4895029564489343043gmail_msg">
@@ -4268,7 +4268,19 @@ void Clang::ConstructJob(<wbr>Compilation &C,<br class="m_-4895029564489343043gmail_msg">
<br class="m_-4895029564489343043gmail_msg">
// Forward -Xclang arguments to -cc1, and -mllvm arguments to the LLVM option<br class="m_-4895029564489343043gmail_msg">
// parser.<br class="m_-4895029564489343043gmail_msg">
- Args.AddAllArgValues(CmdArgs, options::OPT_Xclang);<br class="m_-4895029564489343043gmail_msg">
+ // -finclude-default-header flag is for preprocessor,<br class="m_-4895029564489343043gmail_msg">
+ // do not pass it to other cc1 commands when save-temps is enabled<br class="m_-4895029564489343043gmail_msg">
+ if (C.getDriver().<wbr>isSaveTempsEnabled() &&<br class="m_-4895029564489343043gmail_msg">
+ !isa<PreprocessJobAction>(JA)) {<br class="m_-4895029564489343043gmail_msg">
+ for (auto Arg : Args.filtered(options::OPT_<wbr>Xclang)) {<br class="m_-4895029564489343043gmail_msg">
+ Arg->claim();<br class="m_-4895029564489343043gmail_msg">
+ if (StringRef(Arg->getValue()) != "-finclude-default-header")<br class="m_-4895029564489343043gmail_msg">
+ CmdArgs.push_back(Arg-><wbr>getValue());<br class="m_-4895029564489343043gmail_msg">
+ }<br class="m_-4895029564489343043gmail_msg">
+ }<br class="m_-4895029564489343043gmail_msg">
+ else {<br class="m_-4895029564489343043gmail_msg">
+ Args.AddAllArgValues(CmdArgs, options::OPT_Xclang);<br class="m_-4895029564489343043gmail_msg">
+ }<br class="m_-4895029564489343043gmail_msg">
for (const Arg *A : Args.filtered(options::OPT_<wbr>mllvm)) {<br class="m_-4895029564489343043gmail_msg">
A->claim();<br class="m_-4895029564489343043gmail_msg">
<br class="m_-4895029564489343043gmail_msg">
<br class="m_-4895029564489343043gmail_msg">
Added: cfe/trunk/test/Driver/<a href="http://include-default-header.cl" rel="noreferrer" class="m_-4895029564489343043gmail_msg" target="_blank">include-<wbr>default-header.cl</a><br class="m_-4895029564489343043gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/include-default-header.cl?rev=297890&view=auto" rel="noreferrer" class="m_-4895029564489343043gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/test/Driver/<wbr>include-default-header.cl?rev=<wbr>297890&view=auto</a><br class="m_-4895029564489343043gmail_msg">
==============================<wbr>==============================<wbr>==================<br class="m_-4895029564489343043gmail_msg">
--- cfe/trunk/test/Driver/<a href="http://include-default-header.cl" rel="noreferrer" class="m_-4895029564489343043gmail_msg" target="_blank">include-<wbr>default-header.cl</a> (added)<br class="m_-4895029564489343043gmail_msg">
+++ cfe/trunk/test/Driver/<a href="http://include-default-header.cl" rel="noreferrer" class="m_-4895029564489343043gmail_msg" target="_blank">include-<wbr>default-header.cl</a> Wed Mar 15 15:57:11 2017<br class="m_-4895029564489343043gmail_msg">
@@ -0,0 +1,4 @@<br class="m_-4895029564489343043gmail_msg">
+// RUN: %clang -v -save-temps -x cl -Xclang -cl-std=CL2.0 -Xclang -finclude-default-header -target amdgcn -S -c %s<br class="m_-4895029564489343043gmail_msg">
+<br class="m_-4895029564489343043gmail_msg">
+void test() {}<br class="m_-4895029564489343043gmail_msg">
+<br class="m_-4895029564489343043gmail_msg">
<br class="m_-4895029564489343043gmail_msg">
<br class="m_-4895029564489343043gmail_msg">
______________________________<wbr>_________________<br class="m_-4895029564489343043gmail_msg">
cfe-commits mailing list<br class="m_-4895029564489343043gmail_msg">
<a href="mailto:cfe-commits@lists.llvm.org" class="m_-4895029564489343043gmail_msg" target="_blank">cfe-commits@lists.llvm.org</a><br class="m_-4895029564489343043gmail_msg">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" class="m_-4895029564489343043gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br class="m_-4895029564489343043gmail_msg">
</blockquote></div>
</blockquote></div><br></div>