[PATCH] Make tooling::Range more convenient.

Guillaume Papin guillaume.papin at epitech.eu
Tue Jul 16 10:45:56 PDT 2013


Hi djasper, revane,

Working on the C++11 Migrator I needed something similar to the tooling::Range
but with the added possibility to update the offset/length, so I made the fields
public.

I also added two methods getBegin()/getEnd() for convenience but I have no
strong opinion about their existance, it just makes my code slightly more
readable IMHO.

http://llvm-reviews.chandlerc.com/D1156

Files:
  include/clang/Tooling/Refactoring.h

Index: include/clang/Tooling/Refactoring.h
===================================================================
--- include/clang/Tooling/Refactoring.h
+++ include/clang/Tooling/Refactoring.h
@@ -33,15 +33,15 @@
 namespace tooling {
 
 /// \brief A source range independent of the \c SourceManager.
-class Range {
-public:
+struct Range {
   Range() : Offset(0), Length(0) {}
   Range(unsigned Offset, unsigned Length) : Offset(Offset), Length(Length) {}
 
   unsigned getOffset() const { return Offset; }
   unsigned getLength() const { return Length; }
+  unsigned getBegin() const { return Offset; }
+  unsigned getEnd() const { return Offset + Length; }
 
-private:
   unsigned Offset;
   unsigned Length;
 };
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1156.1.patch
Type: text/x-patch
Size: 713 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130716/d97a8430/attachment.bin>


More information about the cfe-commits mailing list