[libcxx-commits] [libcxxabi] e65cd4c - [libc++] Enable -Wunused-template
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Mar 8 10:26:56 PST 2023
Author: Nikolas Klauser
Date: 2023-03-08T19:26:49+01:00
New Revision: e65cd4ce832b52d7b625a1e01cbecb264f9d2716
URL: https://github.com/llvm/llvm-project/commit/e65cd4ce832b52d7b625a1e01cbecb264f9d2716
DIFF: https://github.com/llvm/llvm-project/commit/e65cd4ce832b52d7b625a1e01cbecb264f9d2716.diff
LOG: [libc++] Enable -Wunused-template
Clang wants to enable this flag by default, but libc++ isn't working with it yet.
Reviewed By: Mordante, #libc, #libc_abi, EricWF
Spies: libcxx-commits, arichardson
Differential Revision: https://reviews.llvm.org/D144667
Added:
Modified:
libcxx/CMakeLists.txt
libcxx/include/__algorithm/make_projected.h
libcxx/include/__config
libcxx/include/__memory/shared_ptr.h
libcxx/include/__type_traits/is_nothrow_convertible.h
libcxx/src/filesystem/filesystem_common.h
libcxx/utils/libcxx/test/params.py
libcxxabi/src/demangle/StringView.h
Removed:
################################################################################
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 0c1b2fe32f7ae..ed9aaf60f255d 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -568,9 +568,15 @@ function(cxx_add_warning_flags target)
else()
target_add_compile_flags_if_supported(${target} PRIVATE -Wall)
endif()
- target_add_compile_flags_if_supported(${target} PRIVATE -Wextra -W -Wwrite-strings
- -Wno-unused-parameter -Wno-long-long
- -Werror=return-type -Wextra-semi -Wundef
+ target_add_compile_flags_if_supported(${target} PRIVATE -Wextra
+ -W
+ -Wwrite-strings
+ -Wno-unused-parameter
+ -Wno-long-long
+ -Werror=return-type
+ -Wextra-semi
+ -Wundef
+ -Wunused-template
-Wformat-nonliteral)
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
target_add_compile_flags_if_supported(${target} PRIVATE
diff --git a/libcxx/include/__algorithm/make_projected.h b/libcxx/include/__algorithm/make_projected.h
index f4ca4c9d4a7a8..61055fcdf30d7 100644
--- a/libcxx/include/__algorithm/make_projected.h
+++ b/libcxx/include/__algorithm/make_projected.h
@@ -60,7 +60,7 @@ template <class _Pred,
__enable_if_t<!(!is_member_pointer<typename decay<_Pred>::type>::value &&
__is_identity<typename decay<_Proj>::type>::value),
int> = 0>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static _ProjectedPred<_Pred, _Proj>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ProjectedPred<_Pred, _Proj>
__make_projected(_Pred& __pred, _Proj& __proj) {
return _ProjectedPred<_Pred, _Proj>(__pred, __proj);
}
@@ -73,7 +73,7 @@ template <class _Pred,
__enable_if_t<!is_member_pointer<typename decay<_Pred>::type>::value &&
__is_identity<typename decay<_Proj>::type>::value,
int> = 0>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static _Pred& __make_projected(_Pred& __pred, _Proj&) {
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Pred& __make_projected(_Pred& __pred, _Proj&) {
return __pred;
}
@@ -86,7 +86,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
namespace ranges {
template <class _Comp, class _Proj1, class _Proj2>
-_LIBCPP_HIDE_FROM_ABI constexpr static
+_LIBCPP_HIDE_FROM_ABI constexpr
decltype(auto) __make_projected_comp(_Comp& __comp, _Proj1& __proj1, _Proj2& __proj2) {
if constexpr (__is_identity<decay_t<_Proj1>>::value && __is_identity<decay_t<_Proj2>>::value &&
!is_member_pointer_v<decay_t<_Comp>>) {
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 95a75ea758d53..d3063f039a890 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -1254,13 +1254,19 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
// macro is used to mark them as such, which suppresses the
// '-Wctad-maybe-unsupported' compiler warning when CTAD is used in user code
// with these classes.
-#if _LIBCPP_STD_VER >= 17
-# define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) \
- template <class ..._Tag> \
- _ClassName(typename _Tag::__allow_ctad...) -> _ClassName<_Tag...>
-#else
-# define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) static_assert(true, "")
-#endif
+# if _LIBCPP_STD_VER >= 17
+# ifdef _LIBCPP_COMPILER_CLANG_BASED
+# define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) \
+ template <class... _Tag> \
+ [[maybe_unused]] _ClassName(typename _Tag::__allow_ctad...)->_ClassName<_Tag...>
+# else
+# define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(ClassName) \
+ template <class... _Tag> \
+ ClassName(typename _Tag::__allow_ctad...)->ClassName<_Tag...>
+# endif
+# else
+# define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) static_assert(true, "")
+# endif
// TODO(varconst): currently, there are bugs in Clang's intrinsics when handling Objective-C++ `id`, so don't use
// compiler intrinsics in the Objective-C++ mode.
diff --git a/libcxx/include/__memory/shared_ptr.h b/libcxx/include/__memory/shared_ptr.h
index 3ef264dcfe48c..70615176d3703 100644
--- a/libcxx/include/__memory/shared_ptr.h
+++ b/libcxx/include/__memory/shared_ptr.h
@@ -433,10 +433,10 @@ struct __is_array_deletable<_Ptr, decltype(delete[] std::declval<_Ptr>())> : tru
template <class _Dp, class _Pt,
class = decltype(std::declval<_Dp>()(std::declval<_Pt>()))>
-static true_type __well_formed_deleter_test(int);
+true_type __well_formed_deleter_test(int);
template <class, class>
-static false_type __well_formed_deleter_test(...);
+false_type __well_formed_deleter_test(...);
template <class _Dp, class _Pt>
struct __well_formed_deleter : decltype(std::__well_formed_deleter_test<_Dp, _Pt>(0)) {};
diff --git a/libcxx/include/__type_traits/is_nothrow_convertible.h b/libcxx/include/__type_traits/is_nothrow_convertible.h
index 148c2d68ccabd..64f75e1fd68db 100644
--- a/libcxx/include/__type_traits/is_nothrow_convertible.h
+++ b/libcxx/include/__type_traits/is_nothrow_convertible.h
@@ -27,10 +27,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER >= 20
template <typename _Tp>
-static void __test_noexcept(_Tp) noexcept;
+void __test_noexcept(_Tp) noexcept;
template<typename _Fm, typename _To>
-static bool_constant<noexcept(_VSTD::__test_noexcept<_To>(std::declval<_Fm>()))>
+bool_constant<noexcept(_VSTD::__test_noexcept<_To>(std::declval<_Fm>()))>
__is_nothrow_convertible_test();
template <typename _Fm, typename _To>
diff --git a/libcxx/src/filesystem/filesystem_common.h b/libcxx/src/filesystem/filesystem_common.h
index fb6f88783cd03..5867805efeeeb 100644
--- a/libcxx/src/filesystem/filesystem_common.h
+++ b/libcxx/src/filesystem/filesystem_common.h
@@ -44,9 +44,11 @@
#endif
#endif
+// TODO: Check whether these functions actually need internal linkage, or if they can be made normal header functions
_LIBCPP_DIAGNOSTIC_PUSH
_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wunused-function")
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wunused-function")
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wunused-template")
#if defined(_LIBCPP_WIN32API)
# define PATHSTR(x) (L##x)
diff --git a/libcxx/utils/libcxx/test/params.py b/libcxx/utils/libcxx/test/params.py
index 0574a00a737bd..db4c5efc08a05 100644
--- a/libcxx/utils/libcxx/test/params.py
+++ b/libcxx/utils/libcxx/test/params.py
@@ -17,6 +17,7 @@
'-Wextra',
'-Wshadow',
'-Wundef',
+ '-Wunused-template',
'-Wno-unused-command-line-argument',
'-Wno-attributes',
'-Wno-pessimizing-move',
diff --git a/libcxxabi/src/demangle/StringView.h b/libcxxabi/src/demangle/StringView.h
index 90890e3771102..07b7cf8575753 100644
--- a/libcxxabi/src/demangle/StringView.h
+++ b/libcxxabi/src/demangle/StringView.h
@@ -17,9 +17,16 @@
#define DEMANGLE_STRINGVIEW_H
#include "DemangleConfig.h"
+
+#include <__cxxabi_config.h>
#include <cassert>
#include <cstring>
+#ifdef _LIBCXXABI_COMPILER_CLANG
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunused-template"
+#endif
+
DEMANGLE_NAMESPACE_BEGIN
class StringView {
@@ -119,4 +126,8 @@ inline bool operator==(const StringView &LHS, const StringView &RHS) {
DEMANGLE_NAMESPACE_END
+#ifdef _LIBCXXABI_COMPILER_CLANG
+#pragma clang diagnostic pop
+#endif
+
#endif
More information about the libcxx-commits
mailing list