r365331 - [clangd] A code tweak to expand a macro

Ilya Biryukov via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 8 08:25:16 PDT 2019


Author: ibiryukov
Date: Mon Jul  8 08:25:16 2019
New Revision: 365331

URL: http://llvm.org/viewvc/llvm-project?rev=365331&view=rev
Log:
[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

Modified:
    cfe/trunk/include/clang/Tooling/Syntax/Tokens.h

Modified: cfe/trunk/include/clang/Tooling/Syntax/Tokens.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Syntax/Tokens.h?rev=365331&r1=365330&r2=365331&view=diff
==============================================================================
--- cfe/trunk/include/clang/Tooling/Syntax/Tokens.h (original)
+++ cfe/trunk/include/clang/Tooling/Syntax/Tokens.h Mon Jul  8 08:25:16 2019
@@ -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;
 




More information about the cfe-commits mailing list