[libcxx-commits] [PATCH] D119264: [libc++] Rename *SAFE_STATIC to *CONSTINIT, and normalize its uses.

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Feb 8 10:49:02 PST 2022


Quuxplusone added inline comments.


================
Comment at: libcxx/src/experimental/memory_resource_init_helper.h:2
 #pragma GCC system_header
-_LIBCPP_SAFE_STATIC ResourceInitHelper res_init _LIBCPP_INIT_PRIORITY_MAX;
+_LIBCPP_CONSTINIT ResourceInitHelper res_init _LIBCPP_INIT_PRIORITY_MAX;
----------------
Here I wonder if adding `static` would be helpful. (This is included from within an anonymous namespace already, so it'd be redundant to the computer, but possibly helpful to the human reader.)


================
Comment at: libcxx/src/memory.cpp:135
 
-_LIBCPP_SAFE_STATIC static const std::size_t __sp_mut_count = 16;
-_LIBCPP_SAFE_STATIC static __libcpp_mutex_t mut_back[__sp_mut_count] =
+static constexpr std::size_t __sp_mut_count = 16;
+static _LIBCPP_CONSTINIT __libcpp_mutex_t mut_back[__sp_mut_count] =
----------------
Here I'm changing `constinit const` to `constexpr`. I suspect the original code was just `static const` (i.e., C++03-friendly `constexpr`), and then `_LIBCPP_SAFE_STATIC` got added basically in a cut-and-paste error.


================
Comment at: libcxx/src/memory.cpp:174
 {
-    static __sp_mut muts[__sp_mut_count]
-    {
+    static _LIBCPP_CONSTINIT __sp_mut muts[__sp_mut_count] = {
         &mut_back[ 0], &mut_back[ 1], &mut_back[ 2], &mut_back[ 3],
----------------
Here I'm //adding// `constinit` to this array that seems like it was always intended to be `constinit`. (The compiler optimizer was probably already doing the obvious thing anyway.)


================
Comment at: libcxxabi/src/cxa_default_handlers.cpp:108
 _LIBCXXABI_DATA_VIS
-_LIBCPP_SAFE_STATIC std::new_handler __cxa_new_handler = 0;
+_LIBCPP_CONSTINIT std::new_handler __cxa_new_handler = 0;
 
----------------
Here's a place it would be nice to use `nullptr`, if it's allowed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119264/new/

https://reviews.llvm.org/D119264



More information about the libcxx-commits mailing list