getting all definitions of a macro identifer?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

getting all definitions of a macro identifer?

via cfe-dev

Hi,

I have a question about getting macro definitions when using Clang's libraries. In analyzing code statically, we'd like to get all definitions of a macro identifier regardless of its actual value passed in. For instance, for the following macro:

#ifdef X

#define F1 zzz

#else

#define F1 yyy

#endif

We'd like to get F1's all substitutions (zzz and yyy) no matter what value of X is provided. What's the best method to do it? I'm afraid that using the Preprocessor library is or isn't enough.

Thanks.

-- 
Love,
Lou


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: getting all definitions of a macro identifer?

via cfe-dev

Hi,

you can hook the PPCallbacks and do manual processing on the macros that are defined. If you want to find *ALL* definitions of the macro in your whole project you need to process all files and (probably) store the results between multiple calls.

See https://clang.llvm.org/doxygen/classclang_1_1PPCallbacks.html

Best Jonas


Am 19.10.2018 um 10:30 schrieb Lou Wynn via cfe-dev:

Hi,

I have a question about getting macro definitions when using Clang's libraries. In analyzing code statically, we'd like to get all definitions of a macro identifier regardless of its actual value passed in. For instance, for the following macro:

#ifdef X

#define F1 zzz

#else

#define F1 yyy

#endif

We'd like to get F1's all substitutions (zzz and yyy) no matter what value of X is provided. What's the best method to do it? I'm afraid that using the Preprocessor library is or isn't enough.

Thanks.

-- 
Love,
Lou



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev