[cfe-dev] ast-print of functions
Douglas Gregor
dgregor at apple.com
Mon Apr 18 08:09:56 PDT 2011
On Apr 15, 2011, at 7:54 AM, Zheng Wang wrote:
> Hello,
>
> I am trying to understand how the StmtPrinter works. Assuming I have the following code:
>
> int compute (int a)
> {
> balball
> }
>
> which function in clang will print the function name -- "compute"? Or, what type of stmt the function corresponds to?
You won't find it in StmtPrinter, because a function is a declaration (not a statement). The DeclPrinter handles the printing of all kinds of declarations, including functions, which are represented by a FunctionDecl.
Declarations can occur within statements, e.g., DeclStmt is a statement that contains one or more declarations. However, in your example, the function occurs at the top level, stored within the translation unit.
- Doug
More information about the cfe-dev
mailing list