[cfe-dev] Right parenthesis of a condition.

Dorian Haglund via cfe-dev cfe-dev at lists.llvm.org
Wed Feb 28 01:11:11 PST 2018


Hello,

I'm using the clang library to monitor (among other things) the if
statements in my program.

i need to get the location of the right parenthesis of the condition of the
if (and while) statements.

I've tried things such as:

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 of the right
parenthesis.

Do you know how to get it ? If it is not possible, could you explain why ?
Best regards,


-- 
Dorian Haglund
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180228/4ea5b1c7/attachment.html>


More information about the cfe-dev mailing list