[libcxx-commits] [PATCH] D116120: [libc++][format] Improve ABI stability.

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Dec 21 11:34:58 PST 2021


Mordante updated this revision to Diff 395730.
Mordante added a comment.

Fix the CI. I had validated that -Wswitch wasn't used on Linux, but it seems
other CI jobs do, leading to an expected error.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116120/new/

https://reviews.llvm.org/D116120

Files:
  libcxx/include/__format/format_arg.h


Index: libcxx/include/__format/format_arg.h
===================================================================
--- libcxx/include/__format/format_arg.h
+++ libcxx/include/__format/format_arg.h
@@ -37,21 +37,20 @@
 #if !defined(_LIBCPP_HAS_NO_CONCEPTS)
 
 namespace __format {
-/** The type stored in @ref basic_format_arg. */
+/// The type stored in @ref basic_format_arg.
+///
+/// @note The 128-bit types are unconditionally in the list to avoid the values
+/// of the enums to depend on the availability of 128-bit integers.
 enum class _LIBCPP_ENUM_VIS __arg_t : uint8_t {
   __none,
   __boolean,
   __char_type,
   __int,
   __long_long,
-#ifndef _LIBCPP_HAS_NO_INT128
   __i128,
-#endif
   __unsigned,
   __unsigned_long_long,
-#ifndef _LIBCPP_HAS_NO_INT128
   __u128,
-#endif
   __float,
   __double,
   __long_double,
@@ -75,19 +74,11 @@
     return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__int);
   case __format::__arg_t::__long_long:
     return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__long_long);
-#ifndef _LIBCPP_HAS_NO_INT128
-  case __format::__arg_t::__i128:
-    return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__i128);
-#endif
   case __format::__arg_t::__unsigned:
     return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__unsigned);
   case __format::__arg_t::__unsigned_long_long:
     return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis),
                          __arg.__unsigned_long_long);
-#ifndef _LIBCPP_HAS_NO_INT128
-  case __format::__arg_t::__u128:
-    return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__u128);
-#endif
   case __format::__arg_t::__float:
     return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__float);
   case __format::__arg_t::__double:
@@ -101,6 +92,17 @@
     return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__string_view);
   case __format::__arg_t::__ptr:
     return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__ptr);
+
+  // When _LIBCPP_HAS_NO_INT128 is defined these cases fallthrough to
+  // _LIBCPP_UNREACHABLE().
+  case __format::__arg_t::__i128:
+#ifndef _LIBCPP_HAS_NO_INT128
+    return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__i128);
+#endif
+  case __format::__arg_t::__u128:
+#ifndef _LIBCPP_HAS_NO_INT128
+    return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__u128);
+#endif
   }
   _LIBCPP_UNREACHABLE();
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116120.395730.patch
Type: text/x-patch
Size: 2404 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211221/0a9fb29f/attachment.bin>


More information about the libcxx-commits mailing list