From ed9e5713053e52bcf307e9e6568965caf8536b9b Mon Sep 17 00:00:00 2001 From: Ilya Biryukov Date: Mon, 8 Jul 2019 15:25:16 +0000 Subject: [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 --- include/clang/Tooling/Syntax/Tokens.h | 9 +++++++++ 1 file changed, 9 insertions(+) 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; -- cgit v1.2.1