[libcxx-commits] [libcxx] 7a98d83 - [libc++] Fixes concepts overload resolution.

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Sat Apr 23 09:19:16 PDT 2022


Author: Mark de Wever
Date: 2022-04-23T18:19:11+02:00
New Revision: 7a98d8351b27b1e20ca606d9b2d0fd155dd169ff

URL: https://github.com/llvm/llvm-project/commit/7a98d8351b27b1e20ca606d9b2d0fd155dd169ff
DIFF: https://github.com/llvm/llvm-project/commit/7a98d8351b27b1e20ca606d9b2d0fd155dd169ff.diff

LOG: [libc++] Fixes concepts overload resolution.

D123182 fixes a bug in Clang's overload resolution. After it landed it
was discovered `basic_format_arg`'s constructors contains this bug. This
fixes the bug in libc++, unblocking D123182.

The code has been tested in combination with D123182.

Reviewed By: royjacobson, #libc

Differential Revision: https://reviews.llvm.org/D124103

Added: 
    

Modified: 
    libcxx/include/__format/format_arg.h

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__format/format_arg.h b/libcxx/include/__format/format_arg.h
index c5320ecf4327f..45356b22cd463 100644
--- a/libcxx/include/__format/format_arg.h
+++ b/libcxx/include/__format/format_arg.h
@@ -160,17 +160,17 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_arg {
   };
   __format::__arg_t __type_;
 
-  _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(bool __v) noexcept
+  _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(const bool& __v) noexcept
       : __boolean(__v), __type_(__format::__arg_t::__boolean) {}
 
   template <class _Tp>
-  _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(_Tp __v) noexcept
+  _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(const _Tp& __v) noexcept
       requires(same_as<_Tp, char_type> ||
                (same_as<_Tp, char> && same_as<char_type, wchar_t>))
       : __char_type(__v), __type_(__format::__arg_t::__char_type) {}
 
   template <__libcpp_signed_integer _Tp>
-  _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(_Tp __v) noexcept {
+  _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(const _Tp& __v) noexcept {
     if constexpr (sizeof(_Tp) <= sizeof(int)) {
       __int = static_cast<int>(__v);
       __type_ = __format::__arg_t::__int;
@@ -189,7 +189,7 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_arg {
   }
 
   template <__libcpp_unsigned_integer _Tp>
-  _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(_Tp __v) noexcept {
+  _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(const _Tp& __v) noexcept {
     if constexpr (sizeof(_Tp) <= sizeof(unsigned)) {
       __unsigned = static_cast<unsigned>(__v);
       __type_ = __format::__arg_t::__unsigned;


        


More information about the libcxx-commits mailing list