[libc-commits] [libc] [lldb] Move definition of SBSaveCoreOptions dtor out of header (#102539) (PR #102672)
Roland McGrath via libc-commits
libc-commits at lists.llvm.org
Fri Aug 9 13:02:39 PDT 2024
https://github.com/frobtech created https://github.com/llvm/llvm-project/pull/102672
This class is technically not usable in its current state. When you use
it in a simple C++ project, your compiler will complain about an
incomplete definition of SaveCoreOptions. Normally this isn't a problem,
other classes in the SBAPI do this. The difference is that
SBSaveCoreOptions has a default destructor in the header, so the
compiler will attempt to generate the code for the destructor with an
incomplete definition of the impl type.
All methods for every class, including constructors and destructors,
must have a separate implementation not in a header.
>From 56be26fc03872972f6395bc7eaaeee7125d61b96 Mon Sep 17 00:00:00 2001
From: Roland McGrath <mcgrathr at google.com>
Date: Fri, 9 Aug 2024 13:00:29 -0700
Subject: [PATCH] [libc] Fix use of cpp::numeric_limits<...>::digits
The previous change replaced INT_WIDTH with
cpp::numberic_limits<int>::digits, but these don't have the same
value. While INT_WIDTH == UINT_WIDTH, not so for ::digits, so
use cpp::numberic_limits<unsigned int>::digits et al instead for
the intended effects.
Bug: https://issues.fuchsia.dev/358196552
---
libc/src/stdio/printf_core/parser.h | 6 +++---
libc/test/src/stdbit/stdc_leading_zeros_ui_test.cpp | 13 +++++++------
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/libc/src/stdio/printf_core/parser.h b/libc/src/stdio/printf_core/parser.h
index 9a3f19a919744..684911a567569 100644
--- a/libc/src/stdio/printf_core/parser.h
+++ b/libc/src/stdio/printf_core/parser.h
@@ -211,11 +211,11 @@ template <typename ArgProvider> class Parser {
case (LengthModifier::wf):
if (bw == 0) {
section.has_conv = false;
- } else if (bw <= cpp::numeric_limits<int>::digits) {
+ } else if (bw <= cpp::numeric_limits<unsigned int>::digits) {
WRITE_ARG_VAL_SIMPLEST(section.conv_val_raw, int, conv_index);
- } else if (bw <= cpp::numeric_limits<long>::digits) {
+ } else if (bw <= cpp::numeric_limits<unsigned long>::digits) {
WRITE_ARG_VAL_SIMPLEST(section.conv_val_raw, long, conv_index);
- } else if (bw <= cpp::numeric_limits<long long>::digits) {
+ } else if (bw <= cpp::numeric_limits<unsigned long long>::digits) {
WRITE_ARG_VAL_SIMPLEST(section.conv_val_raw, long long, conv_index);
} else {
WRITE_ARG_VAL_SIMPLEST(section.conv_val_raw, intmax_t, conv_index);
diff --git a/libc/test/src/stdbit/stdc_leading_zeros_ui_test.cpp b/libc/test/src/stdbit/stdc_leading_zeros_ui_test.cpp
index f1b8363ecc8f7..c047457cc82e5 100644
--- a/libc/test/src/stdbit/stdc_leading_zeros_ui_test.cpp
+++ b/libc/test/src/stdbit/stdc_leading_zeros_ui_test.cpp
@@ -12,14 +12,15 @@
#include <stddef.h>
TEST(LlvmLibcStdcLeadingZerosUiTest, Zero) {
- EXPECT_EQ(
- LIBC_NAMESPACE::stdc_leading_zeros_ui(0U),
- static_cast<unsigned>(LIBC_NAMESPACE::cpp::numeric_limits<int>::digits));
+ EXPECT_EQ(LIBC_NAMESPACE::stdc_leading_zeros_ui(0U),
+ static_cast<unsigned>(
+ LIBC_NAMESPACE::cpp::numeric_limits<unsigned int>::digits));
}
TEST(LlvmLibcStdcLeadingZerosUiTest, OneHot) {
- for (unsigned i = 0U; i != LIBC_NAMESPACE::cpp::numeric_limits<int>::digits;
- ++i)
+ for (unsigned i = 0U;
+ i != LIBC_NAMESPACE::cpp::numeric_limits<unsigned int>::digits; ++i)
EXPECT_EQ(LIBC_NAMESPACE::stdc_leading_zeros_ui(1U << i),
- LIBC_NAMESPACE::cpp::numeric_limits<int>::digits - i - 1);
+ LIBC_NAMESPACE::cpp::numeric_limits<unsigned int>::digits - i -
+ 1);
}
More information about the libc-commits
mailing list