[llvm] 8f859cc - Use std::less instead of operator < in less_first and less_second
Akira Hatanaka via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 27 12:59:45 PDT 2021
Author: Akira Hatanaka
Date: 2021-08-27T12:56:08-07:00
New Revision: 8f859cc34966ede0054842cb5243536f9572b708
URL: https://github.com/llvm/llvm-project/commit/8f859cc34966ede0054842cb5243536f9572b708
DIFF: https://github.com/llvm/llvm-project/commit/8f859cc34966ede0054842cb5243536f9572b708.diff
LOG: Use std::less instead of operator < in less_first and less_second
According to the standard, if p1 and p2 are both pointers, p1 < p2 and
p2 < p1 can both be false in theory in some cases:
https://eel.is/c++draft/expr.rel#4.3
std::less<void> yields a implementation-defined strict total order over
pointers:
https://eel.is/c++draft/comparisons.general
Differential Revision: https://reviews.llvm.org/D108733
Added:
Modified:
llvm/include/llvm/ADT/STLExtras.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h
index 1ecc678e37a1f..0c923e905b59c 100644
--- a/llvm/include/llvm/ADT/STLExtras.h
+++ b/llvm/include/llvm/ADT/STLExtras.h
@@ -1273,7 +1273,7 @@ template <typename ContainerTy> auto make_second_range(ContainerTy &&c) {
/// compares less than the first component of another std::pair.
struct less_first {
template <typename T> bool operator()(const T &lhs, const T &rhs) const {
- return lhs.first < rhs.first;
+ return std::less<>()(lhs.first, rhs.first);
}
};
@@ -1281,7 +1281,7 @@ struct less_first {
/// compares less than the second component of another std::pair.
struct less_second {
template <typename T> bool operator()(const T &lhs, const T &rhs) const {
- return lhs.second < rhs.second;
+ return std::less<>()(lhs.second, rhs.second);
}
};
More information about the llvm-commits
mailing list