[cfe-dev] Source information for types
Chris Lattner
clattner at apple.com
Thu Jul 9 10:02:30 PDT 2009
On Jul 8, 2009, at 6:56 PM, Argyrios Kyrtzidis wrote:
>> Ah, so SourceType inherits from Type? That feels slightly nasty, but
>> it works, I guess.
>
> Yes, it will be a Type subclass that the type system should not deal
> with and should not be aware of (e.g. CodeGen will never come across a
> SourceType).
> The benefit is that the size of Decls remain the same (no need to add
> a pointer to a "type source info" object).
>
Hi Argiris,
I always thought we'd do this sort of thing by introducing several new
subclasses of type, but ones that are very specific to the various
types. For example, in an ArrayType, you really want to store the
location of the [ and ], and the "Expr*" of the size. To do this,
we'd have something like:
class ConstantArrayTypeWithLoc : public ConstantArrayType {
SourceLocation LBracketLoc, RBracketLoc;
Expr *Size;
...
};
The canonical form of the array type would be the normal ConstantArray
without location info (so that canonical types are pointer unique as
usual). This just provides loc info for ConstantArray, so we'd need
to have a per-class subclass for every type that has a token. Does
this approach make sense?
-Chris
More information about the cfe-dev
mailing list