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

Argiris Kirtzidis akyrtzi at gmail.com
Thu Sep 11 13:32:07 PDT 2008

Argiris Kirtzidis wrote:
> Ted Kremenek wrote:
>> Another reason that having types own Decls is that it really makes 
>> things much more difficult for clients that wish to modify the AST.  
>> When is a Decl owned by a type?  With the idea you propose, a 
>> DeclStmt might own a TypeDecl if it isn't a RecordDecl, but in the 
>> case of a RecordType the type would own it.  There is also the 
>> problem that we now have multiple RecordDecls for a given 
>> RecordType.  Does the RecordType own all of those RecordDecls?  This 
>> actually makes manipulation of the AST really tricky and error prone.
> To be more clear, the idea is that TypeDecls are owned by Types, and 
> only one RecordDecl would be created.
> Can clients modify the AST without involving Types ? Assuming one 
> RecordDecl in the AST is replaced with another, what about the 
> RecordType the refers to it ?
> My point is that if the DeclGroup owns the RecordDecl, the Type will 
> still need to be updated. If the Type owns the the RecordDecl you may 
> only need to update the Type.

Also, about modifying the AST: assuming you want to replace a RecordDecl 
with another one, it's easier to replace the one RecordDecl in the Type, 
instead of tracking down and replacing all RecordDecls (forward 
declarations and definition).


More information about the cfe-dev mailing list