summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Biryukov <ibiryukov@google.com>2019-07-08 15:25:16 +0000
committerIlya Biryukov <ibiryukov@google.com>2019-07-08 15:25:16 +0000
commited9e5713053e52bcf307e9e6568965caf8536b9b (patch)
tree7946f676edc56b5c10e801c720d102403a8504c4
parent0c22dae814b97cdec6403ffc5d4d364f52a21890 (diff)
downloadclang-ed9e5713053e52bcf307e9e6568965caf8536b9b.tar.gz
[clangd] A code tweak to expand a macro
Reviewers: sammccall Reviewed By: sammccall Subscribers: mgorny, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61681 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365331 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Tooling/Syntax/Tokens.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/clang/Tooling/Syntax/Tokens.h b/include/clang/Tooling/Syntax/Tokens.h
index 1ec6ccb52b..a89ff3680d 100644
--- a/include/clang/Tooling/Syntax/Tokens.h
+++ b/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;