[libcxx-commits] [libcxx] [libcxxabi] [llvm] [libc++] Make variables in templates inline (PR #115785)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Tue Nov 12 07:53:31 PST 2024


https://github.com/philnik777 updated https://github.com/llvm/llvm-project/pull/115785

>From 86f3e3479536aabbe689a77151a9ecd10fd51583 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Mon, 11 Nov 2024 23:57:05 +0100
Subject: [PATCH] [libc++] Make variables in templates inline

---
 .../include/__random/discard_block_engine.h   |  10 +-
 .../__random/linear_congruential_engine.h     |  24 +-
 .../__random/mersenne_twister_engine.h        | 351 +-----------------
 .../include/__random/shuffle_order_engine.h   |   5 +-
 .../__random/subtract_with_carry_engine.h     |  21 +-
 .../include/__type_traits/integral_constant.h |   5 +-
 libcxx/include/any                            |   2 -
 libcxx/include/limits                         |  93 ++---
 libcxx/include/ratio                          |  10 +-
 libcxx/src/chrono.cpp                         |   6 +
 libcxx/src/filesystem/filesystem_clock.cpp    |   3 +
 libcxx/src/filesystem/path.cpp                |   3 +
 libcxxabi/src/cxa_demangle.cpp                |   4 -
 runtimes/cmake/Modules/WarningFlags.cmake     |   1 +
 14 files changed, 64 insertions(+), 474 deletions(-)

diff --git a/libcxx/include/__random/discard_block_engine.h b/libcxx/include/__random/discard_block_engine.h
index f319557a573657..45951245a53401 100644
--- a/libcxx/include/__random/discard_block_engine.h
+++ b/libcxx/include/__random/discard_block_engine.h
@@ -43,8 +43,8 @@ class _LIBCPP_TEMPLATE_VIS discard_block_engine {
   typedef typename _Engine::result_type result_type;
 
   // engine characteristics
-  static _LIBCPP_CONSTEXPR const size_t block_size = __p;
-  static _LIBCPP_CONSTEXPR const size_t used_block = __r;
+  static inline _LIBCPP_CONSTEXPR const size_t block_size = __p;
+  static inline _LIBCPP_CONSTEXPR const size_t used_block = __r;
 
 #ifdef _LIBCPP_CXX03_LANG
   static const result_type _Min = _Engine::_Min;
@@ -110,12 +110,6 @@ class _LIBCPP_TEMPLATE_VIS discard_block_engine {
   operator>>(basic_istream<_CharT, _Traits>& __is, discard_block_engine<_Eng, _Pp, _Rp>& __x);
 };
 
-template <class _Engine, size_t __p, size_t __r>
-_LIBCPP_CONSTEXPR const size_t discard_block_engine<_Engine, __p, __r>::block_size;
-
-template <class _Engine, size_t __p, size_t __r>
-_LIBCPP_CONSTEXPR const size_t discard_block_engine<_Engine, __p, __r>::used_block;
-
 template <class _Engine, size_t __p, size_t __r>
 typename discard_block_engine<_Engine, __p, __r>::result_type discard_block_engine<_Engine, __p, __r>::operator()() {
   if (__n_ >= static_cast<int>(__r)) {
diff --git a/libcxx/include/__random/linear_congruential_engine.h b/libcxx/include/__random/linear_congruential_engine.h
index a0afda4945cdcf..a6e63839d3fc16 100644
--- a/libcxx/include/__random/linear_congruential_engine.h
+++ b/libcxx/include/__random/linear_congruential_engine.h
@@ -251,12 +251,12 @@ class _LIBCPP_TEMPLATE_VIS linear_congruential_engine {
   static_assert(_Min < _Max, "linear_congruential_engine invalid parameters");
 
   // engine characteristics
-  static _LIBCPP_CONSTEXPR const result_type multiplier = __a;
-  static _LIBCPP_CONSTEXPR const result_type increment  = __c;
-  static _LIBCPP_CONSTEXPR const result_type modulus    = __m;
+  static inline _LIBCPP_CONSTEXPR const result_type multiplier = __a;
+  static inline _LIBCPP_CONSTEXPR const result_type increment  = __c;
+  static inline _LIBCPP_CONSTEXPR const result_type modulus    = __m;
   _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
   _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; }
-  static _LIBCPP_CONSTEXPR const result_type default_seed = 1u;
+  static inline _LIBCPP_CONSTEXPR const result_type default_seed = 1u;
 
   // constructors and seeding functions
 #ifndef _LIBCPP_CXX03_LANG
@@ -318,22 +318,6 @@ class _LIBCPP_TEMPLATE_VIS linear_congruential_engine {
   operator>>(basic_istream<_CharT, _Traits>& __is, linear_congruential_engine<_Up, _Ap, _Cp, _Np>& __x);
 };
 
-template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
-_LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type
-    linear_congruential_engine<_UIntType, __a, __c, __m>::multiplier;
-
-template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
-_LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type
-    linear_congruential_engine<_UIntType, __a, __c, __m>::increment;
-
-template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
-_LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type
-    linear_congruential_engine<_UIntType, __a, __c, __m>::modulus;
-
-template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
-_LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type
-    linear_congruential_engine<_UIntType, __a, __c, __m>::default_seed;
-
 template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
 template <class _Sseq>
 void linear_congruential_engine<_UIntType, __a, __c, __m>::__seed(_Sseq& __q, integral_constant<unsigned, 1>) {
diff --git a/libcxx/include/__random/mersenne_twister_engine.h b/libcxx/include/__random/mersenne_twister_engine.h
index 9dd87f9ce71a11..a23feffff0c89c 100644
--- a/libcxx/include/__random/mersenne_twister_engine.h
+++ b/libcxx/include/__random/mersenne_twister_engine.h
@@ -166,22 +166,22 @@ class _LIBCPP_TEMPLATE_VIS mersenne_twister_engine {
   static_assert(__f <= _Max, "mersenne_twister_engine invalid parameters");
 
   // engine characteristics
-  static _LIBCPP_CONSTEXPR const size_t word_size                      = __w;
-  static _LIBCPP_CONSTEXPR const size_t state_size                     = __n;
-  static _LIBCPP_CONSTEXPR const size_t shift_size                     = __m;
-  static _LIBCPP_CONSTEXPR const size_t mask_bits                      = __r;
-  static _LIBCPP_CONSTEXPR const result_type xor_mask                  = __a;
-  static _LIBCPP_CONSTEXPR const size_t tempering_u                    = __u;
-  static _LIBCPP_CONSTEXPR const result_type tempering_d               = __d;
-  static _LIBCPP_CONSTEXPR const size_t tempering_s                    = __s;
-  static _LIBCPP_CONSTEXPR const result_type tempering_b               = __b;
-  static _LIBCPP_CONSTEXPR const size_t tempering_t                    = __t;
-  static _LIBCPP_CONSTEXPR const result_type tempering_c               = __c;
-  static _LIBCPP_CONSTEXPR const size_t tempering_l                    = __l;
-  static _LIBCPP_CONSTEXPR const result_type initialization_multiplier = __f;
+  static inline _LIBCPP_CONSTEXPR const size_t word_size                      = __w;
+  static inline _LIBCPP_CONSTEXPR const size_t state_size                     = __n;
+  static inline _LIBCPP_CONSTEXPR const size_t shift_size                     = __m;
+  static inline _LIBCPP_CONSTEXPR const size_t mask_bits                      = __r;
+  static inline _LIBCPP_CONSTEXPR const result_type xor_mask                  = __a;
+  static inline _LIBCPP_CONSTEXPR const size_t tempering_u                    = __u;
+  static inline _LIBCPP_CONSTEXPR const result_type tempering_d               = __d;
+  static inline _LIBCPP_CONSTEXPR const size_t tempering_s                    = __s;
+  static inline _LIBCPP_CONSTEXPR const result_type tempering_b               = __b;
+  static inline _LIBCPP_CONSTEXPR const size_t tempering_t                    = __t;
+  static inline _LIBCPP_CONSTEXPR const result_type tempering_c               = __c;
+  static inline _LIBCPP_CONSTEXPR const size_t tempering_l                    = __l;
+  static inline _LIBCPP_CONSTEXPR const result_type initialization_multiplier = __f;
   _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
   _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; }
-  static _LIBCPP_CONSTEXPR const result_type default_seed = 5489u;
+  static inline _LIBCPP_CONSTEXPR const result_type default_seed = 5489u;
 
   // constructors and seeding functions
 #ifndef _LIBCPP_CXX03_LANG
@@ -310,329 +310,6 @@ class _LIBCPP_TEMPLATE_VIS mersenne_twister_engine {
   }
 };
 
-template <class _UIntType,
-          size_t __w,
-          size_t __n,
-          size_t __m,
-          size_t __r,
-          _UIntType __a,
-          size_t __u,
-          _UIntType __d,
-          size_t __s,
-          _UIntType __b,
-          size_t __t,
-          _UIntType __c,
-          size_t __l,
-          _UIntType __f>
-_LIBCPP_CONSTEXPR const size_t
-    mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::word_size;
-
-template <class _UIntType,
-          size_t __w,
-          size_t __n,
-          size_t __m,
-          size_t __r,
-          _UIntType __a,
-          size_t __u,
-          _UIntType __d,
-          size_t __s,
-          _UIntType __b,
-          size_t __t,
-          _UIntType __c,
-          size_t __l,
-          _UIntType __f>
-_LIBCPP_CONSTEXPR const size_t
-    mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::state_size;
-
-template <class _UIntType,
-          size_t __w,
-          size_t __n,
-          size_t __m,
-          size_t __r,
-          _UIntType __a,
-          size_t __u,
-          _UIntType __d,
-          size_t __s,
-          _UIntType __b,
-          size_t __t,
-          _UIntType __c,
-          size_t __l,
-          _UIntType __f>
-_LIBCPP_CONSTEXPR const size_t
-    mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::shift_size;
-
-template <class _UIntType,
-          size_t __w,
-          size_t __n,
-          size_t __m,
-          size_t __r,
-          _UIntType __a,
-          size_t __u,
-          _UIntType __d,
-          size_t __s,
-          _UIntType __b,
-          size_t __t,
-          _UIntType __c,
-          size_t __l,
-          _UIntType __f>
-_LIBCPP_CONSTEXPR const size_t
-    mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::mask_bits;
-
-template <class _UIntType,
-          size_t __w,
-          size_t __n,
-          size_t __m,
-          size_t __r,
-          _UIntType __a,
-          size_t __u,
-          _UIntType __d,
-          size_t __s,
-          _UIntType __b,
-          size_t __t,
-          _UIntType __c,
-          size_t __l,
-          _UIntType __f>
-_LIBCPP_CONSTEXPR const typename mersenne_twister_engine<
-    _UIntType,
-    __w,
-    __n,
-    __m,
-    __r,
-    __a,
-    __u,
-    __d,
-    __s,
-    __b,
-    __t,
-    __c,
-    __l,
-    __f>::result_type
-    mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::xor_mask;
-
-template <class _UIntType,
-          size_t __w,
-          size_t __n,
-          size_t __m,
-          size_t __r,
-          _UIntType __a,
-          size_t __u,
-          _UIntType __d,
-          size_t __s,
-          _UIntType __b,
-          size_t __t,
-          _UIntType __c,
-          size_t __l,
-          _UIntType __f>
-_LIBCPP_CONSTEXPR const size_t
-    mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_u;
-
-template <class _UIntType,
-          size_t __w,
-          size_t __n,
-          size_t __m,
-          size_t __r,
-          _UIntType __a,
-          size_t __u,
-          _UIntType __d,
-          size_t __s,
-          _UIntType __b,
-          size_t __t,
-          _UIntType __c,
-          size_t __l,
-          _UIntType __f>
-_LIBCPP_CONSTEXPR const typename mersenne_twister_engine<
-    _UIntType,
-    __w,
-    __n,
-    __m,
-    __r,
-    __a,
-    __u,
-    __d,
-    __s,
-    __b,
-    __t,
-    __c,
-    __l,
-    __f>::result_type
-    mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_d;
-
-template <class _UIntType,
-          size_t __w,
-          size_t __n,
-          size_t __m,
-          size_t __r,
-          _UIntType __a,
-          size_t __u,
-          _UIntType __d,
-          size_t __s,
-          _UIntType __b,
-          size_t __t,
-          _UIntType __c,
-          size_t __l,
-          _UIntType __f>
-_LIBCPP_CONSTEXPR const size_t
-    mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_s;
-
-template <class _UIntType,
-          size_t __w,
-          size_t __n,
-          size_t __m,
-          size_t __r,
-          _UIntType __a,
-          size_t __u,
-          _UIntType __d,
-          size_t __s,
-          _UIntType __b,
-          size_t __t,
-          _UIntType __c,
-          size_t __l,
-          _UIntType __f>
-_LIBCPP_CONSTEXPR const typename mersenne_twister_engine<
-    _UIntType,
-    __w,
-    __n,
-    __m,
-    __r,
-    __a,
-    __u,
-    __d,
-    __s,
-    __b,
-    __t,
-    __c,
-    __l,
-    __f>::result_type
-    mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_b;
-
-template <class _UIntType,
-          size_t __w,
-          size_t __n,
-          size_t __m,
-          size_t __r,
-          _UIntType __a,
-          size_t __u,
-          _UIntType __d,
-          size_t __s,
-          _UIntType __b,
-          size_t __t,
-          _UIntType __c,
-          size_t __l,
-          _UIntType __f>
-_LIBCPP_CONSTEXPR const size_t
-    mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_t;
-
-template <class _UIntType,
-          size_t __w,
-          size_t __n,
-          size_t __m,
-          size_t __r,
-          _UIntType __a,
-          size_t __u,
-          _UIntType __d,
-          size_t __s,
-          _UIntType __b,
-          size_t __t,
-          _UIntType __c,
-          size_t __l,
-          _UIntType __f>
-_LIBCPP_CONSTEXPR const typename mersenne_twister_engine<
-    _UIntType,
-    __w,
-    __n,
-    __m,
-    __r,
-    __a,
-    __u,
-    __d,
-    __s,
-    __b,
-    __t,
-    __c,
-    __l,
-    __f>::result_type
-    mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_c;
-
-template <class _UIntType,
-          size_t __w,
-          size_t __n,
-          size_t __m,
-          size_t __r,
-          _UIntType __a,
-          size_t __u,
-          _UIntType __d,
-          size_t __s,
-          _UIntType __b,
-          size_t __t,
-          _UIntType __c,
-          size_t __l,
-          _UIntType __f>
-_LIBCPP_CONSTEXPR const size_t
-    mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_l;
-
-template <class _UIntType,
-          size_t __w,
-          size_t __n,
-          size_t __m,
-          size_t __r,
-          _UIntType __a,
-          size_t __u,
-          _UIntType __d,
-          size_t __s,
-          _UIntType __b,
-          size_t __t,
-          _UIntType __c,
-          size_t __l,
-          _UIntType __f>
-_LIBCPP_CONSTEXPR const typename mersenne_twister_engine<
-    _UIntType,
-    __w,
-    __n,
-    __m,
-    __r,
-    __a,
-    __u,
-    __d,
-    __s,
-    __b,
-    __t,
-    __c,
-    __l,
-    __f>::result_type
-    mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::
-        initialization_multiplier;
-
-template <class _UIntType,
-          size_t __w,
-          size_t __n,
-          size_t __m,
-          size_t __r,
-          _UIntType __a,
-          size_t __u,
-          _UIntType __d,
-          size_t __s,
-          _UIntType __b,
-          size_t __t,
-          _UIntType __c,
-          size_t __l,
-          _UIntType __f>
-_LIBCPP_CONSTEXPR const typename mersenne_twister_engine<
-    _UIntType,
-    __w,
-    __n,
-    __m,
-    __r,
-    __a,
-    __u,
-    __d,
-    __s,
-    __b,
-    __t,
-    __c,
-    __l,
-    __f>::result_type
-    mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::default_seed;
-
 template <class _UIntType,
           size_t __w,
           size_t __n,
diff --git a/libcxx/include/__random/shuffle_order_engine.h b/libcxx/include/__random/shuffle_order_engine.h
index 53f6c08971105e..11a46689a0fa67 100644
--- a/libcxx/include/__random/shuffle_order_engine.h
+++ b/libcxx/include/__random/shuffle_order_engine.h
@@ -66,7 +66,7 @@ class _LIBCPP_TEMPLATE_VIS shuffle_order_engine {
 
 public:
   // engine characteristics
-  static _LIBCPP_CONSTEXPR const size_t table_size = __k;
+  static inline _LIBCPP_CONSTEXPR const size_t table_size = __k;
 
 #ifdef _LIBCPP_CXX03_LANG
   static const result_type _Min = _Engine::_Min;
@@ -173,9 +173,6 @@ class _LIBCPP_TEMPLATE_VIS shuffle_order_engine {
   }
 };
 
-template <class _Engine, size_t __k>
-_LIBCPP_CONSTEXPR const size_t shuffle_order_engine<_Engine, __k>::table_size;
-
 template <class _Eng, size_t _Kp>
 _LIBCPP_HIDE_FROM_ABI bool
 operator==(const shuffle_order_engine<_Eng, _Kp>& __x, const shuffle_order_engine<_Eng, _Kp>& __y) {
diff --git a/libcxx/include/__random/subtract_with_carry_engine.h b/libcxx/include/__random/subtract_with_carry_engine.h
index e087ab4a3c2c7b..40dfaf4016ada0 100644
--- a/libcxx/include/__random/subtract_with_carry_engine.h
+++ b/libcxx/include/__random/subtract_with_carry_engine.h
@@ -72,12 +72,12 @@ class _LIBCPP_TEMPLATE_VIS subtract_with_carry_engine {
   static_assert(_Min < _Max, "subtract_with_carry_engine invalid parameters");
 
   // engine characteristics
-  static _LIBCPP_CONSTEXPR const size_t word_size = __w;
-  static _LIBCPP_CONSTEXPR const size_t short_lag = __s;
-  static _LIBCPP_CONSTEXPR const size_t long_lag  = __r;
+  static inline _LIBCPP_CONSTEXPR const size_t word_size = __w;
+  static inline _LIBCPP_CONSTEXPR const size_t short_lag = __s;
+  static inline _LIBCPP_CONSTEXPR const size_t long_lag  = __r;
   _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
   _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; }
-  static _LIBCPP_CONSTEXPR const result_type default_seed = 19780503u;
+  static inline _LIBCPP_CONSTEXPR const result_type default_seed = 19780503u;
 
   // constructors and seeding functions
 #ifndef _LIBCPP_CXX03_LANG
@@ -130,19 +130,6 @@ class _LIBCPP_TEMPLATE_VIS subtract_with_carry_engine {
   _LIBCPP_HIDE_FROM_ABI void __seed(_Sseq& __q, integral_constant<unsigned, 2>);
 };
 
-template <class _UIntType, size_t __w, size_t __s, size_t __r>
-_LIBCPP_CONSTEXPR const size_t subtract_with_carry_engine<_UIntType, __w, __s, __r>::word_size;
-
-template <class _UIntType, size_t __w, size_t __s, size_t __r>
-_LIBCPP_CONSTEXPR const size_t subtract_with_carry_engine<_UIntType, __w, __s, __r>::short_lag;
-
-template <class _UIntType, size_t __w, size_t __s, size_t __r>
-_LIBCPP_CONSTEXPR const size_t subtract_with_carry_engine<_UIntType, __w, __s, __r>::long_lag;
-
-template <class _UIntType, size_t __w, size_t __s, size_t __r>
-_LIBCPP_CONSTEXPR const typename subtract_with_carry_engine<_UIntType, __w, __s, __r>::result_type
-    subtract_with_carry_engine<_UIntType, __w, __s, __r>::default_seed;
-
 template <class _UIntType, size_t __w, size_t __s, size_t __r>
 void subtract_with_carry_engine<_UIntType, __w, __s, __r>::seed(result_type __sd, integral_constant<unsigned, 1>) {
   linear_congruential_engine<result_type, 40014u, 0u, 2147483563u> __e(__sd == 0u ? default_seed : __sd);
diff --git a/libcxx/include/__type_traits/integral_constant.h b/libcxx/include/__type_traits/integral_constant.h
index 23e87e27feff55..b8c75c546aa942 100644
--- a/libcxx/include/__type_traits/integral_constant.h
+++ b/libcxx/include/__type_traits/integral_constant.h
@@ -19,7 +19,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _Tp, _Tp __v>
 struct _LIBCPP_TEMPLATE_VIS integral_constant {
-  static _LIBCPP_CONSTEXPR const _Tp value = __v;
+  static inline _LIBCPP_CONSTEXPR const _Tp value = __v;
   typedef _Tp value_type;
   typedef integral_constant type;
   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT { return value; }
@@ -28,9 +28,6 @@ struct _LIBCPP_TEMPLATE_VIS integral_constant {
 #endif
 };
 
-template <class _Tp, _Tp __v>
-_LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
-
 typedef integral_constant<bool, true> true_type;
 typedef integral_constant<bool, false> false_type;
 
diff --git a/libcxx/include/any b/libcxx/include/any
index 719dc2cf999e50..cae56fa376e057 100644
--- a/libcxx/include/any
+++ b/libcxx/include/any
@@ -166,8 +166,6 @@ template <class _Tp>
 struct _LIBCPP_TEMPLATE_VIS __unique_typeinfo {
   static constexpr int __id = 0;
 };
-template <class _Tp>
-constexpr int __unique_typeinfo<_Tp>::__id;
 
 template <class _Tp>
 inline _LIBCPP_HIDE_FROM_ABI constexpr const void* __get_fallback_typeid() {
diff --git a/libcxx/include/limits b/libcxx/include/limits
index b85c66257d27b7..da0a92d7daff4a 100644
--- a/libcxx/include/limits
+++ b/libcxx/include/limits
@@ -464,18 +464,18 @@ class _LIBCPP_TEMPLATE_VIS numeric_limits : private __libcpp_numeric_limits<_Tp>
   typedef typename __base::type type;
 
 public:
-  static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
+  static inline _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
   [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __base::min(); }
   [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __base::max(); }
   [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return __base::lowest(); }
 
-  static _LIBCPP_CONSTEXPR const int digits       = __base::digits;
-  static _LIBCPP_CONSTEXPR const int digits10     = __base::digits10;
-  static _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10;
-  static _LIBCPP_CONSTEXPR const bool is_signed   = __base::is_signed;
-  static _LIBCPP_CONSTEXPR const bool is_integer  = __base::is_integer;
-  static _LIBCPP_CONSTEXPR const bool is_exact    = __base::is_exact;
-  static _LIBCPP_CONSTEXPR const int radix        = __base::radix;
+  static inline _LIBCPP_CONSTEXPR const int digits       = __base::digits;
+  static inline _LIBCPP_CONSTEXPR const int digits10     = __base::digits10;
+  static inline _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10;
+  static inline _LIBCPP_CONSTEXPR const bool is_signed   = __base::is_signed;
+  static inline _LIBCPP_CONSTEXPR const bool is_integer  = __base::is_integer;
+  static inline _LIBCPP_CONSTEXPR const bool is_exact    = __base::is_exact;
+  static inline _LIBCPP_CONSTEXPR const int radix        = __base::radix;
   [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {
     return __base::epsilon();
   }
@@ -483,17 +483,17 @@ public:
     return __base::round_error();
   }
 
-  static _LIBCPP_CONSTEXPR const int min_exponent   = __base::min_exponent;
-  static _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10;
-  static _LIBCPP_CONSTEXPR const int max_exponent   = __base::max_exponent;
-  static _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10;
+  static inline _LIBCPP_CONSTEXPR const int min_exponent   = __base::min_exponent;
+  static inline _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10;
+  static inline _LIBCPP_CONSTEXPR const int max_exponent   = __base::max_exponent;
+  static inline _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10;
 
-  static _LIBCPP_CONSTEXPR const bool has_infinity      = __base::has_infinity;
-  static _LIBCPP_CONSTEXPR const bool has_quiet_NaN     = __base::has_quiet_NaN;
-  static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN;
+  static inline _LIBCPP_CONSTEXPR const bool has_infinity      = __base::has_infinity;
+  static inline _LIBCPP_CONSTEXPR const bool has_quiet_NaN     = __base::has_quiet_NaN;
+  static inline _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN;
   _LIBCPP_SUPPRESS_DEPRECATED_PUSH
-  static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm;
-  static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss          = __base::has_denorm_loss;
+  static inline _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm;
+  static inline _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss;
   _LIBCPP_SUPPRESS_DEPRECATED_POP
   [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {
     return __base::infinity();
@@ -508,62 +508,15 @@ public:
     return __base::denorm_min();
   }
 
-  static _LIBCPP_CONSTEXPR const bool is_iec559  = __base::is_iec559;
-  static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded;
-  static _LIBCPP_CONSTEXPR const bool is_modulo  = __base::is_modulo;
+  static inline _LIBCPP_CONSTEXPR const bool is_iec559  = __base::is_iec559;
+  static inline _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded;
+  static inline _LIBCPP_CONSTEXPR const bool is_modulo  = __base::is_modulo;
 
-  static _LIBCPP_CONSTEXPR const bool traps                    = __base::traps;
-  static _LIBCPP_CONSTEXPR const bool tinyness_before          = __base::tinyness_before;
-  static _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style;
+  static inline _LIBCPP_CONSTEXPR const bool traps                    = __base::traps;
+  static inline _LIBCPP_CONSTEXPR const bool tinyness_before          = __base::tinyness_before;
+  static inline _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style;
 };
 
-template <class _Tp>
-_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_specialized;
-template <class _Tp>
-_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::digits;
-template <class _Tp>
-_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::digits10;
-template <class _Tp>
-_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_digits10;
-template <class _Tp>
-_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_signed;
-template <class _Tp>
-_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_integer;
-template <class _Tp>
-_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_exact;
-template <class _Tp>
-_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::radix;
-template <class _Tp>
-_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::min_exponent;
-template <class _Tp>
-_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::min_exponent10;
-template <class _Tp>
-_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_exponent;
-template <class _Tp>
-_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_exponent10;
-template <class _Tp>
-_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_infinity;
-template <class _Tp>
-_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_quiet_NaN;
-template <class _Tp>
-_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_signaling_NaN;
-template <class _Tp>
-_LIBCPP_CONSTEXPR const float_denorm_style numeric_limits<_Tp>::has_denorm;
-template <class _Tp>
-_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_denorm_loss;
-template <class _Tp>
-_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_iec559;
-template <class _Tp>
-_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_bounded;
-template <class _Tp>
-_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_modulo;
-template <class _Tp>
-_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::traps;
-template <class _Tp>
-_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::tinyness_before;
-template <class _Tp>
-_LIBCPP_CONSTEXPR const float_round_style numeric_limits<_Tp>::round_style;
-
 template <class _Tp>
 class _LIBCPP_TEMPLATE_VIS numeric_limits<const _Tp> : public numeric_limits<_Tp> {};
 
diff --git a/libcxx/include/ratio b/libcxx/include/ratio
index b989c272aaee6a..54a90b157290df 100644
--- a/libcxx/include/ratio
+++ b/libcxx/include/ratio
@@ -248,18 +248,12 @@ class _LIBCPP_TEMPLATE_VIS ratio {
   static _LIBCPP_CONSTEXPR const intmax_t __gcd = __static_gcd<__na, __da>::value;
 
 public:
-  static _LIBCPP_CONSTEXPR const intmax_t num = __s * __na / __gcd;
-  static _LIBCPP_CONSTEXPR const intmax_t den = __da / __gcd;
+  static inline _LIBCPP_CONSTEXPR const intmax_t num = __s * __na / __gcd;
+  static inline _LIBCPP_CONSTEXPR const intmax_t den = __da / __gcd;
 
   typedef ratio<num, den> type;
 };
 
-template <intmax_t _Num, intmax_t _Den>
-_LIBCPP_CONSTEXPR const intmax_t ratio<_Num, _Den>::num;
-
-template <intmax_t _Num, intmax_t _Den>
-_LIBCPP_CONSTEXPR const intmax_t ratio<_Num, _Den>::den;
-
 template <class _Tp>
 struct __is_ratio : false_type {};
 template <intmax_t _Num, intmax_t _Den>
diff --git a/libcxx/src/chrono.cpp b/libcxx/src/chrono.cpp
index f17ea5542bd99d..10fe9968ed4a1c 100644
--- a/libcxx/src/chrono.cpp
+++ b/libcxx/src/chrono.cpp
@@ -134,7 +134,10 @@ static system_clock::time_point __libcpp_system_clock_now() {
 
 #endif
 
+_LIBCPP_DIAGNOSTIC_PUSH
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-redundant-constexpr-static-def")
 const bool system_clock::is_steady;
+_LIBCPP_DIAGNOSTIC_POP
 
 system_clock::time_point system_clock::now() noexcept { return __libcpp_system_clock_now(); }
 
@@ -226,7 +229,10 @@ static steady_clock::time_point __libcpp_steady_clock_now() {
 #    error "Monotonic clock not implemented on this platform"
 #  endif
 
+_LIBCPP_DIAGNOSTIC_PUSH
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-redundant-constexpr-static-def")
 const bool steady_clock::is_steady;
+_LIBCPP_DIAGNOSTIC_POP
 
 steady_clock::time_point steady_clock::now() noexcept { return __libcpp_steady_clock_now(); }
 
diff --git a/libcxx/src/filesystem/filesystem_clock.cpp b/libcxx/src/filesystem/filesystem_clock.cpp
index 473a54a00f013a..5bcfb1909795ec 100644
--- a/libcxx/src/filesystem/filesystem_clock.cpp
+++ b/libcxx/src/filesystem/filesystem_clock.cpp
@@ -36,7 +36,10 @@
 
 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
 
+_LIBCPP_DIAGNOSTIC_PUSH
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-redundant-constexpr-static-def")
 const bool _FilesystemClock::is_steady;
+_LIBCPP_DIAGNOSTIC_POP
 
 _FilesystemClock::time_point _FilesystemClock::now() noexcept {
   typedef chrono::duration<rep> __secs;
diff --git a/libcxx/src/filesystem/path.cpp b/libcxx/src/filesystem/path.cpp
index 58742442bae6b7..cb88075cdf2144 100644
--- a/libcxx/src/filesystem/path.cpp
+++ b/libcxx/src/filesystem/path.cpp
@@ -24,7 +24,10 @@ using parser::string_view_t;
 //                            path definitions
 ///////////////////////////////////////////////////////////////////////////////
 
+_LIBCPP_DIAGNOSTIC_PUSH
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-redundant-constexpr-static-def")
 constexpr path::value_type path::preferred_separator;
+_LIBCPP_DIAGNOSTIC_POP
 
 path& path::replace_extension(path const& replacement) {
   path p = extension();
diff --git a/libcxxabi/src/cxa_demangle.cpp b/libcxxabi/src/cxa_demangle.cpp
index bece33a007fcd3..4756d8343630b9 100644
--- a/libcxxabi/src/cxa_demangle.cpp
+++ b/libcxxabi/src/cxa_demangle.cpp
@@ -28,10 +28,6 @@
 
 using namespace itanium_demangle;
 
-constexpr const char *itanium_demangle::FloatData<float>::spec;
-constexpr const char *itanium_demangle::FloatData<double>::spec;
-constexpr const char *itanium_demangle::FloatData<long double>::spec;
-
 // <discriminator> := _ <non-negative number>      # when number < 10
 //                 := __ <non-negative number> _   # when number >= 10
 //  extension      := decimal-digit+               # at the end of string
diff --git a/runtimes/cmake/Modules/WarningFlags.cmake b/runtimes/cmake/Modules/WarningFlags.cmake
index 90edf3a9574380..d17bf92389d0b0 100644
--- a/runtimes/cmake/Modules/WarningFlags.cmake
+++ b/runtimes/cmake/Modules/WarningFlags.cmake
@@ -24,6 +24,7 @@ function(cxx_add_warning_flags target enable_werror enable_pedantic)
       -Wunused-template
       -Wformat-nonliteral
       -Wzero-length-array
+      -Wdeprecated-redundant-constexpr-static-def
       )
 
   if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")



More information about the libcxx-commits mailing list