[libc-commits] [libc] [libc] Remove some global printf_core declarations in float_dec_converter.h (PR #196860)
via libc-commits
libc-commits at lists.llvm.org
Sun May 10 17:51:43 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Nico Weber (nico)
<details>
<summary>Changes</summary>
fixed_converter.h and float_hex_converter.h have local declarations with the same name shadowing these, causing -Wshadow warnings. For now, just don't have global declarations for these.
---
Full diff: https://github.com/llvm/llvm-project/pull/196860.diff
1 Files Affected:
- (modified) libc/src/stdio/printf_core/float_dec_converter.h (+15-6)
``````````diff
diff --git a/libc/src/stdio/printf_core/float_dec_converter.h b/libc/src/stdio/printf_core/float_dec_converter.h
index 509b4e24ada32..8b99688cb993c 100644
--- a/libc/src/stdio/printf_core/float_dec_converter.h
+++ b/libc/src/stdio/printf_core/float_dec_converter.h
@@ -29,11 +29,6 @@
namespace LIBC_NAMESPACE_DECL {
namespace printf_core {
-#ifdef LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE
-using StorageType = UInt128;
-#else
-using StorageType = fputil::FPBits<long double>::StorageType;
-#endif // LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE
using DecimalString = IntegerToString<intmax_t>;
using ExponentString =
IntegerToString<intmax_t, radix::Dec::WithWidth<2>::WithSign>;
@@ -51,7 +46,6 @@ constexpr uint32_t MAX_BLOCK = 999999999;
// constexpr size_t BLOCK_SIZE = 18;
// constexpr uint32_t MAX_BLOCK = 999999999999999999;
-constexpr char DECIMAL_POINT = '.';
LIBC_INLINE RoundDirection get_round_direction(int last_digit, bool truncated,
Sign sign) {
@@ -176,6 +170,7 @@ template <WriteMode write_mode> class FloatWriter {
LIBC_INLINE int flush_buffer(bool round_up_max_blocks = false) {
const char MAX_BLOCK_DIGIT = (round_up_max_blocks ? '0' : '9');
+ constexpr char DECIMAL_POINT = '.';
// Write the most recent buffered block, and mark has_written
if (!has_written) {
@@ -368,6 +363,8 @@ template <WriteMode write_mode> class FloatWriter {
// has_carry should only be true here if every previous digit is 9, which
// implies that the number has never been written.
if (has_carry /* && !has_written */) {
+ constexpr char DECIMAL_POINT = '.';
+
if (has_exp) { // This is in %e style
// Since this is exponential notation, we don't write any more digits
// but we do increment the exponent.
@@ -604,6 +601,12 @@ template <typename T, WriteMode write_mode,
LIBC_INLINE int convert_float_dec_exp_typed(Writer<write_mode> *writer,
const FormatSection &to_conv,
fputil::FPBits<T> float_bits) {
+#ifdef LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE
+ using StorageType = UInt128;
+#else
+ using StorageType = fputil::FPBits<long double>::StorageType;
+#endif // LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE
+
// signed because later we use -FRACTION_LEN
constexpr int32_t FRACTION_LEN = fputil::FPBits<T>::FRACTION_LEN;
int exponent = float_bits.get_explicit_exponent();
@@ -766,6 +769,12 @@ template <typename T, WriteMode write_mode,
LIBC_INLINE int convert_float_dec_auto_typed(Writer<write_mode> *writer,
const FormatSection &to_conv,
fputil::FPBits<T> float_bits) {
+#ifdef LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE
+ using StorageType = UInt128;
+#else
+ using StorageType = fputil::FPBits<long double>::StorageType;
+#endif // LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE
+
// signed because later we use -FRACTION_LEN
constexpr int32_t FRACTION_LEN = fputil::FPBits<T>::FRACTION_LEN;
int exponent = float_bits.get_explicit_exponent();
``````````
</details>
https://github.com/llvm/llvm-project/pull/196860
More information about the libc-commits
mailing list