How to find out name of variable of a given DeclStmt

Hi, please could anybody help me?

I have a DeclStmt and I would like to find out the name of the variable that
is declared.

best regards
Fritz Franz

Hi, Fritz. A DeclStmt can have more than one Decl in it…

int a, *b, c = 3;

…so you’ll have to iterate over the Decls within it using decl_begin() and decl_end(). And since not all Decls have names, you’ll then have to dyn_cast* each one to a NamedDecl before printing any names.

*It’s possible that all Decls found in a DeclStmt will have names, in which case you can just use the asserting ‘cast’ instead of ‘dyn_cast’.

Hope that helps,

Thank you very much Jordan!