From 3e7452a812fa06c5eaae7d089891489222417e92 Mon Sep 17 00:00:00 2001 From: Joe Loser Date: Wed, 24 Nov 2021 22:48:40 -0500 Subject: [PATCH] [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 --- libcxx/include/filesystem | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libcxx/include/filesystem b/libcxx/include/filesystem index 6a42824d6452e..c688ab765b13f 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,