[cfe-dev] RFC: Extra source location information for dependent types
Chris Lattner
clattner at apple.com
Wed Apr 1 21:26:17 PDT 2009
On Mar 31, 2009, at 2:31 PM, Douglas Gregor wrote:
> Template instantiation for class templates and types is starting to
> shape up. One problem I'm seeing now is that we don't retain enough
> source location information in the type system to do a good job with
> instantiation.
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 we've previously discussed this would also be a good way to shake
out bugs where clients might be looking at the non-canonical version
of a type accidentally: with this optional flag, no types would be
canonical :)
>> Both of these have SourceLocation info contained within their
>> expression. That said, what specific Type classes do you anticipate
>> adding source location information? If the classes are self-
>> contained and don't effect the semantics of the type system in
>> general, there may not be a need for any fancy infrastructure (or
>> sweeping changes).
>
> We'll need to add SourceLocations to nearly every compound type,
> because you can build just about any type out of other, dependent
> types and we need the location information during template
> instantiation. This means everything from FunctionProtoTypes to
> PointerTypes would have SourceLocations.
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?
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?
-Chris
More information about the cfe-dev
mailing list