Getting preprocessor statements

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

Getting preprocessor statements

Jim Crafton
I have a couple of pre-processor questions:
How to collect any #includes in a translation unit?
How to collect any macros that are defined?

Cheers

Jim
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Getting preprocessor statements

Douglas Gregor

On Apr 15, 2010, at 12:54 PM, Jim Crafton wrote:

> I have a couple of pre-processor questions:
> How to collect any #includes in a translation unit?
> How to collect any macros that are defined?

You can write a subclass of PPCallbacks and attach an object of that subclass to the preprocessor. Then, you'll see whenever we #include a file, #define a macro, etc.

Alternatively, you could extend the (optionally-built) PreprocessingRecord to specifically track #includes (it already tracks macro definitions) and use that information.

        - Doug
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev