[cfe-dev] Tentative typeid Parser/AST implementation
Doug Gregor
doug.gregor at gmail.com
Tue Nov 11 05:04:06 PST 2008
On Tue, Nov 11, 2008 at 5:48 AM, Sebastian Redl
<sebastian.redl at getdesigned.at> wrote:
> Chris Lattner wrote:
>>
>> I don't really care one way or the other, as long as we're
>> consistent. Do you think one approach is better than the other? If
>> you like merging the two together, would you be willing to change
>> sizeof/alignof to match?
> I'll do that.
One trick I found while looking at this... instead of having a bit for
isTypeOp, you can split the SourceRange into two SourceLocations:
SourceLocation OpLoc; // location of the 'typeid', 'sizeof', or 'alignof'
SourceLocation RParenLoc; // location of the right paren, if this
we're storing a type
When RParenLoc is a valid location, the Operand is a type and
RParenLoc will be the source location of the right paren. When
RParenLoc is invalid, the Operand is an expression (and the
expression's getSourceRange will tell us where the end of the
expression is). getSourceRange gets slightly more complicated, but
we'll save ourselves 4 bytes per typeid/sizeof/alignof.
- Doug
More information about the cfe-dev
mailing list