[libcxx-commits] [libcxx] [llvm] [libc++] Enable -Wmissing-prototypes (PR #116261)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Thu Nov 14 09:31:12 PST 2024


https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/116261

None

>From 3c30f7a244b9c3397f80cd0f7e3ffe7d58c48b73 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/filesystem/int128_builtins.cpp      | 2 ++
 libcxx/src/include/from_chars_floating_point.h | 4 ++--
 libcxx/src/legacy_pointer_safety.cpp           | 4 ++++
 runtimes/cmake/Modules/WarningFlags.cmake      | 1 +
 5 files changed, 13 insertions(+), 3 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/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/libcxx/src/legacy_pointer_safety.cpp b/libcxx/src/legacy_pointer_safety.cpp
index a9361ca879bb58..31abc978499006 100644
--- a/libcxx/src/legacy_pointer_safety.cpp
+++ b/libcxx/src/legacy_pointer_safety.cpp
@@ -15,9 +15,13 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+_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 void declare_reachable(void*) {}
 _LIBCPP_EXPORTED_FROM_ABI void declare_no_pointers(char*, size_t) {}
 _LIBCPP_EXPORTED_FROM_ABI void undeclare_no_pointers(char*, size_t) {}
 _LIBCPP_EXPORTED_FROM_ABI void* __undeclare_reachable(void* p) { return p; }
+_LIBCPP_DIAGNOSTIC_POP
 
 _LIBCPP_END_NAMESPACE_STD
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 libcxx-commits mailing list