Reputation: 596
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 ?
Upvotes: 3
Views: 344
Reputation: 596
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.
Upvotes: 1