[cfe-commits] [PATCH] Member reference fixit (bug 6800)

Aaron Ballman aaron at aaronballman.com
Wed Feb 1 15:49:03 PST 2012


Ping?

~Aaron

On Fri, Jan 27, 2012 at 6:18 AM, Aaron Ballman <aaron at aaronballman.com> wrote:
> On Tue, Jan 24, 2012 at 6:54 PM, Douglas Gregor <dgregor at apple.com> wrote:
>>
>> On Jan 21, 2012, at 11:42 PM, Aaron Ballman wrote:
>>
>>> I've attached a patch to fix bug 6800 (and test cases) so that a
>>> proper fixit is output when dereferencing using -> instead of .  We
>>> were missing the fixit when looking up overloaded operator -> and
>>> emitting a diagnostic.
>>
>> This goes in the right direction, but there's a bit more we need. We only emit a Fix-It when the compiler can recover as if you had typed when we're suggesting. In this case, we'll still end up returning an error expression, which suppresses a lot of important type checking. In this particular case, we'd need to communicate up to the caller that the user meant to type a "." but typed an "->" instead.
>
> I've been trying various ways to implement this, but what I'm finding
> is that by attempting to recover, the error gets re-generated
> elsewhere (SemaMemberExpr.cpp's LookupMemberExpr to be exact).  So we
> end up emitting the diagnostic twice in that scenario.
>
>> Moreover, you should customize the error message in this case. Perhaps something like "type %0 is not a pointer and does not have an overloaded 'operator->'; did you mean to use '.'?".
>
> Good call!
>
> I've attached a second attempt, but because I am leaving out the
> diagnostic for operator-> (so as not to get duplicate diagnostics), I
> don't think I've quite got it right.  If you have suggestions, I'd
> love to hear them.
>
> Thanks!
>
> ~Aaron
-------------- next part --------------
A non-text attachment was scrubbed...
Name: member_ref_fixit 2.patch
Type: application/octet-stream
Size: 4769 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120201/95961bb9/attachment.obj>


More information about the cfe-commits mailing list