[llvm] r268062 - Add operator- to Path's reverse_iterator. Needed for D19666

Filipe Cabecinhas via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 29 09:48:08 PDT 2016


Author: filcab
Date: Fri Apr 29 11:48:07 2016
New Revision: 268062

URL: http://llvm.org/viewvc/llvm-project?rev=268062&view=rev
Log:
Add operator- to Path's reverse_iterator. Needed for D19666

Reviewers: rafael, craig.topper, bogner

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D19724

Modified:
    llvm/trunk/include/llvm/Support/Path.h
    llvm/trunk/lib/Support/Path.cpp

Modified: llvm/trunk/include/llvm/Support/Path.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Path.h?rev=268062&r1=268061&r2=268062&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Path.h (original)
+++ llvm/trunk/include/llvm/Support/Path.h Fri Apr 29 11:48:07 2016
@@ -87,6 +87,9 @@ public:
   reverse_iterator &operator++();    // preincrement
   bool operator==(const reverse_iterator &RHS) const;
   bool operator!=(const reverse_iterator &RHS) const { return !(*this == RHS); }
+
+  /// @brief Difference in bytes between this and RHS.
+  ptrdiff_t operator-(const reverse_iterator &RHS) const;
 };
 
 /// @brief Get begin iterator over \a path.

Modified: llvm/trunk/lib/Support/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Path.cpp?rev=268062&r1=268061&r2=268062&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Path.cpp (original)
+++ llvm/trunk/lib/Support/Path.cpp Fri Apr 29 11:48:07 2016
@@ -353,6 +353,10 @@ bool reverse_iterator::operator==(const
          Position == RHS.Position;
 }
 
+ptrdiff_t reverse_iterator::operator-(const reverse_iterator &RHS) const {
+  return Position - RHS.Position;
+}
+
 StringRef root_path(StringRef path) {
   const_iterator b = begin(path),
                  pos = b,




More information about the llvm-commits mailing list