AST for preprocessor directives

Hello!

At the moment I’m doing some source-to-source manipulations with clang. I using the RewriteObjC.cpp as an example of such manipulations, but as far as I understand the AST is not produced for the preprocessor directives, like for instance - #define value 1
Is the manual parsing the only way to deal with preprocessor directives or there is a way to translate them into AST?

Also where I can get list of all DeclNodes for the C language? Are they mixed with Objective-C and C++ in DeclNodes.inc?

Thanks,
Andrey

Hello!

At the moment I’m doing some source-to-source manipulations with clang. I using the RewriteObjC.cpp as an example of such manipulations, but as far as I understand the AST is not produced for the preprocessor directives, like for instance - #define value 1
Is the manual parsing the only way to deal with preprocessor directives or there is a way to translate them into AST?

You can implement your own PPCallbacks subclass to watch all of the preprocessor activity.

Also where I can get list of all DeclNodes for the C language? Are they mixed with Objective-C and C++ in DeclNodes.inc?

Yes, they’re mixed in DeclNodes.inc. The C-specific nodes are all defined in include/clang/AST/Decl.h

  • Doug