Clang AST dump doesn't show #defines
问题 I'm dumping the AST of some headers like this: clang -cc1 -ast-dump -fblocks header.h However, any #define s on the header are not showing on the dump. Is there a way of adding them? 回答1: It's true, #defines are handled by the preprocessor, not the compiler. So you need a preprocessor parser stage. I know of two: Boost Wave can preprocess the input for you, and/or give you hooks to trigger on macro definitions or uses. The Clang tool pp-trace uses a Clang library that can do callbacks on many