Clang AST dump doesn't show #defines

最后都变了- 提交于 2019-12-24 02:58:40

问题


I'm dumping the AST of some headers like this:

clang -cc1 -ast-dump -fblocks header.h

However, any #defines 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:

  1. Boost Wave can preprocess the input for you, and/or give you hooks to trigger on macro definitions or uses.

  2. The Clang tool pp-trace uses a Clang library that can do callbacks on many preprocessor events, including macro definitions.



来源:https://stackoverflow.com/questions/29595807/clang-ast-dump-doesnt-show-defines

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!