[cfe-dev] My first patch to clang

Nicola Gigante nicola.gigante at gmail.com
Sat Dec 5 06:22:43 PST 2009


Il giorno 04/dic/2009, alle ore 22.20, John McCall ha scritto:
> 
> I see a few issues with this patch, mostly minor.
> 
> The first is that we like to have reasonably high confidence in our suggestions.  There are plenty of pointer base types where changing '.' into '->' won't actually help;  for example, int*, struct foo**, etc.  We shouldn't recommend using '->' unless the base is specifically a pointer to a record type.
> 
> The second is that fixits should be aligned with error-recovery whenever possible.  In this case, that means that if we're doing to give a fixit for transforming the '.' into the '->', we should then proceed to do the member lookup, build the expression, etc. as if the user had typed '->'.  It looks like you can make that work very easily:  just (1) pass IsArrow to LookupMemberExpr by reference instead of by value, (2) try to diagnose this error *before* the block in LookupMemberExpr that calls LookupMemberInRecord, and (3) set IsArrow = true when you diagnose.
> 

Ok, I've tried to do what you suggested. The new patch is attached. 
Now it seems to generate the new diagnostic only with record types, as expected.

However, I'm not very sure about the error recovery.
Generally speaking, how does it work in clang? In the case of recoverable errors, the lexer/parser/sema code continues as the user had typed the right code?

Thanks,
Nicola

-------------- next part --------------
A non-text attachment was scrubbed...
Name: member_pointer_suggestion.patch
Type: application/octet-stream
Size: 3398 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20091205/396ce2ce/attachment.obj>
-------------- next part --------------



More information about the cfe-dev mailing list