Comparing SourceRanges

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

Comparing SourceRanges

Oleg Smolsky via cfe-dev
Hi all,

How can I check if a SourceRange is inside another SourceRange?
For example, if I have a FunctionDecl *FD and a Stmt *S, how to check if S->getSourceRange() is located inside FD->getSourceRange()?

Best,
Pardis

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

Re: Comparing SourceRanges

Oleg Smolsky via cfe-dev

You can compare both the beginning and the end of the SourceRange. SourceLocations itself are comparable.

With this you can build a small helper function to the inclusion check.

Best, Jonas

Am 27.11.18 um 18:52 schrieb Pardis Pashakhanloo via cfe-dev:
Hi all,

How can I check if a SourceRange is inside another SourceRange?
For example, if I have a FunctionDecl *FD and a Stmt *S, how to check if S->getSourceRange() is located inside FD->getSourceRange()?

Best,
Pardis

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

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