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
  • 13,936
  • 3
  • 30
  • 47
Dorian
  • 348
  • 1
  • 9

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
  • 348
  • 1
  • 9