[cfe-dev] My first patch to clang

Douglas Gregor dgregor at apple.com
Fri Dec 4 16:46:21 PST 2009

On Dec 4, 2009, at 3:06 PM, Chris Lattner wrote:

> On Dec 4, 2009, at 1:20 PM, John McCall wrote:
>> On Dec 4, 2009, at 8:37 AM, Nicola Gigante wrote:
>>> Hello,
>>> as promised I've started to look at how clang works under the hood.
>>> My first "kid job" was to implement a simple diagnostic improvement
>>> that suggests to use -> instead of . if the base expression is a
>>> pointer. You find the patch attached.
>> Great idea!  We have some similar-in-concept diagnostics/fixits, but
>> not this one specifically.
>> 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.
> "pointer to a record type for which the field would be valid".  We
> might as well test that the field makes sense as well.

If we don't do the validity check, then we can double-recover from a  

   struct X {
     void setValue(int);

   void f(X *xp) {


	- Doug

More information about the cfe-dev mailing list