<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body 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">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>Yes. As the new comment says << takes a reference to a pointer -- we need an lvalue. </div><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">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></body></html>