<div dir="ltr">On Fri, Jul 12, 2013 at 4:01 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank" onclick="window.open('https://mail.google.com/mail/?view=cm&tf=1&to=richard@metafoo.co.uk&cc=&bcc=&su=&body=','_blank');return false;" class="cremed">richard@metafoo.co.uk</a>></span> wrote:<br>
<div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="">
<div class="h5">On Fri, Jul 12, 2013 at 3:16 PM, Kaelyn Uhrain <<a href="mailto:rikka@google.com" target="_blank" onclick="window.open('https://mail.google.com/mail/?view=cm&tf=1&to=rikka@google.com&cc=&bcc=&su=&body=','_blank');return false;" class="cremed">rikka@google.com</a>> wrote:<br>
> On Thu, Jul 11, 2013 at 10:16 PM, Nico Weber <<a href="mailto:thakis@chromium.org" target="_blank" onclick="window.open('https://mail.google.com/mail/?view=cm&tf=1&to=thakis@chromium.org&cc=&bcc=&su=&body=','_blank');return false;" class="cremed">thakis@chromium.org</a>> wrote:<br>
>><br>>> Nice, thanks!<br>>><br>>> On Thu, Jul 11, 2013 at 3:38 PM, Kaelyn Uhrain <<a href="mailto:rikka@google.com" target="_blank" onclick="window.open('https://mail.google.com/mail/?view=cm&tf=1&to=rikka@google.com&cc=&bcc=&su=&body=','_blank');return false;" class="cremed">rikka@google.com</a>> wrote:<br>
>>><br>>>> Author: rikka<br>
>>> Date: Thu Jul 11 17:38:30 2013<br>>>> New Revision: 186128<br>>>><br>>>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=186128&view=rev" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project?rev=186128&view=rev</a><br>
>>> Log:<br>>>> Provide a fixit hint for changing '->' to '.' if there is no operator-><br>>>> defined for a class.<br>>>><br>>>> Modified:<br>>>> cfe/trunk/lib/Sema/SemaOverload.cpp<br>
>>> cfe/trunk/test/FixIt/fixit.cpp<br>>>><br>>>> Modified: cfe/trunk/lib/Sema/SemaOverload.cpp<br>>>> URL:<br>>>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=186128&r1=186127&r2=186128&view=diff" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=186128&r1=186127&r2=186128&view=diff</a><br>
>>><br>>>> ==============================================================================<br>>>> --- cfe/trunk/lib/Sema/SemaOverload.cpp (original)<br>>>> +++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Jul 11 17:38:30 2013<br>
>>> @@ -11353,10 +11353,17 @@ Sema::BuildOverloadedArrowExpr(Scope *S,<br>>>> break;<br>>>><br>>>> case OR_No_Viable_Function:<br>>>> - if (CandidateSet.empty())<br>
>>> - Diag(OpLoc, diag::err_typecheck_member_reference_arrow)<br>>>> - << Base->getType() << Base->getSourceRange();<br>>>> - else<br>>>> + if (CandidateSet.empty()) {<br>
>>> + QualType BaseType = Base->getType();<br>>>> + if (BaseType->isRecordType() && !BaseType->isPointerType()) {<br>>>> + Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)<br>
>>> + << BaseType << 1 << Base->getSourceRange()<br>>>> + << FixItHint::CreateReplacement(OpLoc, ".");<br>>><br>>><br>>> Since this is a fixit on an error, don't you need to fix up the AST?<br>
>> (<a href="http://clang.llvm.org/docs/InternalsManual.html#fix-it-hints" target="_blank" class="cremed">http://clang.llvm.org/docs/InternalsManual.html#fix-it-hints</a>)<br>><br>><br>> This is a tricky case because of how operator-> is recursively applied to<br>
> it's own result... from what I could tell, recovery would require not just<br>> breaking out of the loop for operator-> in ActOnStartCXXMemberReference but<br>> also telling the parser to start over with the '.' in place of the '->',<br>
> which I have no idea how to do from several function-call-layers within<br>> Sema. And I couldn't add the fixit to a note as the internals manual<br>> suggests since there is no note associated with the diagnostic.<br>
<br></div></div>We usually handle these cases by adding a note to carry the fixit:<br><br><font face="courier new, monospace">error: member reference type 'PR15045::Cl0' is not a pointer<br> return c->a;<br>
^<br>
note: did you mean to use '.' instead?<br> return c->a;</font><div><font face="courier new, monospace"> ~~<br> .</font></div>
</blockquote></div><br></div><div class="gmail_extra">Ah, I see! Just submitted r186342 to move the fixit into a separate note. Thanks Richard!<br></div></div>