[PATCH] D19724: Add operator- to Path's reverse_iterator. Needed for D19666

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 29 09:22:47 PDT 2016


Filipe Cabecinhas <filcab+llvm.phabricator at gmail.com> writes:
> filcab created this revision.
> filcab added reviewers: rafael, craig.topper, bogner.
> filcab added a subscriber: llvm-commits.

This is obvious, you don't really need pre-commit review for this kind
of thing. LGTM.

> http://reviews.llvm.org/D19724
>
> Files:
>   include/llvm/Support/Path.h
>   lib/Support/Path.cpp
>
> Index: lib/Support/Path.cpp
> ===================================================================
> --- lib/Support/Path.cpp
> +++ lib/Support/Path.cpp
> @@ -353,6 +353,10 @@
>           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,
> Index: include/llvm/Support/Path.h
> ===================================================================
> --- include/llvm/Support/Path.h
> +++ include/llvm/Support/Path.h
> @@ -87,6 +87,9 @@
>    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.
>



More information about the llvm-commits mailing list