ast-print of functions

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?

Cheers,
Zheng

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