diff --git a/llvm/include/llvm/Support/Path.h b/llvm/include/llvm/Support/Path.h index 5b9f50ee055f..f8031036c3e8 100644 --- a/llvm/include/llvm/Support/Path.h +++ b/llvm/include/llvm/Support/Path.h @@ -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. diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp index 875bf75b1f0e..f9a71b986a87 100644 --- a/llvm/lib/Support/Path.cpp +++ b/llvm/lib/Support/Path.cpp @@ -353,6 +353,10 @@ bool reverse_iterator::operator==(const reverse_iterator &RHS) 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,