[libc-commits] [libc] [libc] Add Q length modifier to support float128 conversions in printf (PR #203077)

Alex Strelnikov via libc-commits libc-commits at lists.llvm.org
Mon Jun 22 09:41:06 PDT 2026


================
@@ -665,12 +690,19 @@ template <typename ArgProvider> class Parser {
         case ('A'):
         case ('g'):
         case ('G'):
-          if (lm != LengthModifier::L)
-            conv_size = type_desc_from_type<double>();
+#if defined(LIBC_INTERNAL_PRINTF_CONVERT_FLOAT128)
+          if (lm == LengthModifier::Q) {
+            conv_size = type_desc_from_type<float128>();
+          } else
+#endif // LIBC_INTERNAL_PRINTF_CONVERT_FLOAT128
 #ifndef LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE
-          else
+              if (lm == LengthModifier::L) {
             conv_size = type_desc_from_type<long double>();
+          } else
 #endif // !LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE
+          {
+            conv_size = type_desc_from_type<double>();
+          }
----------------
strel-12 wrote:

Thanks, updated to use a `switch`.

https://github.com/llvm/llvm-project/pull/203077


More information about the libc-commits mailing list