diff --git a/include/llvm/ADT/DenseMap.h b/include/llvm/ADT/DenseMap.h index 402b5484463..f690a6b1a26 100644 --- a/include/llvm/ADT/DenseMap.h +++ b/include/llvm/ADT/DenseMap.h @@ -1244,30 +1244,19 @@ public: return Ptr; } -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wambiguous-reversed-operator" -#endif - bool operator==(const ConstIterator &RHS) const { - assert((!Ptr || isHandleInSync()) && "handle not in sync!"); + friend bool operator==(const DenseMapIterator &LHS, + const DenseMapIterator &RHS) { + assert((!LHS.Ptr || LHS.isHandleInSync()) && "handle not in sync!"); assert((!RHS.Ptr || RHS.isHandleInSync()) && "handle not in sync!"); - assert(getEpochAddress() == RHS.getEpochAddress() && + assert(LHS.getEpochAddress() == RHS.getEpochAddress() && "comparing incomparable iterators!"); - return Ptr == RHS.Ptr; + return LHS.Ptr == RHS.Ptr; } -#ifdef __clang__ -#pragma clang diagnostic pop -#endif -#if __cpp_impl_three_way_comparison >= 201711 -#else - bool operator!=(const ConstIterator &RHS) const { - assert((!Ptr || isHandleInSync()) && "handle not in sync!"); - assert((!RHS.Ptr || RHS.isHandleInSync()) && "handle not in sync!"); - assert(getEpochAddress() == RHS.getEpochAddress() && - "comparing incomparable iterators!"); - return Ptr != RHS.Ptr; + + friend bool operator!=(const DenseMapIterator &LHS, + const DenseMapIterator &RHS) { + return !(LHS == RHS); } -#endif inline DenseMapIterator& operator++() { // Preincrement assert(isHandleInSync() && "invalid iterator access!"); diff --git a/include/llvm/ADT/STLExtras.h b/include/llvm/ADT/STLExtras.h index 890a133953e..acee4df520a 100644 --- a/include/llvm/ADT/STLExtras.h +++ b/include/llvm/ADT/STLExtras.h @@ -558,12 +558,12 @@ public: return *this; } - using BaseT::operator==; - bool operator==(const early_inc_iterator_impl &RHS) const { + friend bool operator==(const early_inc_iterator_impl &LHS, + const early_inc_iterator_impl &RHS) { #if LLVM_ENABLE_ABI_BREAKING_CHECKS - assert(!IsEarlyIncremented && "Cannot compare after dereferencing!"); + assert(!LHS.IsEarlyIncremented && "Cannot compare after dereferencing!"); #endif - return BaseT::operator==(RHS); + return (const BaseT &)LHS == (const BaseT &)RHS; } }; diff --git a/include/llvm/ADT/iterator.h b/include/llvm/ADT/iterator.h index 9a1f6e1511e..105dd9105c9 100644 --- a/include/llvm/ADT/iterator.h +++ b/include/llvm/ADT/iterator.h @@ -142,9 +142,11 @@ public: return tmp; } +#ifndef __cpp_impl_three_way_comparison bool operator!=(const DerivedT &RHS) const { - return !static_cast(this)->operator==(RHS); + return !(static_cast(*this) == RHS); } +#endif bool operator>(const DerivedT &RHS) const { static_assert( @@ -260,12 +262,16 @@ public: return *static_cast(this); } - bool operator==(const DerivedT &RHS) const { return I == RHS.I; } - bool operator<(const DerivedT &RHS) const { + friend bool operator==(const iterator_adaptor_base &LHS, + const iterator_adaptor_base &RHS) { + return LHS.I == RHS.I; + } + friend bool operator<(const iterator_adaptor_base &LHS, + const iterator_adaptor_base &RHS) { static_assert( BaseT::IsRandomAccess, "Relational operators are only defined for random access iterators."); - return I < RHS.I; + return LHS.I < RHS.I; } ReferenceT operator*() const { return *I; } diff --git a/lib/ObjectYAML/DWARFEmitter.cpp b/lib/ObjectYAML/DWARFEmitter.cpp index ed3732ba29f..dfacffc5c1d 100644 --- a/lib/ObjectYAML/DWARFEmitter.cpp +++ b/lib/ObjectYAML/DWARFEmitter.cpp @@ -397,7 +397,7 @@ Error DWARFYAML::emitDebugAddr(raw_ostream &OS, const Data &DI) { writeInteger((uint8_t)TableEntry.SegSelectorSize, OS, DI.IsLittleEndian); for (const SegAddrPair &Pair : TableEntry.SegAddrPairs) { - if (TableEntry.SegSelectorSize != 0) + if (TableEntry.SegSelectorSize != yaml::Hex8{0}) if (Error Err = writeVariableSizedInteger(Pair.Segment, TableEntry.SegSelectorSize, OS, DI.IsLittleEndian))