1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 12:12:47 +01:00

C++20 fixes

This commit is contained in:
xddxd 2021-03-26 17:59:21 +02:00 committed by Ivan
parent 716bb292ba
commit 5d8643e8eb
4 changed files with 24 additions and 29 deletions

View File

@ -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!");

View File

@ -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;
}
};

View File

@ -142,9 +142,11 @@ public:
return tmp;
}
#ifndef __cpp_impl_three_way_comparison
bool operator!=(const DerivedT &RHS) const {
return !static_cast<const DerivedT *>(this)->operator==(RHS);
return !(static_cast<const DerivedT &>(*this) == RHS);
}
#endif
bool operator>(const DerivedT &RHS) const {
static_assert(
@ -260,12 +262,16 @@ public:
return *static_cast<DerivedT *>(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; }

View File

@ -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))