Clang AST转储不显示#defines [英] Clang AST dump doesn't show #defines
问题描述
我正在像这样转储某些标头的AST:
I'm dumping the AST of some headers like this:
clang -cc1 -ast-dump -fblocks header.h
但是,标头上的任何#define
都不会显示在转储中.有没有添加它们的方法?
However, any #define
s on the header are not showing on the dump. Is there a way of adding them?
推荐答案
是的,#define是由预处理程序而不是编译器处理的.因此,您需要一个预处理器解析器阶段.我知道两个:
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 可以为您预处理输入和/或为您提供了触发宏定义或使用的挂钩.
Boost Wave can preprocess the input for you, and/or give you hooks to trigger on macro definitions or uses.
Clang工具 pp-trace 使用的Clang库可以对许多预处理器事件(包括宏定义)进行回调.
The Clang tool pp-trace uses a Clang library that can do callbacks on many preprocessor events, including macro definitions.
这篇关于Clang AST转储不显示#defines的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!