<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 18, 2015 at 8:28 PM, David Blaikie via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">dblaikie added inline comments.<br>
<span class=""><br>
================<br>
Comment at: include/clang/Basic/Diagnostic.h:936-937<br>
@@ -935,3 +935,4 @@<br>
public:<br>
/// Copy constructor. When copied, this "takes" the diagnostic info from the<br>
/// input and neuters it.<br>
+ DiagnosticBuilder(DiagnosticBuilder &&D) {<br>
----------------<br>
</span><span class="">rsmith wrote:<br>
> Comment is out of date.<br>
</span>Updated the wording a bit - the scare quotes and somewhat-vague "neuter" seemed unhelpful. Hopefully my rephrasing is an improvement, but I can restore the old or alternate wording if you prefer.<br>
<span class=""><br>
================<br>
Comment at: include/clang/Sema/Sema.h:1085-1092<br>
@@ -1084,10 +1084,10 @@<br>
<br>
/// Teach operator<< to produce an object of the correct type.<br>
template<typename T><br>
friend const SemaDiagnosticBuilder &operator<<(<br>
const SemaDiagnosticBuilder &Diag, const T &Value) {<br>
const DiagnosticBuilder &BaseDiag = Diag;<br>
BaseDiag << Value;<br>
return Diag;<br>
}<br>
};<br>
----------------<br>
</span><span class="">rsmith wrote:<br>
> If we only need to support value category preservation for `SemaDiagnosticBuilder`, can we duplicate this template for the `SemaDiagnosticBuilder &&operator<<(SemaDiagnosticBuilder &&Diag, const T &Value)` case?<br>
</span>Ah, good idea - that seems to totally work and removes the need for all the mechanical changes. (the handful of non-Sema diag cleanups in a few places (including clang-tidy) remain)<br>
<span class=""><br>
================<br>
Comment at: lib/Parse/Parser.cpp:163-170<br>
@@ -162,5 +162,10 @@<br>
<br>
- DiagnosticBuilder DB =<br>
- Spelling<br>
- ? Diag(EndLoc, DiagID) << FixItHint::CreateInsertion(EndLoc, Spelling)<br>
- : Diag(Tok, DiagID);<br>
+ DiagnosticBuilder DB = [&]() {<br>
+ if (!Spelling)<br>
+ return Diag(Tok, DiagID);<br>
+<br>
+ auto D = Diag(EndLoc, DiagID);<br>
+ D << FixItHint::CreateInsertion(EndLoc, Spelling);<br>
+ return D;<br>
+ }();<br>
+<br>
----------------<br>
</span><span class="">rsmith wrote:<br>
> This one might be more readable as<br>
><br>
> DiagnosticBuilder DB = std::move(Spelling ? ... : ...);<br>
><br>
> Thoughts?<br>
</span>Tried a few things here (move inside or outside the conditional operator) and none of it works. op<< takes its first arg by const ref (so that it can successfully take a temporary) and then returns it by const ref too - so we'd have to cast away constness before we could move from it.<br></blockquote><div><br>I suppose my original change could allow us to change the op<<'s to take by non-const ref and return by non-const ref, thus making this code fixable with std::move? Though that'd be even more invasive (but help remove the oddity of << mutating const objects... might eventually be able to make DiagnosticBuilder's members non-mutable... )<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Thoughts? Alternative approaches?<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<a href="http://reviews.llvm.org/D12131" rel="noreferrer" target="_blank">http://reviews.llvm.org/D12131</a><br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</div></div></blockquote></div><br></div></div>