[libcxx-commits] [libcxx] 3e7452a - [libc++] Avoid overload resolution in path comparison operators
Joe Loser via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Nov 25 08:41:30 PST 2021
Author: Joe Loser
Date: 2021-11-25T11:40:55-05:00
New Revision: 3e7452a812fa06c5eaae7d089891489222417e92
URL: https://github.com/llvm/llvm-project/commit/3e7452a812fa06c5eaae7d089891489222417e92
DIFF: https://github.com/llvm/llvm-project/commit/3e7452a812fa06c5eaae7d089891489222417e92.diff
LOG: [libc++] Avoid overload resolution in path comparison operators
Rework `std::filesystem::path::operator==` and friends to avoid overload
resolution and atomic constraint caching issues shown from
https://reviews.llvm.org/D113161.
Always call `__compare(string_view)` from the comparison operators which avoids
overload resolution.
Differential Revision: https://reviews.llvm.org/D114570
Added:
Modified:
libcxx/include/filesystem
Removed:
################################################################################
diff --git a/libcxx/include/filesystem b/libcxx/include/filesystem
index 6a42824d6452..c688ab765b13 100644
--- a/libcxx/include/filesystem
+++ b/libcxx/include/filesystem
@@ -1492,22 +1492,22 @@ public:
#endif // !_LIBCPP_HAS_NO_LOCALIZATION
friend _LIBCPP_INLINE_VISIBILITY bool operator==(const path& __lhs, const path& __rhs) noexcept {
- return __lhs.compare(__rhs) == 0;
+ return __lhs.__compare(__rhs.__pn_) == 0;
}
friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const path& __lhs, const path& __rhs) noexcept {
- return __lhs.compare(__rhs) != 0;
+ return __lhs.__compare(__rhs.__pn_) != 0;
}
friend _LIBCPP_INLINE_VISIBILITY bool operator<(const path& __lhs, const path& __rhs) noexcept {
- return __lhs.compare(__rhs) < 0;
+ return __lhs.__compare(__rhs.__pn_) < 0;
}
friend _LIBCPP_INLINE_VISIBILITY bool operator<=(const path& __lhs, const path& __rhs) noexcept {
- return __lhs.compare(__rhs) <= 0;
+ return __lhs.__compare(__rhs.__pn_) <= 0;
}
friend _LIBCPP_INLINE_VISIBILITY bool operator>(const path& __lhs, const path& __rhs) noexcept {
- return __lhs.compare(__rhs) > 0;
+ return __lhs.__compare(__rhs.__pn_) > 0;
}
friend _LIBCPP_INLINE_VISIBILITY bool operator>=(const path& __lhs, const path& __rhs) noexcept {
- return __lhs.compare(__rhs) >= 0;
+ return __lhs.__compare(__rhs.__pn_) >= 0;
}
friend _LIBCPP_INLINE_VISIBILITY path operator/(const path& __lhs,
More information about the libcxx-commits
mailing list