Commit 02261c4b authored by Peter Kasting's avatar Peter Kasting Committed by V8 LUCI CQ

Types on both sides of comparison operators should be the same.

This prevents "ambiguous call" warnings when compiling in C++20 mode.

Bug: chromium:1284275
Change-Id: I52f782aaddfad1920e4b2df5e916b2c292cc7cff
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3630346
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80458}
parent 8656d937
......@@ -322,22 +322,22 @@ class TimeBase : public TimeConstants {
}
// Comparison operators
bool operator==(TimeClass other) const {
bool operator==(const TimeBase<TimeClass>& other) const {
return us_ == other.us_;
}
bool operator!=(TimeClass other) const {
bool operator!=(const TimeBase<TimeClass>& other) const {
return us_ != other.us_;
}
bool operator<(TimeClass other) const {
bool operator<(const TimeBase<TimeClass>& other) const {
return us_ < other.us_;
}
bool operator<=(TimeClass other) const {
bool operator<=(const TimeBase<TimeClass>& other) const {
return us_ <= other.us_;
}
bool operator>(TimeClass other) const {
bool operator>(const TimeBase<TimeClass>& other) const {
return us_ > other.us_;
}
bool operator>=(TimeClass other) const {
bool operator>=(const TimeBase<TimeClass>& other) const {
return us_ >= other.us_;
}
......
......@@ -150,11 +150,23 @@ class Vector {
input.size() * sizeof(S) / sizeof(T));
}
bool operator==(const Vector<const T> other) const {
bool operator==(const Vector<T>& other) const {
return std::equal(begin(), end(), other.begin(), other.end());
}
bool operator!=(const Vector<const T> other) const {
bool operator!=(const Vector<T>& other) const {
return !operator==(other);
}
template<typename TT = T>
std::enable_if_t<!std::is_const_v<TT>, bool> operator==(
const Vector<const T>& other) const {
return std::equal(begin(), end(), other.begin(), other.end());
}
template<typename TT = T>
std::enable_if_t<!std::is_const_v<TT>, bool> operator!=(
const Vector<const T>& other) const {
return !operator==(other);
}
......
......@@ -45,10 +45,12 @@ class RegisterBase {
return reg_code_;
}
inline constexpr bool operator==(SubType other) const {
inline constexpr bool operator==(
const RegisterBase<SubType, kAfterLastRegister>& other) const {
return reg_code_ == other.reg_code_;
}
inline constexpr bool operator!=(SubType other) const {
inline constexpr bool operator!=(
const RegisterBase<SubType, kAfterLastRegister>& other) const {
return reg_code_ != other.reg_code_;
}
......
......@@ -140,8 +140,12 @@ class V8_EXPORT_PRIVATE INSTRUCTION_OPERAND_ALIGN InstructionOperand {
// APIs to aid debugging. For general-stream APIs, use operator<<.
void Print() const;
bool operator==(InstructionOperand& other) const { return Equals(other); }
bool operator!=(InstructionOperand& other) const { return !Equals(other); }
bool operator==(const InstructionOperand& other) const {
return Equals(other);
}
bool operator!=(const InstructionOperand& other) const {
return !Equals(other);
}
protected:
explicit InstructionOperand(Kind kind) : value_(KindField::encode(kind)) {}
......
......@@ -206,10 +206,10 @@ class V8_EXPORT_PRIVATE LoadElimination final
}
static IndexRange Invalid() { return IndexRange(); }
bool operator==(const IndexRange& other) {
bool operator==(const IndexRange& other) const {
return begin_ == other.begin_ && end_ == other.end_;
}
bool operator!=(const IndexRange& other) { return !(*this == other); }
bool operator!=(const IndexRange& other) const { return !(*this == other); }
struct Iterator {
int i;
......
......@@ -355,10 +355,10 @@ class PageIteratorImpl
explicit PageIteratorImpl(PAGE_TYPE* p) : p_(p) {}
PageIteratorImpl(const PageIteratorImpl<PAGE_TYPE>& other) : p_(other.p_) {}
PAGE_TYPE* operator*() { return p_; }
bool operator==(const PageIteratorImpl<PAGE_TYPE>& rhs) {
bool operator==(const PageIteratorImpl<PAGE_TYPE>& rhs) const {
return rhs.p_ == p_;
}
bool operator!=(const PageIteratorImpl<PAGE_TYPE>& rhs) {
bool operator!=(const PageIteratorImpl<PAGE_TYPE>& rhs) const {
return rhs.p_ != p_;
}
inline PageIteratorImpl<PAGE_TYPE>& operator++();
......
......@@ -306,11 +306,11 @@ class PropertyDetails {
return PropertyDetails(PropertyKind::kData, NONE, cell_type);
}
bool operator==(PropertyDetails const& other) {
bool operator==(PropertyDetails const& other) const {
return value_ == other.value_;
}
bool operator!=(PropertyDetails const& other) {
bool operator!=(PropertyDetails const& other) const {
return value_ != other.value_;
}
......@@ -393,8 +393,6 @@ class PropertyDetails {
return PropertyCellTypeField::decode(value_);
}
bool operator==(const PropertyDetails& b) const { return value_ == b.value_; }
// Bit fields in value_ (type, shift, size). Must be public so the
// constants can be embedded in generated code.
using KindField = base::BitField<PropertyKind, 0, 1>;
......
......@@ -173,8 +173,12 @@ class IdentityMap : public IdentityMapBase {
V* operator*() { return entry(); }
V* operator->() { return entry(); }
bool operator!=(const Iterator& other) { return index_ != other.index_; }
bool operator==(const Iterator& other) { return index_ == other.index_; }
bool operator!=(const Iterator& other) const {
return index_ != other.index_;
}
bool operator==(const Iterator& other) const {
return index_ == other.index_;
}
private:
Iterator(IdentityMap* map, int index) : map_(map), index_(index) {}
......
......@@ -103,10 +103,10 @@ class V8_EXPORT_PRIVATE BytecodeIterator : public NON_EXPORTED_BASE(Decoder) {
ptr_ += OpcodeLength(ptr_, end_);
return *this;
}
bool operator==(const iterator_base& that) {
bool operator==(const iterator_base& that) const {
return this->ptr_ == that.ptr_;
}
bool operator!=(const iterator_base& that) {
bool operator!=(const iterator_base& that) const {
return this->ptr_ != that.ptr_;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment