Skip to content

Commit

Permalink
[libc++] Avoid overload resolution in path comparison operators
Browse files Browse the repository at this point in the history
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
  • Loading branch information
JoeLoser committed Nov 25, 2021
1 parent 68e7e76 commit 3e7452a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions libcxx/include/filesystem
Expand Up @@ -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,
Expand Down

0 comments on commit 3e7452a

Please sign in to comment.