[cfe-dev] Source information for types

Argyrios Kyrtzidis kyrtzidis at apple.com
Wed Jul 8 16:34:14 PDT 2009

On Jul 8, 2009, at 3:53 PM, Eli Friedman wrote:

> On Wed, Jul 8, 2009 at 1:28 PM, Argyrios  
> Kyrtzidis<kyrtzidis at apple.com> wrote:
>> I'd like to make a proposal for keeping source location information
>> for types in the AST, to allow functionality like "find the source
>> locations where this typedef is used".
> I'm pretty sure you can do this already: you can recurse into a type
> to find typedefs, getTypeSpecStartLoc returns the start of the
> declaration specifiers, and you can re-lex the source and figure out
> the precise location of the typedef name from there.  It might be nice
> to provide utility methods to do this, but I don't see any need for
> any core changes.

Might be simple for a single typedef name but it doesn't work well  
with C++ types like this:

std::vector< my_template< my_namespace::my_type, my_variable > >

Ideally all the type source info for the above type would be readily  
available from the AST; recomputing all the information from the  
tokens isn't practical, Sema already did the hard work, we just need  
to store it.

> Also, your suggestion doesn't really address where exactly you plan to
> store your flag; there aren't any spare bits in QualType.

The flag is just a boolean to pass to Sema to tell it whether to  
create SourceTypes or not. If the flag is false, Sema will discard the  
source info and just pass QualTypes to the Decls, as it currently does.


More information about the cfe-dev mailing list