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

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Kristof Beyls via cfe-dev
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.)

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

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

Kristof Beyls via cfe-dev
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".

On Tue, Oct 29, 2019 at 10:48 AM Stephan Bergmann via cfe-dev <[hidden email]> wrote:
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.)

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


--
Regards,
Ilya Biryukov

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

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

Kristof Beyls via cfe-dev
On 29/10/2019 10:58, Ilya Biryukov wrote:
> 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 :)  Thanks!

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev