1

i am building a clang libtool, how can i get the preprocessor information that will tell me if a given Decl is inside a scope of #if #ifdef #ifndef ?

gregOS
  • 21
  • 2

1 Answers1

3

There's no easy answer for this unfortunately. Clang isn't fully aware at an AST level of any preprocessor directives.

The best you can do to the best of my knowledge is to implement a PPCallbacks class, register it with the compiler instance preprocessor and implement the functions for If, Elif, Endif.

Then you can use a ASTVisitor to find everything in between those Source locations.

keyboardsmoke
  • 156
  • 2
  • 6