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

Filipe Cabecinhas via llvm-commits llvm-commits at lists.llvm.org
Sun May 1 02:22:55 PDT 2016


Honestly, I didn't think too much about it and just did the same as
const_iterator.
As for having the operator as a non-instance variable, it wouldn't
bring us anything new yet:
The only definition is for (reverse_iterator - reverse_iterator), and
afaict, there's no implicit conversion from anything to that.

If you still want those changes or want me to still bring it to an
inline definition, let me know. Not sure if we'll be saving much, but
it won't hurt :-)

Thank you,

  Filipe

On Fri, Apr 29, 2016 at 11:55 PM, David Blaikie via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Usually member variables that can be non-instance members should be
> non-instance members so as to allow equal conversions on the left and right
> hand operands. One way to do this is to declare it as a friend, instead of
> as a non-static member (or even define it in terms of another operation)
>
> Also not sure whether that operation should be out of line, or just make it
> inline?
>
> On Fri, Apr 29, 2016 at 9:48 AM, Filipe Cabecinhas via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
>>
>> 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,
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>


More information about the llvm-commits mailing list