[cfe-dev] My understanding of AST

Journeyer J. Joh oosaprogrammer at gmail.com
Fri Nov 2 05:03:46 PDT 2012

Hello list,

I'd like to share my understanding and also want some review or
comment about it.
Let's say there is a function.

int func()
  int array[3];
  return 0;

I investigated how an AST node for the declaration of array above forms.

1. ConstantArrayType is registered into ASTContext (this Clang::Type
is distinguished by it's size(3) and type(int))
2. a TypeSourceInfo is created with the clang::Type above (which is
registered in ASTContext) and the Locations(ArrayTypeLoc,
3. a VarDecl is created with the TypeSourceInfo above and the name of
the variable, ('array' this case)

?. So I think the VarDecl is itself the AST node for the array declaration!

I am not sure especially for the one marked by '?'.

I think all 'Decl's is itself is a node of AST. And I wonder if this is correct.

Thank you very much!

Also I wonder if this kind of question is not proper in this mail
list. If anyone think so let me know. I will stop asking this kind of
question here.

Best regards
Journeyer J. Joh
o o s a p r o g r a m m e r
a t
g m a i l  d o t  c o m

More information about the cfe-dev mailing list