[cfe-dev] Incorrect endLoc of MemberExpr in AST?

Aaron Ballman via cfe-dev cfe-dev at lists.llvm.org
Mon Jan 13 05:41:18 PST 2020


On Mon, Jan 13, 2020 at 8:31 AM Nikita Petrenko via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
>
> My question is described on SO:
> https://stackoverflow.com/questions/59697541/expression-size-in-ast-is-incorrect-for-member-access
>
> I got no answer on SO, and I suppose that I can reach more clang devs through this mailing list. I hope it is ok.
>
> Thanks!

SourceLocations in Clang point to the insertion point before the
token, not to the insertion point after the token. To find the end of
the characters, you have to measure the token length and add it to the
end location. You can use Lexer::getLocForEndOfToken() to do this
automatically for you.

HTH!

~Aaron

>
> Best,
> Nikita
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


More information about the cfe-dev mailing list