clang and #if regions

Hi All,

Out of curiosity, now that I'm using the C interface to clang, is there a
simple way to determine the source lines that were activated for compilation
by the C-preprocessor? The complement of that, of course, is the set of
lines that did *not* make it through the C pre-processor.

You get where I'm going here--in the IDE I wish to low-light the lines that
are #if'd out. I just wondered whether there was an easy way to do this.
Looking at the C interface, it looks like it could be expensive. Or I've
missed something!

I know that the XCode 4 preview I have doesn't do this, or I can't find a
way to do it in XCode.

Thanks,

Quoting "Paul Curtis" <plc@rowley.co.uk>:

simple way to determine the source lines that were activated for compilation
by the C-preprocessor? The complement of that, of course, is the set of
lines that did *not* make it through the C pre-processor.

I still did not had the time to experiment it, but you are probably
searching for this:

http://clang.llvm.org/doxygen/classclang_1_1PPCallbacks.html

"This interface provides a way to observe the actions of the preprocessor
  as it does its thing. Clients can define their hooks here to implement
  preprocessor level tools."

Regards,

Hi Benoit,

Quoting "Paul Curtis" <plc@rowley.co.uk>:

> simple way to determine the source lines that were activated for
> compilation by the C-preprocessor? The complement of that, of
course,
> is the set of lines that did *not* make it through the C pre-
processor.

I still did not had the time to experiment it, but you are probably
searching for this:

http://clang.llvm.org/doxygen/classclang_1_1PPCallbacks.html

"This interface provides a way to observe the actions of the
preprocessor as it does its thing. Clients can define their
hooks here to implement preprocessor level tools."

This looks promising, but that means directly hooking into the underlying
clang classes rather than going through the insulating C API? I was sort of
hoping for something that could just pop out of the woodwork, but if it
means I need to roll up my sleeves, then I guess it's time to do some
digging. :slight_smile:

Regards,