Clang AST转储不显示#defines [英] Clang AST dump doesn't show #defines

查看:206
本文介绍了Clang AST转储不显示#defines的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在像这样转储某些标头的AST:

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

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

但是,标头上的任何#define都不会显示在转储中.有没有添加它们的方法?

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

  1. Boost Wave 可以为您预处理输入和/或为您提供了触发宏定义或使用的挂钩.

  1. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆