[libcxx-commits] [libcxx] 7ced7e8 - [libc++][NFC] Replace typedef with using declarations in <__atomic/*>

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Wed Feb 22 05:49:45 PST 2023


Author: Nikolas Klauser
Date: 2023-02-22T14:49:39+01:00
New Revision: 7ced7e84c094bf96bb3bf76209f580af36f52ecd

URL: https://github.com/llvm/llvm-project/commit/7ced7e84c094bf96bb3bf76209f580af36f52ecd
DIFF: https://github.com/llvm/llvm-project/commit/7ced7e84c094bf96bb3bf76209f580af36f52ecd.diff

LOG: [libc++][NFC] Replace typedef with using declarations in <__atomic/*>

Reviewed By: Mordante, #libc

Spies: arichardson, libcxx-commits

Differential Revision: https://reviews.llvm.org/D144259

Added: 
    

Modified: 
    libcxx/include/__atomic/aliases.h
    libcxx/include/__atomic/atomic.h
    libcxx/include/__atomic/atomic_base.h
    libcxx/include/__atomic/atomic_flag.h
    libcxx/include/__atomic/memory_order.h
    libcxx/utils/data/ignore_format.txt

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__atomic/aliases.h b/libcxx/include/__atomic/aliases.h
index b64282813446e..806589b630ee2 100644
--- a/libcxx/include/__atomic/aliases.h
+++ b/libcxx/include/__atomic/aliases.h
@@ -25,89 +25,90 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-typedef atomic<bool>               atomic_bool;
-typedef atomic<char>               atomic_char;
-typedef atomic<signed char>        atomic_schar;
-typedef atomic<unsigned char>      atomic_uchar;
-typedef atomic<short>              atomic_short;
-typedef atomic<unsigned short>     atomic_ushort;
-typedef atomic<int>                atomic_int;
-typedef atomic<unsigned int>       atomic_uint;
-typedef atomic<long>               atomic_long;
-typedef atomic<unsigned long>      atomic_ulong;
-typedef atomic<long long>          atomic_llong;
-typedef atomic<unsigned long long> atomic_ullong;
+using atomic_bool   = atomic<bool>;
+using atomic_char   = atomic<char>;
+using atomic_schar  = atomic<signed char>;
+using atomic_uchar  = atomic<unsigned char>;
+using atomic_short  = atomic<short>;
+using atomic_ushort = atomic<unsigned short>;
+using atomic_int    = atomic<int>;
+using atomic_uint   = atomic<unsigned int>;
+using atomic_long   = atomic<long>;
+using atomic_ulong  = atomic<unsigned long>;
+using atomic_llong  = atomic<long long>;
+using atomic_ullong = atomic<unsigned long long>;
 #ifndef _LIBCPP_HAS_NO_CHAR8_T
-typedef atomic<char8_t>            atomic_char8_t;
+using atomic_char8_t = atomic<char8_t>;
 #endif
-typedef atomic<char16_t>           atomic_char16_t;
-typedef atomic<char32_t>           atomic_char32_t;
+using atomic_char16_t = atomic<char16_t>;
+using atomic_char32_t = atomic<char32_t>;
 #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-typedef atomic<wchar_t>            atomic_wchar_t;
+using atomic_wchar_t = atomic<wchar_t>;
 #endif
 
-typedef atomic<int_least8_t>   atomic_int_least8_t;
-typedef atomic<uint_least8_t>  atomic_uint_least8_t;
-typedef atomic<int_least16_t>  atomic_int_least16_t;
-typedef atomic<uint_least16_t> atomic_uint_least16_t;
-typedef atomic<int_least32_t>  atomic_int_least32_t;
-typedef atomic<uint_least32_t> atomic_uint_least32_t;
-typedef atomic<int_least64_t>  atomic_int_least64_t;
-typedef atomic<uint_least64_t> atomic_uint_least64_t;
+using atomic_int_least8_t   = atomic<int_least8_t>;
+using atomic_uint_least8_t  = atomic<uint_least8_t>;
+using atomic_int_least16_t  = atomic<int_least16_t>;
+using atomic_uint_least16_t = atomic<uint_least16_t>;
+using atomic_int_least32_t  = atomic<int_least32_t>;
+using atomic_uint_least32_t = atomic<uint_least32_t>;
+using atomic_int_least64_t  = atomic<int_least64_t>;
+using atomic_uint_least64_t = atomic<uint_least64_t>;
 
-typedef atomic<int_fast8_t>   atomic_int_fast8_t;
-typedef atomic<uint_fast8_t>  atomic_uint_fast8_t;
-typedef atomic<int_fast16_t>  atomic_int_fast16_t;
-typedef atomic<uint_fast16_t> atomic_uint_fast16_t;
-typedef atomic<int_fast32_t>  atomic_int_fast32_t;
-typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
-typedef atomic<int_fast64_t>  atomic_int_fast64_t;
-typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
+using atomic_int_fast8_t   = atomic<int_fast8_t>;
+using atomic_uint_fast8_t  = atomic<uint_fast8_t>;
+using atomic_int_fast16_t  = atomic<int_fast16_t>;
+using atomic_uint_fast16_t = atomic<uint_fast16_t>;
+using atomic_int_fast32_t  = atomic<int_fast32_t>;
+using atomic_uint_fast32_t = atomic<uint_fast32_t>;
+using atomic_int_fast64_t  = atomic<int_fast64_t>;
+using atomic_uint_fast64_t = atomic<uint_fast64_t>;
 
-typedef atomic< int8_t>  atomic_int8_t;
-typedef atomic<uint8_t>  atomic_uint8_t;
-typedef atomic< int16_t> atomic_int16_t;
-typedef atomic<uint16_t> atomic_uint16_t;
-typedef atomic< int32_t> atomic_int32_t;
-typedef atomic<uint32_t> atomic_uint32_t;
-typedef atomic< int64_t> atomic_int64_t;
-typedef atomic<uint64_t> atomic_uint64_t;
+using atomic_int8_t   = atomic< int8_t>;
+using atomic_uint8_t  = atomic<uint8_t>;
+using atomic_int16_t  = atomic< int16_t>;
+using atomic_uint16_t = atomic<uint16_t>;
+using atomic_int32_t  = atomic< int32_t>;
+using atomic_uint32_t = atomic<uint32_t>;
+using atomic_int64_t  = atomic< int64_t>;
+using atomic_uint64_t = atomic<uint64_t>;
 
-typedef atomic<intptr_t>  atomic_intptr_t;
-typedef atomic<uintptr_t> atomic_uintptr_t;
-typedef atomic<size_t>    atomic_size_t;
-typedef atomic<ptr
diff _t> atomic_ptr
diff _t;
-typedef atomic<intmax_t>  atomic_intmax_t;
-typedef atomic<uintmax_t> atomic_uintmax_t;
+using atomic_intptr_t  = atomic<intptr_t>;
+using atomic_uintptr_t = atomic<uintptr_t>;
+using atomic_size_t    = atomic<size_t>;
+using atomic_ptr
diff _t = atomic<ptr
diff _t>;
+using atomic_intmax_t  = atomic<intmax_t>;
+using atomic_uintmax_t = atomic<uintmax_t>;
 
 // atomic_*_lock_free : prefer the contention type most highly, then the largest lock-free type
 
 #ifdef __cpp_lib_atomic_is_always_lock_free
-# define _LIBCPP_CONTENTION_LOCK_FREE ::std::__libcpp_is_always_lock_free<__cxx_contention_t>::__value
+#  define _LIBCPP_CONTENTION_LOCK_FREE ::std::__libcpp_is_always_lock_free<__cxx_contention_t>::__value
 #else
-# define _LIBCPP_CONTENTION_LOCK_FREE false
+#  define _LIBCPP_CONTENTION_LOCK_FREE false
 #endif
 
 #if ATOMIC_LLONG_LOCK_FREE == 2
-typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, long long>          __libcpp_signed_lock_free;
-typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned long long> __libcpp_unsigned_lock_free;
+using __libcpp_signed_lock_free = __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, long long>;
+using __libcpp_unsigned_lock_free =
+    __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned long long>;
 #elif ATOMIC_INT_LOCK_FREE == 2
-typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, int>                __libcpp_signed_lock_free;
-typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned int>       __libcpp_unsigned_lock_free;
+using __libcpp_signed_lock_free   = __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, int>;
+using __libcpp_unsigned_lock_free = __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned int>;
 #elif ATOMIC_SHORT_LOCK_FREE == 2
-typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, short>              __libcpp_signed_lock_free;
-typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned short>     __libcpp_unsigned_lock_free;
+using __libcpp_signed_lock_free   = __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, short>;
+using __libcpp_unsigned_lock_free = __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned short>;
 #elif ATOMIC_CHAR_LOCK_FREE == 2
-typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, char>               __libcpp_signed_lock_free;
-typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned char>      __libcpp_unsigned_lock_free;
+using __libcpp_signed_lock_free   = __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, char>;
+using __libcpp_unsigned_lock_free = __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned char>;
 #else
-    // No signed/unsigned lock-free types
-#define _LIBCPP_NO_LOCK_FREE_TYPES
+// No signed/unsigned lock-free types
+#  define _LIBCPP_NO_LOCK_FREE_TYPES
 #endif
 
 #if !defined(_LIBCPP_NO_LOCK_FREE_TYPES)
-typedef atomic<__libcpp_signed_lock_free> atomic_signed_lock_free;
-typedef atomic<__libcpp_unsigned_lock_free> atomic_unsigned_lock_free;
+using atomic_signed_lock_free   = atomic<__libcpp_signed_lock_free>;
+using atomic_unsigned_lock_free = atomic<__libcpp_unsigned_lock_free>;
 #endif
 
 _LIBCPP_END_NAMESPACE_STD

diff  --git a/libcxx/include/__atomic/atomic.h b/libcxx/include/__atomic/atomic.h
index d34baec6774bf..57671c12c4e60 100644
--- a/libcxx/include/__atomic/atomic.h
+++ b/libcxx/include/__atomic/atomic.h
@@ -29,9 +29,9 @@ template <class _Tp>
 struct atomic
     : public __atomic_base<_Tp>
 {
-    typedef __atomic_base<_Tp> __base;
-    typedef _Tp value_type;
-    typedef value_type 
diff erence_type;
+  using __base          = __atomic_base<_Tp>;
+  using value_type      = _Tp;
+  using 
diff erence_type = value_type;
 
 #if _LIBCPP_STD_VER >= 20
     _LIBCPP_HIDE_FROM_ABI
@@ -61,9 +61,9 @@ template <class _Tp>
 struct atomic<_Tp*>
     : public __atomic_base<_Tp*>
 {
-    typedef __atomic_base<_Tp*> __base;
-    typedef _Tp* value_type;
-    typedef ptr
diff _t 
diff erence_type;
+    using __base          = __atomic_base<_Tp*>;
+    using value_type      = _Tp*;
+    using 
diff erence_type = ptr
diff _t;
 
     _LIBCPP_HIDE_FROM_ABI
     atomic() _NOEXCEPT = default;

diff  --git a/libcxx/include/__atomic/atomic_base.h b/libcxx/include/__atomic/atomic_base.h
index 83040d3ac79c9..413f096a6702f 100644
--- a/libcxx/include/__atomic/atomic_base.h
+++ b/libcxx/include/__atomic/atomic_base.h
@@ -143,7 +143,7 @@ template <class _Tp>
 struct __atomic_base<_Tp, true>
     : public __atomic_base<_Tp, false>
 {
-    typedef __atomic_base<_Tp, false> __base;
+    using __base = __atomic_base<_Tp, false>;
 
     _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
     __atomic_base() _NOEXCEPT = default;

diff  --git a/libcxx/include/__atomic/atomic_flag.h b/libcxx/include/__atomic/atomic_flag.h
index 4731b4228a8b1..46a6ad790b874 100644
--- a/libcxx/include/__atomic/atomic_flag.h
+++ b/libcxx/include/__atomic/atomic_flag.h
@@ -24,7 +24,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-typedef struct atomic_flag
+struct atomic_flag
 {
     __cxx_atomic_impl<_LIBCPP_ATOMIC_FLAG_TYPE> __a_;
 
@@ -82,8 +82,7 @@ typedef struct atomic_flag
     atomic_flag& operator=(const atomic_flag&) = delete;
     atomic_flag& operator=(const atomic_flag&) volatile = delete;
 
-} atomic_flag;
-
+};
 
 inline _LIBCPP_HIDE_FROM_ABI
 bool

diff  --git a/libcxx/include/__atomic/memory_order.h b/libcxx/include/__atomic/memory_order.h
index d90e231e79ce7..3671dc3cf9be0 100644
--- a/libcxx/include/__atomic/memory_order.h
+++ b/libcxx/include/__atomic/memory_order.h
@@ -31,7 +31,7 @@ enum __legacy_memory_order {
     __mo_seq_cst
 };
 
-typedef underlying_type<__legacy_memory_order>::type __memory_order_underlying_t;
+using __memory_order_underlying_t = underlying_type<__legacy_memory_order>::type;
 
 #if _LIBCPP_STD_VER >= 20
 
@@ -56,14 +56,14 @@ inline constexpr auto memory_order_seq_cst = memory_order::seq_cst;
 
 #else
 
-typedef enum memory_order {
+enum memory_order {
   memory_order_relaxed = __mo_relaxed,
   memory_order_consume = __mo_consume,
   memory_order_acquire = __mo_acquire,
   memory_order_release = __mo_release,
   memory_order_acq_rel = __mo_acq_rel,
   memory_order_seq_cst = __mo_seq_cst,
-} memory_order;
+};
 
 #endif // _LIBCPP_STD_VER >= 20
 

diff  --git a/libcxx/utils/data/ignore_format.txt b/libcxx/utils/data/ignore_format.txt
index 74bcdb3e14ffe..695939fc494ee 100644
--- a/libcxx/utils/data/ignore_format.txt
+++ b/libcxx/utils/data/ignore_format.txt
@@ -213,7 +213,6 @@ libcxx/include/__algorithm/upper_bound.h
 libcxx/include/any
 libcxx/include/array
 libcxx/include/atomic
-libcxx/include/__atomic/aliases.h
 libcxx/include/__atomic/atomic_base.h
 libcxx/include/__atomic/atomic_flag.h
 libcxx/include/__atomic/atomic.h


        


More information about the libcxx-commits mailing list