summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/Tooling/Syntax/Tokens.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/include/clang/Tooling/Syntax/Tokens.h b/clang/include/clang/Tooling/Syntax/Tokens.h
index 1ec6ccb52b1..a89ff3680d2 100644
--- a/clang/include/clang/Tooling/Syntax/Tokens.h
+++ b/clang/include/clang/Tooling/Syntax/Tokens.h
@@ -66,6 +66,15 @@ struct FileRange {
unsigned length() const { return End - Begin; }
+ /// Check if \p Offset is inside the range.
+ bool contains(unsigned Offset) const {
+ return Begin <= Offset && Offset < End;
+ }
+ /// Check \p Offset is inside the range or equal to its endpoint.
+ bool touches(unsigned Offset) const {
+ return Begin <= Offset && Offset <= End;
+ }
+
/// Gets the substring that this FileRange refers to.
llvm::StringRef text(const SourceManager &SM) const;
OpenPOWER on IntegriCloud