getSourceRange of an Expr Stmt covering the closing "; "?

Because of how Expr is derived from Stmt, e.getSourceRange() for an Expr e that constitutes an expression-statement doesn't include the closing ";".

Is there perhaps some code already somewhere that provides the extended SourceRange? (I'd imagined that SourceManager might provide something like that, but couldn't find anything.)

Hi Stephan,

It’s a common problem, there’s a helper in Clang Tooling library that solves this.
Take a look at the getExtendedRange function from “include/clang/Tooling/Transformer/SourceCode.h”.

Ah, there it did hide :slight_smile: Thanks!