<div dir="auto"><div>Hi!</div><div dir="auto"><br></div><div dir="auto">A bit of an off-topic note beforehand: Why not add a space inside of parens?</div><div dir="auto"><br></div><div dir="auto">Fixits are actually pretty straightforward to implement. It's like this:</div><div dir="auto"><br></div><div dir="auto">Diag(ErrorLoc, diag::err_missing_foo) << VarName // some diagnostic, unchanged</div><div dir="auto"><< FixItHint::CreateInsertion(ErrorLoc, " foo");</div><div dir="auto"><br></div><div dir="auto">This creates a diagnostic with a fixit at ErrorLoc and inserts foo there. There are other fixit hints that you can use like replacement.<span style="background-color:rgb(255,255,255);font-size:medium;white-space:pre-wrap"><br></span><br>Hope that helps!<br><br><div class="gmail_quote" dir="auto"><div dir="ltr">On Wed, Dec 12, 2018, 11:03 AM Andy Gibbs via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@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">




<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Hi,</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I'd like to add a fixit (or two) to suggest parentheses in the following expressions:</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<div>
<div><span style="color:rgb(0,0,255);font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">  struct</span><span style="font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal"> S {
</span><span style="color:rgb(0,0,255);font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">float</span><span style="font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal"> value; };</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">  S
</span><span style="color:rgb(0,0,255);font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">operator</span><span style="color:rgb(163,21,21);font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">""</span><span style="font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">
 _f(</span><span style="color:rgb(0,0,255);font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">long</span><span style="font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">
</span><span style="color:rgb(0,0,255);font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">double</span><span style="font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal"> t);</span></div>
<br>
<div><span style="font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal"> 
</span><span style="color:rgb(0,0,255);font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">void</span><span style="font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal"> test() {</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">   
</span><span style="color:rgb(0,0,255);font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">int</span><span style="font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal"> i =
</span><span style="color:rgb(48,48,192);font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">0x2e</span><span style="font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">+</span><span style="color:rgb(163,21,21);font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">'a'</span><span style="font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">;         
 // fixit: (0x2e)+'a'<br>
</span></div>
<span style="font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">   
</span><span style="color:rgb(0,0,255);font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">float</span><span style="font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal"> j =
</span><span style="color:rgb(9,136,90);font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">100.0</span><span style="font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">_e-</span><span style="color:rgb(9,136,90);font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">10.0</span><span style="font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">;   
 // fixit: (100.0_e)-10.0<br>
</span>
<div><span style="font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">   
</span><span style="color:rgb(0,0,255);font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">float</span><span style="font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal"> k =
</span><span style="color:rgb(9,136,90);font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">100.0</span><span style="font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">_f.value;   // fixit: (100.0_f).value<br>
</span></div>
<div><span style="font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">   
</span><span style="color:rgb(0,0,255);font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">int</span><span style="font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal"> l =
</span><span style="color:rgb(48,48,192);font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">0x2e</span><span style="font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">+i;            // fixit:
 (0x2e)+i<br>
</span></div>
<div><span></span></div>
</div>
<span style="font-family:Consolas,Courier,monospace;font-size:10pt;line-height:normal">  }</span><br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
However, I am not sure of the correct way to do this.</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Would someone, please, give me a quick tutorial or, if easier, point out an similar example in the clang code.</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Many thanks,</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Andy<br>
</div>
</div>

_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank" rel="noreferrer">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div></div></div>