Skip to content

Commit

Permalink
More C++20 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
xddxd authored and Nekotekina committed Apr 18, 2021
1 parent 5d8643e commit 4d88105
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
16 changes: 12 additions & 4 deletions include/llvm/ADT/DenseSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,12 @@ class DenseSetImpl {

Iterator& operator++() { ++I; return *this; }
Iterator operator++(int) { auto T = *this; ++I; return T; }
bool operator==(const ConstIterator& X) const { return I == X.I; }
bool operator!=(const ConstIterator& X) const { return I != X.I; }
friend bool operator==(const Iterator &X, const Iterator &Y) {
return X.I == Y.I;
}
friend bool operator!=(const Iterator &X, const Iterator &Y) {
return X.I != Y.I;
}
};

class ConstIterator {
Expand All @@ -155,8 +159,12 @@ class DenseSetImpl {

ConstIterator& operator++() { ++I; return *this; }
ConstIterator operator++(int) { auto T = *this; ++I; return T; }
bool operator==(const ConstIterator& X) const { return I == X.I; }
bool operator!=(const ConstIterator& X) const { return I != X.I; }
friend bool operator==(const ConstIterator &X, const ConstIterator &Y) {
return X.I == Y.I;
}
friend bool operator!=(const ConstIterator &X, const ConstIterator &Y) {
return X.I != Y.I;
}
};

using iterator = Iterator;
Expand Down
4 changes: 2 additions & 2 deletions include/llvm/CodeGen/LiveInterval.h
Original file line number Diff line number Diff line change
Expand Up @@ -731,10 +731,10 @@ namespace llvm {
++*this;
return res;
}
bool operator!=(const SingleLinkedListIterator<T> &Other) {
bool operator!=(const SingleLinkedListIterator<T> &Other) const {
return P != Other.operator->();
}
bool operator==(const SingleLinkedListIterator<T> &Other) {
bool operator==(const SingleLinkedListIterator<T> &Other) const {
return P == Other.operator->();
}
T &operator*() const {
Expand Down
8 changes: 6 additions & 2 deletions include/llvm/ProfileData/InstrProfReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ class InstrProfIterator : public std::iterator<std::input_iterator_tag,
InstrProfIterator(InstrProfReader *Reader) : Reader(Reader) { Increment(); }

InstrProfIterator &operator++() { Increment(); return *this; }
bool operator==(const InstrProfIterator &RHS) { return Reader == RHS.Reader; }
bool operator!=(const InstrProfIterator &RHS) { return Reader != RHS.Reader; }
bool operator==(const InstrProfIterator &RHS) const {
return Reader == RHS.Reader;
}
bool operator!=(const InstrProfIterator &RHS) const {
return Reader != RHS.Reader;
}
value_type &operator*() { return Record; }
value_type *operator->() { return &Record; }
};
Expand Down
4 changes: 2 additions & 2 deletions include/llvm/Support/SuffixTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,10 @@ class SuffixTree {
return It;
}

bool operator==(const RepeatedSubstringIterator &Other) {
bool operator==(const RepeatedSubstringIterator &Other) const {
return N == Other.N;
}
bool operator!=(const RepeatedSubstringIterator &Other) {
bool operator!=(const RepeatedSubstringIterator &Other) const {
return !(*this == Other);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Transforms/Scalar/GVNHoist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ struct CHIArg {
// The instruction (VN) which uses the values flowing out of CHI.
Instruction *I;

bool operator==(const CHIArg &A) { return VN == A.VN; }
bool operator!=(const CHIArg &A) { return !(*this == A); }
bool operator==(const CHIArg &A) const { return VN == A.VN; }
bool operator!=(const CHIArg &A) const { return !(*this == A); }
};

using CHIIt = SmallVectorImpl<CHIArg>::iterator;
Expand Down

0 comments on commit 4d88105

Please sign in to comment.