3

I'm using the clang library to do some c++ AST manipulation. I would like to get the location of the right parenthesis of a condition of an IfStmt. I tried:

auto condLocEnd = statement->getCond()->getLocEnd();
auto condLoc = Lexer::findLocationAfterToken(condLocEnd, tok::r_paren, sm, LangOptions(), false);

Unfortunately condLoc is invalid when the condition contains a macro. Eg: if(p == NULL). I can't figure out how to get the location. How to get it ?

Ron
  • 14,674
  • 4
  • 34
  • 47
Dorian
  • 490
  • 2
  • 10

1 Answers1

1

Thanks to the cfe-dev mailing list, I found that this answer https://stackoverflow.com/a/24223347. I needed to get the expansion location for the LocEnd() of my condition expression.

Dorian
  • 490
  • 2
  • 10