[cfe-dev] Cleaning up the representation of Decls in the AST

Zhongxing Xu xuzhongxing at gmail.com
Fri Sep 12 06:55:32 PDT 2008


2008/9/12 Argiris Kirtzidis <akyrtzi at gmail.com>

> Zhongxing Xu wrote:
>
>> I agree with Ted that we should separate syntax thing from semantics thing
>> in the AST.
>>
>> struct s;
>> struct s a;
>> struct s { int d; } x;
>>
>> These 'struct s' have different meanings: type declaration, type
>> specifier, type definition.
>> But syntactically they are all RecordDecl.
>>
>
> Strictly syntactically speaking, and by standard terminology, here's what
> the above constructs are:
>
> struct s;       ->   type-specifier ';'
> struct s a;    ->   type-specifier 'a' ';'
> struct s { int d; } x;    ->  type-specifier 'x' ';'
>
> Isn't it more faithful to the syntax to consider "struct s { int d; }" as
> part of the type-specifier for 'x' ?
> Here's how a client may work when it receives "struct s { int d; } x;" and
> wants to pretty-print it:
>
> -I've got a DeclGroup of one VarDecl named 'x'.
> -Print its type. It's type (the type-specifier part of the syntax) is
> RecordTypeDef. Print the RecordDecl by getting it from the RecordTypeDef.
> -Print "x;"
>
> This seems more syntactically-oriented to me, why is it more confusing ?
>

As types are uniqued, how do we differentiate 'struct s a;' from 'struct s {
int d; } x;' in the AST?
Use RecordTypeDef and RecordType?

-Zhongxing
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20080912/b72b91d3/attachment.html>


More information about the cfe-dev mailing list