<div dir="ltr">I modified the test so that it now catches all cases:<div><div><ul><li>no remove_if (and thus no erase) : fail<br></li><li>remove_if : fail<br></li><li>remove_if + erase : pass<br></li></ul>The test is however not robust in face of appending more options in the stripPositionalArgs : for now it has the minimal number of '-no-integrated-as' to catch the issues we have had, and we could add some more to have a reasonnable margin. Thoughts ?</div>
</div><div><br></div><div>Cheers,</div><div>--</div><div>Arnaud</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, May 1, 2014 at 2:57 AM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</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"><div class="gmail_extra"><div class="gmail_quote"><div class="">On Wed, Apr 30, 2014 at 4:31 PM, Arnaud Allard de Grandmaison <span dir="ltr"><<a href="mailto:arnaud.adegm@gmail.com" target="_blank">arnaud.adegm@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">Dumping Args before & after the remove_if shows that Jordan is right:<div><div> - before: Args: clang-tool -target x86_64 -no-integrated-as -c -v -c placeholder.cpp</div>
<div> - after: Args: clang-tool -target x86_64 -c -v -c placeholder.cpp placeholder.cpp</div>
</div><div>and later on, _all_ input files are dropped. So we were just lucky.</div><div><br></div><div>The code in stripPositionalArgs appends some arguments (-c placeholder.cpp), so I can not force -no-integrated-as to be last from the command line.</div>
<div><br></div><div> This would require to adapt stripPositionalArgs so that it prepends its arguments and we can test for the missing erase. Do we still want a testcase for that ? It seems a bit like an overshoot to me, but I aggree that there as been several incorrect commits in the same place. </div>
</div></blockquote><div><br></div></div><div>Easier test: add -no-integrated-as *repeatedly*. If you add it enough times, it'll be in the tail of unchanged elements left behind by remove_if.</div><div><div class="h5">
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div><div class="gmail_extra"><div class="gmail_quote">On Thu, May 1, 2014 at 12:46 AM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</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"><div class="gmail_extra"><div class="gmail_quote"><div>On Wed, Apr 30, 2014 at 3:40 PM, Arnaud Allard de Grandmaison <span dir="ltr"><<a href="mailto:arnaud.adegm@gmail.com" target="_blank">arnaud.adegm@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">I have not been able to come up with a testcase which does better than what test/Tooling/multi-jobs.cpp already does.<div>
<br></div><div>The current test status:</div><div> 1. no remove_if (and thus no erase) : multi-jobs fails</div>
<div> 2. remove_if : multi-jobs pass</div><div> 3. remove_if + erase : multi-jobs pass<br><div><br></div><div>Invoking clang-check with '-v' shows that in cases 2 & 3 the -no-integrated-as has been dropped. I feel a bit like hunting a red herring there : depending on the argument position, it gets dropped or not. Jordan's hypothesis is probably right.</div>
</div></div></blockquote><div><br></div></div><div>Try putting it at the end of the command line.</div><div><div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div><div>Cheers,</div><div>--</div><div>Arnaud</div><div><br></div><div><br></div><div><br></div></div></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Apr 30, 2014 at 11:30 PM, Jordan Rose <span dir="ltr"><<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>My hypothesis for how this was working: std::remove_if reorders elements using std::move, so we were getting lucky that -no-integrated-as wasn't the last argument and something else got moved on top of it. We'd have duplicates of the last few arguments (because they got moved earlier), but that wouldn't show -no-integrated-as.</div>
<span><font color="#888888"><div><br></div><div>Jordan</div></font></span><div><div><div><br></div><br><div><div>On Apr 30, 2014, at 14:09, Richard Smith <<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>> wrote:</div>
<br><blockquote type="cite"><div dir="ltr">This needs a test case. This code has already been committed, incorrectly, twice before this revision; the existing test case clearly doesn't actually cover it properly.</div>
<div class="gmail_extra"><br>
<br><div class="gmail_quote">On Wed, Apr 30, 2014 at 12:59 PM, Arnaud A. de Grandmaison <span dir="ltr"><<a href="mailto:arnaud.adegm@gmail.com" target="_blank">arnaud.adegm@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: aadg<br>
Date: Wed Apr 30 14:59:22 2014<br>
New Revision: 207696<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=207696&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=207696&view=rev</a><br>
Log:<br>
PR19601: std::remove_if does not really remove the elements.<br>
<br>
It moves them at the end of the range instead, so an extra erase is needed.<br>
<br>
It is strange that this code works without the erase. On the other hand, removing the remove_if will make fail some tests.<br>
<br>
Modified:<br>
cfe/trunk/lib/Tooling/CompilationDatabase.cpp<br>
<br>
Modified: cfe/trunk/lib/Tooling/CompilationDatabase.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/CompilationDatabase.cpp?rev=207696&r1=207695&r2=207696&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/CompilationDatabase.cpp?rev=207696&r1=207695&r2=207696&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Tooling/CompilationDatabase.cpp (original)<br>
+++ cfe/trunk/lib/Tooling/CompilationDatabase.cpp Wed Apr 30 14:59:22 2014<br>
@@ -238,8 +238,9 @@ static bool stripPositionalArgs(std::vec<br>
<br>
// Remove -no-integrated-as; it's not used for syntax checking,<br>
// and it confuses targets which don't support this option.<br>
- std::remove_if(Args.begin(), Args.end(),<br>
- MatchesAny(std::string("-no-integrated-as")));<br>
+ Args.erase(std::remove_if(Args.begin(), Args.end(),<br>
+ MatchesAny(std::string("-no-integrated-as"))),<br>
+ Args.end());<br>
<br>
const std::unique_ptr<driver::Compilation> Compilation(<br>
NewDriver->BuildCompilation(Args));<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>
_______________________________________________<br>cfe-commits mailing list<br><a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div></div></div><br></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div></div></div><br></div></div>
</blockquote></div><br></div>