[cfe-dev] RFC: Extra source location information for dependent types

Chris Lattner clattner at apple.com
Wed Apr 1 22:37:35 PDT 2009


On Apr 1, 2009, at 10:05 PM, Douglas Gregor wrote:
>> I'm fine with this on general principles, and actually have assumed  
>> that we would get this at some point someday anyway.  I always  
>> assumed that it would take the form of an optional flag to sema  
>> that enables full source location info for all types.  This would  
>> cause sema to create a "PointerTypeWithLoc" type instead of a  
>> PointerType node.  The former would just be a sugared version of  
>> the type whose canonical version would desugar down to the pointer  
>> type, so all semantic clients would be fine.  This would be  
>> incredibly useful for some clients, such as a refactoring tool.
>
> As much as I dislike the idea of having a flag that changes the AST  
> representation, I do think this makes sense.

In a refactoring tool, this is very useful: you can parse the code the  
"fast" way to build whole program symbol databases etc.  When you  
decide you need to do rewriting on a specific file, you can go back  
and reparse it in "full loc" mode, etc.

>> I am really concerned about doing this unconditionally, and by  
>> default.  I'm actually much less concerned about doing this for  
>> dependent types and those derived from a dependent type.  Is there  
>> a constant time operation to tell if a random type is dependent?
>
> Yes, isDependentType is constant time.

Awesome.

>> It would probably be best to implement this as an optional opt-in  
>> thing as described above, and then consider turning it on for  
>> dependent types.  What do you think?
>
> I think that makes sense. We'll want to do the performance tests  
> each way and weigh the advantages/disadvantages.

Sounds great!

-Chris



More information about the cfe-dev mailing list