[libc-commits] [libc] [libc][printf] Break out floating point support behind weak symbols (PR #120612)

via libc-commits libc-commits at lists.llvm.org
Thu Dec 19 10:00:07 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff c4873819a98f59ce4e2664f94c73c2dfec3393f8 add704ac282b5b3e5fd1455d3f914e8491accb17 --extensions h,cpp -- libc/src/stdio/printf_core/split_float.cpp libc/src/stdio/printf_core/float_dec_converter.h libc/src/stdio/printf_core/float_hex_converter.h libc/src/stdio/printf_core/parser.h libc/src/stdio/printf_core/printf_config.h
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libc/src/stdio/printf_core/float_dec_converter.h b/libc/src/stdio/printf_core/float_dec_converter.h
index 5265f71499..968a900ff2 100644
--- a/libc/src/stdio/printf_core/float_dec_converter.h
+++ b/libc/src/stdio/printf_core/float_dec_converter.h
@@ -1115,8 +1115,8 @@ LIBC_PRINTF_SPLIT_DECL int convert_float_dec_auto(Writer *writer,
 
 #ifdef LIBC_PRINTF_DEFINE_SPLIT
 // TODO: unify the float converters to remove the duplicated checks for inf/nan.
-LIBC_PRINTF_SPLIT_DEFN int
-convert_float_decimal(Writer *writer, const FormatSection &to_conv) {
+LIBC_PRINTF_SPLIT_DEFN int convert_float_decimal(Writer *writer,
+                                                 const FormatSection &to_conv) {
   if (to_conv.length_modifier == LengthModifier::L) {
     fputil::FPBits<long double>::StorageType float_raw = to_conv.conv_val_raw;
     fputil::FPBits<long double> float_bits(float_raw);
@@ -1136,8 +1136,8 @@ convert_float_decimal(Writer *writer, const FormatSection &to_conv) {
   return convert_inf_nan(writer, to_conv);
 }
 
-LIBC_PRINTF_SPLIT_DEFN int
-convert_float_dec_exp(Writer *writer, const FormatSection &to_conv) {
+LIBC_PRINTF_SPLIT_DEFN int convert_float_dec_exp(Writer *writer,
+                                                 const FormatSection &to_conv) {
   if (to_conv.length_modifier == LengthModifier::L) {
     fputil::FPBits<long double>::StorageType float_raw = to_conv.conv_val_raw;
     fputil::FPBits<long double> float_bits(float_raw);
diff --git a/libc/src/stdio/printf_core/parser.h b/libc/src/stdio/printf_core/parser.h
index 3ac677e5d0..ad01378394 100644
--- a/libc/src/stdio/printf_core/parser.h
+++ b/libc/src/stdio/printf_core/parser.h
@@ -293,7 +293,9 @@ public:
     return section;
   }
 
-  LIBC_PRINTF_SPLIT_DECL void write_float_arg_val(FormatSection &section, LengthModifier lm, size_t conv_index);
+  LIBC_PRINTF_SPLIT_DECL void write_float_arg_val(FormatSection &section,
+                                                  LengthModifier lm,
+                                                  size_t conv_index);
   LIBC_PRINTF_SPLIT_DECL TypeDesc float_type_desc(LengthModifier lm);
   LIBC_PRINTF_SPLIT_DECL bool advance_arg_if_float(TypeDesc cur_type_desc);
 
@@ -700,9 +702,9 @@ template <typename ArgParser>
 LIBC_PRINTF_SPLIT_DEFN bool
 Parser<ArgParser>::advance_arg_if_float(TypeDesc cur_type_desc) {
   if (cur_type_desc == type_desc_from_type<double>())
-      args_cur.template next_var<double>();
+    args_cur.template next_var<double>();
   else if (cur_type_desc == type_desc_from_type<long double>())
-      args_cur.template next_var<long double>();
+    args_cur.template next_var<long double>();
   else
     return false;
   return true;

``````````

</details>


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


More information about the libc-commits mailing list