[cfe-dev] Cleaning up the representation of Decls in the AST
Neil Booth
neil at daikokuya.co.uk
Sat Aug 23 17:57:57 PDT 2008
Ted Kremenek wrote:-
> On Aug 23, 2008, at 5:29 PM, Neil Booth wrote:
>
>> Ted Kremenek wrote:-
>>
>>> - RecordDecls would represent their fields as a group of DeclGroups.
>>> This enables us to accurately represent:
>>>
>>> struct x {
>>> struct y { int z; } a, b;
>>> int c;
>>> };
>>>
>>> A field_iterator interface can provide the necessary abstraction to
>>> clients that just want to iterate over the FieldDecls of a struct.
>>
>> This example has a different meaning in C and C++. Would they
>> be represented the same?
>
> Hi Neil,
>
> I think I know what you are referring to, but could you please elaborate
> a little more? Are you referring to the visibility of fields?
Sorry I should have been clearer. I'm not referring to visibility,
I'm referring to the fact that in C "struct y" is at file scope,
whereas in C++ it's a nested struct.
>> How would one walk file-scope struct/
>> union/enum declarations for C?
>
> We can currently iterate over all file-scope declarations using
> TranslationUnit (which contains references to all top-level
> declarations). This same interface could be preserved by (a) providing a
> new iterator mechanism to iterate over top-level DeclGroups and (b)
> layering a revised iterator mechanism for iterating over the top-level
> Decls over the iterating mechanism for top-level DeclGroups.
Hence my follow-up question - it seems your iterator would miss
"struct y" in a C source file?
Neil.
More information about the cfe-dev
mailing list