]> granicus.if.org Git - clang/commitdiff
[clangd] A code tweak to expand a macro
authorIlya Biryukov <ibiryukov@google.com>
Mon, 8 Jul 2019 15:25:16 +0000 (15:25 +0000)
committerIlya Biryukov <ibiryukov@google.com>
Mon, 8 Jul 2019 15:25:16 +0000 (15:25 +0000)
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

include/clang/Tooling/Syntax/Tokens.h

index 1ec6ccb52b186977525ba6a30774fc2738ca9782..a89ff3680d2fbf780695a63e44d8c3bf9b7241b3 100644 (file)
@@ -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;