[libcxx] [libcxxabi] [libunwind] [llvm] [libc++] Enable -Wmissing-prototypes (PR #116261)
Nikolas Klauser via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 27 02:27:52 PST 2024
https://github.com/philnik777 updated https://github.com/llvm/llvm-project/pull/116261
>From 4efe922727331e091d27c8eb3e2431d6349b1a40 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Thu, 14 Nov 2024 18:30:39 +0100
Subject: [PATCH] [libc++] Enable -Wmissing-prototypes
---
libcxx/src/charconv.cpp | 5 ++++-
libcxx/src/experimental/time_zone.cpp | 2 +-
libcxx/src/experimental/tzdb.cpp | 3 +++
libcxx/src/filesystem/int128_builtins.cpp | 2 ++
libcxx/src/include/from_chars_floating_point.h | 4 ++--
libcxxabi/src/cxa_personality.cpp | 5 +++++
libcxxabi/src/private_typeinfo.cpp | 6 ++++++
libunwind/src/UnwindLevel1.c | 1 -
libunwind/src/libunwind_ext.h | 1 +
runtimes/cmake/Modules/WarningFlags.cmake | 1 +
10 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/libcxx/src/charconv.cpp b/libcxx/src/charconv.cpp
index 5e8cb7d97703b4..4621df05066997 100644
--- a/libcxx/src/charconv.cpp
+++ b/libcxx/src/charconv.cpp
@@ -18,9 +18,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
namespace __itoa {
+_LIBCPP_DIAGNOSTIC_PUSH
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-prototypes")
+// These functions exist for ABI compatibility, so we don't ever want a declaration.
_LIBCPP_EXPORTED_FROM_ABI char* __u32toa(uint32_t value, char* buffer) noexcept { return __base_10_u32(buffer, value); }
-
_LIBCPP_EXPORTED_FROM_ABI char* __u64toa(uint64_t value, char* buffer) noexcept { return __base_10_u64(buffer, value); }
+_LIBCPP_DIAGNOSTIC_POP
} // namespace __itoa
diff --git a/libcxx/src/experimental/time_zone.cpp b/libcxx/src/experimental/time_zone.cpp
index 764a89ab513c86..c5ba94321e07ce 100644
--- a/libcxx/src/experimental/time_zone.cpp
+++ b/libcxx/src/experimental/time_zone.cpp
@@ -711,7 +711,7 @@ __get_sys_info(sys_seconds __time,
// Iff the "offsets" are the same '__current.__end' is replaced with
// '__next.__end', which effectively merges the two objects in one object. The
// function returns true if a merge occurred.
-[[nodiscard]] bool __merge_continuation(sys_info& __current, const sys_info& __next) {
+[[nodiscard]] static bool __merge_continuation(sys_info& __current, const sys_info& __next) {
if (__current.end != __next.begin)
return false;
diff --git a/libcxx/src/experimental/tzdb.cpp b/libcxx/src/experimental/tzdb.cpp
index d22de21c998198..10333795274212 100644
--- a/libcxx/src/experimental/tzdb.cpp
+++ b/libcxx/src/experimental/tzdb.cpp
@@ -45,6 +45,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
namespace chrono {
+_LIBCPP_DIAGNOSTIC_PUSH
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-prototypes")
// This function is weak so it can be overriden in the tests. The
// declaration is in the test header test/support/test_tzdb.h
_LIBCPP_WEAK string_view __libcpp_tzdb_directory() {
@@ -54,6 +56,7 @@ _LIBCPP_WEAK string_view __libcpp_tzdb_directory() {
# error "unknown path to the IANA Time Zone Database"
#endif
}
+_LIBCPP_DIAGNOSTIC_POP
//===----------------------------------------------------------------------===//
// Details
diff --git a/libcxx/src/filesystem/int128_builtins.cpp b/libcxx/src/filesystem/int128_builtins.cpp
index da6f39e7d78b60..e811b3e6f912db 100644
--- a/libcxx/src/filesystem/int128_builtins.cpp
+++ b/libcxx/src/filesystem/int128_builtins.cpp
@@ -16,6 +16,8 @@
#include <__config>
#include <climits>
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-prototypes") // See the FIXME above
+
#if _LIBCPP_HAS_INT128
extern "C" __attribute__((no_sanitize("undefined"))) _LIBCPP_EXPORTED_FROM_ABI __int128_t
diff --git a/libcxx/src/include/from_chars_floating_point.h b/libcxx/src/include/from_chars_floating_point.h
index 19eeeb28fb08d2..81d2180cc94805 100644
--- a/libcxx/src/include/from_chars_floating_point.h
+++ b/libcxx/src/include/from_chars_floating_point.h
@@ -193,7 +193,7 @@ struct __exponent_result {
// __offset, 0, false. This allows using the results unconditionally, the
// __present is important for the scientific notation, where the value is
// mandatory.
-__exponent_result __parse_exponent(const char* __input, size_t __n, size_t __offset, char __marker) {
+static __exponent_result __parse_exponent(const char* __input, size_t __n, size_t __offset, char __marker) {
if (__offset + 1 < __n && // an exponent always needs at least one digit.
std::tolower(__input[__offset]) == __marker && //
!std::isspace(__input[__offset + 1]) // leading whitespace is not allowed.
@@ -213,7 +213,7 @@ __exponent_result __parse_exponent(const char* __input, size_t __n, size_t __off
}
// Here we do this operation as int64 to avoid overflow.
-int32_t __merge_exponents(int64_t __fractional, int64_t __exponent, int __max_biased_exponent) {
+static int32_t __merge_exponents(int64_t __fractional, int64_t __exponent, int __max_biased_exponent) {
int64_t __sum = __fractional + __exponent;
if (__sum > __max_biased_exponent)
diff --git a/libcxxabi/src/cxa_personality.cpp b/libcxxabi/src/cxa_personality.cpp
index 5f6e75c5be19ce..1836fba5ab5dd5 100644
--- a/libcxxabi/src/cxa_personality.cpp
+++ b/libcxxabi/src/cxa_personality.cpp
@@ -22,6 +22,11 @@
#include "private_typeinfo.h"
#include "unwind.h"
+// The functions defined in this file are magic functions called only by the compiler.
+#ifdef __clang__
+# pragma clang diagnostic ignored "-Wmissing-prototypes"
+#endif
+
// TODO: This is a temporary workaround for libc++abi to recognize that it's being
// built against LLVM's libunwind. LLVM's libunwind started reporting _LIBUNWIND_VERSION
// in LLVM 15 -- we can remove this workaround after shipping LLVM 17. Once we remove
diff --git a/libcxxabi/src/private_typeinfo.cpp b/libcxxabi/src/private_typeinfo.cpp
index 01a1d2603b18d0..d185f2618a7eab 100644
--- a/libcxxabi/src/private_typeinfo.cpp
+++ b/libcxxabi/src/private_typeinfo.cpp
@@ -831,6 +831,10 @@ bool __pointer_to_member_type_info::can_catch_nested(
#pragma clang diagnostic ignored "-Wmissing-field-initializers"
#endif
+#pragma GCC diagnostic push
+// __dynamic_cast is called by the compiler, so there is no prototype
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+
// __dynamic_cast
// static_ptr: pointer to an object of type static_type; nonnull, and since the
@@ -953,6 +957,8 @@ __dynamic_cast(const void *static_ptr, const __class_type_info *static_type,
return const_cast<void*>(dst_ptr);
}
+#pragma GCC diagnostic pop
+
#ifdef __clang__
#pragma clang diagnostic pop
#endif
diff --git a/libunwind/src/UnwindLevel1.c b/libunwind/src/UnwindLevel1.c
index 7e785f4d31e716..e7e2b6ef624dce 100644
--- a/libunwind/src/UnwindLevel1.c
+++ b/libunwind/src/UnwindLevel1.c
@@ -181,7 +181,6 @@ unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *except
}
return _URC_NO_REASON;
}
-extern int __unw_step_stage2(unw_cursor_t *);
#if defined(_LIBUNWIND_USE_GCS)
// Enable the GCS target feature to permit gcspop instructions to be used.
diff --git a/libunwind/src/libunwind_ext.h b/libunwind/src/libunwind_ext.h
index 28db43a4f6eef2..306ed41b3db631 100644
--- a/libunwind/src/libunwind_ext.h
+++ b/libunwind/src/libunwind_ext.h
@@ -26,6 +26,7 @@ extern "C" {
extern int __unw_getcontext(unw_context_t *);
extern int __unw_init_local(unw_cursor_t *, unw_context_t *);
extern int __unw_step(unw_cursor_t *);
+extern int __unw_step_stage2(unw_cursor_t *);
extern int __unw_get_reg(unw_cursor_t *, unw_regnum_t, unw_word_t *);
extern int __unw_get_fpreg(unw_cursor_t *, unw_regnum_t, unw_fpreg_t *);
extern int __unw_set_reg(unw_cursor_t *, unw_regnum_t, unw_word_t);
diff --git a/runtimes/cmake/Modules/WarningFlags.cmake b/runtimes/cmake/Modules/WarningFlags.cmake
index d17bf92389d0b0..15e6772c2fae98 100644
--- a/runtimes/cmake/Modules/WarningFlags.cmake
+++ b/runtimes/cmake/Modules/WarningFlags.cmake
@@ -25,6 +25,7 @@ function(cxx_add_warning_flags target enable_werror enable_pedantic)
-Wformat-nonliteral
-Wzero-length-array
-Wdeprecated-redundant-constexpr-static-def
+ -Wmissing-prototypes
)
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
More information about the llvm-commits
mailing list