<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Mon, Aug 28, 2017 at 7:35 PM Adam Nemet <<a href="mailto:anemet@apple.com">anemet@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div></div><div>It's been a while but I think it has to do with using the same function to parse and emit the class. So naturally it takes a reference.</div></div></blockquote><div><br>Yeah, leaky abstraction. op<< is clearly output only, but the implementation detail of using the same function for input as output leaks into this interface. <br><br>That's really awkward. :/ Hope someone fixes it.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div><br></div><div>In addition we stream opt remarks as pointers so that at parse time we can construct the right object from the class hierarchy.  (I know we only emit these currently and never parse but I did not want to do something that outright  prevented that.)</div></div><div dir="auto"><div><br>On Aug 28, 2017, at 6:32 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">Ah, why does it do that?</div><br><div class="gmail_quote"><div dir="ltr">On Mon, Aug 28, 2017 at 6:31 PM Adam Nemet <<a href="mailto:anemet@apple.com" target="_blank">anemet@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div></div><div><br></div><div><br>On Aug 28, 2017, at 5:16 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">Does this even need the variable then?</div></div></blockquote><div><br></div></div><div dir="auto"><div>Yes. As the new comment says << takes a reference to a pointer -- we need an lvalue. </div></div><div dir="auto"><br><blockquote type="cite"><div><div dir="ltr"> Maybe easier to read as:<br><br>  *Out << &OptDiagBase;<br><br>(& even drop the {} around the if (& while you're there, maybe roll the 'Out' into the if condition, if it's not used after the 'if'))</div><br><div class="gmail_quote"><div dir="ltr">On Mon, Aug 28, 2017 at 4:01 PM Adam Nemet via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-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: anemet<br>
Date: Mon Aug 28 16:00:13 2017<br>
New Revision: 311948<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=311948&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=311948&view=rev</a><br>
Log:<br>
Remove an unnecessary const_cast.<br>
<br>
I think that this is dating back to when emit used to take a const reference.<br>
<br>
Modified:<br>
    llvm/trunk/lib/Analysis/OptimizationDiagnosticInfo.cpp<br>
<br>
Modified: llvm/trunk/lib/Analysis/OptimizationDiagnosticInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/OptimizationDiagnosticInfo.cpp?rev=311948&r1=311947&r2=311948&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/OptimizationDiagnosticInfo.cpp?rev=311948&r1=311947&r2=311948&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Analysis/OptimizationDiagnosticInfo.cpp (original)<br>
+++ llvm/trunk/lib/Analysis/OptimizationDiagnosticInfo.cpp Mon Aug 28 16:00:13 2017<br>
@@ -165,7 +165,8 @@ void OptimizationRemarkEmitter::emit(<br>
<br>
   yaml::Output *Out = F->getContext().getDiagnosticsOutputFile();<br>
   if (Out) {<br>
-    auto *P = const_cast<DiagnosticInfoOptimizationBase *>(&OptDiagBase);<br>
+    // For remarks the << operator takes a reference to a pointer.<br>
+    auto *P = &OptDiagBase;<br>
     *Out << P;<br>
   }<br>
   // FIXME: now that IsVerbose is part of DI, filtering for this will be moved<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>
</div></blockquote></div></blockquote></div>
</div></blockquote></div></blockquote></div></div>