Stmt.getLocEnd() (Antoine Trouve)

You might want to have a look at my CIrewriter.cpp example at which has some useful information including:

// Note Stmt::getLocEnd() returns the source location prior to the
// token at the end of the line. For instance, for:
// var = 123;
// ^---- getLocEnd() points here.

SourceLocation END = s->getLocEnd();

// MeasureTokenLength gets us past the last token, and adding 1 gets
// us past the ‘;’.
int offset = Lexer::MeasureTokenLength(END,
ci->getLangOpts()) + 1;

SourceLocation END1 = END.getLocWithOffset(offset);
Rewrite.InsertText(END1, “\n}”, true, true);

// Also note getLocEnd() on a CompoundStmt points ahead of the ‘}’.
// Use getLocEnd().getLocWithOffset(1) to point past it.

Robert Ankeney