https://github.com/philnik777 updated https://github.com/llvm/llvm-project/pull/116261
>From 811186764d1add4d83972db3ad0d2e7c96bb15a7 Mon Sep 17 00:00:00 2001 From: Nikolas Klauser <nikolasklau...@berlin.de> Date: Sat, 16 Nov 2024 19:23:20 +0100 Subject: [PATCH 1/2] [libc++] Fix a few problems found by clang-tidy --- libcxx/include/__flat_map/flat_map.h | 4 ++-- libcxx/include/__locale_dir/locale_base_api.h | 6 +++--- libcxx/include/__ranges/to.h | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libcxx/include/__flat_map/flat_map.h b/libcxx/include/__flat_map/flat_map.h index 073b63cd8f0a66..58b362ad7a706f 100644 --- a/libcxx/include/__flat_map/flat_map.h +++ b/libcxx/include/__flat_map/flat_map.h @@ -113,7 +113,7 @@ class flat_map { class value_compare { private: key_compare __comp_; - value_compare(key_compare __c) : __comp_(__c) {} + _LIBCPP_HIDE_FROM_ABI value_compare(key_compare __c) : __comp_(__c) {} friend flat_map; public: @@ -659,7 +659,7 @@ class flat_map { template <class _InputIterator> requires __has_input_iterator_category<_InputIterator>::value - void insert(sorted_unique_t, _InputIterator __first, _InputIterator __last) { + _LIBCPP_HIDE_FROM_ABI void insert(sorted_unique_t, _InputIterator __first, _InputIterator __last) { if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) { __reserve(__last - __first); } diff --git a/libcxx/include/__locale_dir/locale_base_api.h b/libcxx/include/__locale_dir/locale_base_api.h index 5cbe91207ca74e..8ed4c29cb8732f 100644 --- a/libcxx/include/__locale_dir/locale_base_api.h +++ b/libcxx/include/__locale_dir/locale_base_api.h @@ -265,17 +265,17 @@ _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") // GCC doesn't support [[g template <class... _Args> _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 4, 5) int __snprintf( char* __s, size_t __n, __locale_t __loc, const char* __format, _Args&&... __args) { - return __libcpp_snprintf_l(__s, __n, __loc, __format, std::forward<_Args>(__args)...); + return std::__libcpp_snprintf_l(__s, __n, __loc, __format, std::forward<_Args>(__args)...); } template <class... _Args> _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __asprintf( char** __s, __locale_t __loc, const char* __format, _Args&&... __args) { - return __libcpp_asprintf_l(__s, __loc, __format, std::forward<_Args>(__args)...); + return std::__libcpp_asprintf_l(__s, __loc, __format, std::forward<_Args>(__args)...); } template <class... _Args> _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int __sscanf( const char* __s, __locale_t __loc, const char* __format, _Args&&... __args) { - return __libcpp_sscanf_l(__s, __loc, __format, std::forward<_Args>(__args)...); + return std::__libcpp_sscanf_l(__s, __loc, __format, std::forward<_Args>(__args)...); } _LIBCPP_DIAGNOSTIC_POP # undef _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT diff --git a/libcxx/include/__ranges/to.h b/libcxx/include/__ranges/to.h index 76249bdd9891c8..c937b0656de87d 100644 --- a/libcxx/include/__ranges/to.h +++ b/libcxx/include/__ranges/to.h @@ -111,14 +111,14 @@ template <class _Container, input_range _Range, class... _Args> for (auto&& __ref : __range) { using _Ref = decltype(__ref); - if constexpr (requires { __result.emplace_back(declval<_Ref>()); }) { + if constexpr (requires { __result.emplace_back(std::declval<_Ref>()); }) { __result.emplace_back(std::forward<_Ref>(__ref)); - } else if constexpr (requires { __result.push_back(declval<_Ref>()); }) { + } else if constexpr (requires { __result.push_back(std::declval<_Ref>()); }) { __result.push_back(std::forward<_Ref>(__ref)); - } else if constexpr (requires { __result.emplace(__result.end(), declval<_Ref>()); }) { + } else if constexpr (requires { __result.emplace(__result.end(), std::declval<_Ref>()); }) { __result.emplace(__result.end(), std::forward<_Ref>(__ref)); } else { - static_assert(requires { __result.insert(__result.end(), declval<_Ref>()); }); + static_assert(requires { __result.insert(__result.end(), std::declval<_Ref>()); }); __result.insert(__result.end(), std::forward<_Ref>(__ref)); } } >From 62231cdc5d9438f3bc0be46290464aea3a805952 Mon Sep 17 00:00:00 2001 From: Nikolas Klauser <nikolasklau...@berlin.de> Date: Thu, 14 Nov 2024 18:30:39 +0100 Subject: [PATCH 2/2] [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 ++++ libunwind/src/UnwindLevel1.c | 1 - libunwind/src/libunwind_ext.h | 1 + runtimes/cmake/Modules/WarningFlags.cmake | 1 + 7 files changed, 14 insertions(+), 4 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/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") _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits