Can I dump list of macro defines used from clang preprocessor

I’m trying to come up with some smart recompile logic for defines given via command line arguments.

To do this, it would be nice if clang could write out to a file what macro defines it used from the command line, or what macro defines it checked existence of

is this possible? thanks

To be clear, I am not asking to dump pre-defined macros, or get the preprocessor output

-E -dM

Right, so I am not asking to dump pre-defined macros, or get the preprocessor output

Let me be more specific

If I have source code that is like this:

#ifdef USE_FOOBAR
...
#endif

and compile it with

-DUSE_FOOBAR -DUSE_OTHER

I would like Clang to tell me that the source code used the define USE_FOOBAR