[libcxx-commits] [libcxx] 4e730ae - [libcxx] Add deprecation notices to macros deprecated in P0883R2
Raul Tambre via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Dec 20 10:30:25 PST 2021
Author: Raul Tambre
Date: 2021-12-20T20:30:00+02:00
New Revision: 4e730aeb731cb9b7116ed51bbef662d363f72b66
URL: https://github.com/llvm/llvm-project/commit/4e730aeb731cb9b7116ed51bbef662d363f72b66
DIFF: https://github.com/llvm/llvm-project/commit/4e730aeb731cb9b7116ed51bbef662d363f72b66.diff
LOG: [libcxx] Add deprecation notices to macros deprecated in P0883R2
When P0883R2 was initially implemented in D103769 #pragma clang deprecated didn't exist yet.
We also forgot to cleanup usages in libc++ itself.
This takes care of both.
Differential Revision: https://reviews.llvm.org/D115995
Added:
Modified:
libcxx/docs/Status/Cxx20Papers.csv
libcxx/include/atomic
libcxx/src/barrier.cpp
libcxx/src/experimental/memory_resource.cpp
libcxx/src/ios.cpp
libcxx/test/libcxx/atomics/atomics.flag/init_bool.pass.cpp
libcxx/test/std/atomics/atomics.flag/init.pass.cpp
libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_var_init.pass.cpp
libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/ctor.pass.cpp
libcxx/test/std/thread/futures/futures.async/async.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/docs/Status/Cxx20Papers.csv b/libcxx/docs/Status/Cxx20Papers.csv
index c456212b859dc..3caca78f36f30 100644
--- a/libcxx/docs/Status/Cxx20Papers.csv
+++ b/libcxx/docs/Status/Cxx20Papers.csv
@@ -133,7 +133,7 @@
"`P1661R1 <https://wg21.link/P1661R1>`__","LWG","Remove dedicated precalculated hash lookup interface","Cologne","|Nothing To Do|",""
"`P1754R1 <https://wg21.link/P1754R1>`__","LWG","Rename concepts to standard_case for C++20, while we still can","Cologne","|In Progress|",""
"","","","","",""
-"`P0883R2 <https://wg21.link/P0883R2>`__","LWG","Fixing Atomic Initialization","Belfast","|Complete| [#note-P0883]_","13.0"
+"`P0883R2 <https://wg21.link/P0883R2>`__","LWG","Fixing Atomic Initialization","Belfast","|Complete| [#note-P0883]_","14.0"
"`P1391R4 <https://wg21.link/P1391R4>`__","LWG","Range constructor for std::string_view","Belfast","|Complete|","14.0"
"`P1394R4 <https://wg21.link/P1394R4>`__","LWG","Range constructor for std::span","Belfast","|Complete|","14.0"
"`P1456R1 <https://wg21.link/P1456R1>`__","LWG","Move-only views","Belfast","* *",""
diff --git a/libcxx/include/atomic b/libcxx/include/atomic
index 4b4c347a57046..4b60d4d6802b4 100644
--- a/libcxx/include/atomic
+++ b/libcxx/include/atomic
@@ -2699,6 +2699,13 @@ typedef atomic<__libcpp_unsigned_lock_free> atomic_unsigned_lock_free;
#define ATOMIC_FLAG_INIT {false}
#define ATOMIC_VAR_INIT(__v) {__v}
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
+# if defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 1400
+# pragma clang deprecated(ATOMIC_FLAG_INIT)
+# pragma clang deprecated(ATOMIC_VAR_INIT)
+# endif
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
+
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_ATOMIC
diff --git a/libcxx/src/barrier.cpp b/libcxx/src/barrier.cpp
index bd566646b84ca..54890b2d797ef 100644
--- a/libcxx/src/barrier.cpp
+++ b/libcxx/src/barrier.cpp
@@ -22,7 +22,7 @@ class __barrier_algorithm_base {
struct alignas(64) /* naturally-align the heap state */ __state_t
{
struct {
- __atomic_base<__barrier_phase_t> __phase = ATOMIC_VAR_INIT(0);
+ __atomic_base<__barrier_phase_t> __phase{0};
} __tickets[64];
};
diff --git a/libcxx/src/experimental/memory_resource.cpp b/libcxx/src/experimental/memory_resource.cpp
index 29db8b3dee6de..018d0159281a6 100644
--- a/libcxx/src/experimental/memory_resource.cpp
+++ b/libcxx/src/experimental/memory_resource.cpp
@@ -97,8 +97,7 @@ static memory_resource *
__default_memory_resource(bool set = false, memory_resource * new_res = nullptr) noexcept
{
#ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER
- _LIBCPP_SAFE_STATIC static atomic<memory_resource*> __res =
- ATOMIC_VAR_INIT(&res_init.resources.new_delete_res);
+ _LIBCPP_SAFE_STATIC static atomic<memory_resource*> __res{&res_init.resources.new_delete_res};
if (set) {
new_res = new_res ? new_res : new_delete_resource();
// TODO: Can a weaker ordering be used?
diff --git a/libcxx/src/ios.cpp b/libcxx/src/ios.cpp
index a9bd1dc323979..56fbcca417aa7 100644
--- a/libcxx/src/ios.cpp
+++ b/libcxx/src/ios.cpp
@@ -137,7 +137,7 @@ ios_base::getloc() const
// xalloc
#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)
-atomic<int> ios_base::__xindex_ = ATOMIC_VAR_INIT(0);
+atomic<int> ios_base::__xindex_{0};
#else
int ios_base::__xindex_ = 0;
#endif
diff --git a/libcxx/test/libcxx/atomics/atomics.flag/init_bool.pass.cpp b/libcxx/test/libcxx/atomics/atomics.flag/init_bool.pass.cpp
index 438f2f8c16940..7678775527419 100644
--- a/libcxx/test/libcxx/atomics/atomics.flag/init_bool.pass.cpp
+++ b/libcxx/test/libcxx/atomics/atomics.flag/init_bool.pass.cpp
@@ -22,7 +22,7 @@
extern std::atomic_flag global;
struct X { X() { global.test_and_set(); }};
X x;
-std::atomic_flag global = ATOMIC_FLAG_INIT;
+std::atomic_flag global{false};
#endif
int main(int, char**)
diff --git a/libcxx/test/std/atomics/atomics.flag/init.pass.cpp b/libcxx/test/std/atomics/atomics.flag/init.pass.cpp
index 0905f468c9d7d..07a7502d4cfd0 100644
--- a/libcxx/test/std/atomics/atomics.flag/init.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.flag/init.pass.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
// XFAIL: c++03
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
// <atomic>
diff --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_var_init.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_var_init.pass.cpp
index 3625a218271c0..ea833c8a260d8 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_var_init.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_var_init.pass.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
// XFAIL: c++03
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
// <atomic>
diff --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/ctor.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/ctor.pass.cpp
index 021db21c80f25..32baca49e3078 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/ctor.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/ctor.pass.cpp
@@ -41,10 +41,6 @@ struct TestFunc {
constexpr Atomic a{t};
assert(a == t);
}
- {
- constexpr Atomic a = ATOMIC_VAR_INIT(t);
- assert(a == t);
- }
}
};
diff --git a/libcxx/test/std/thread/futures/futures.async/async.pass.cpp b/libcxx/test/std/thread/futures/futures.async/async.pass.cpp
index c7a3906de326b..5eded0506873e 100644
--- a/libcxx/test/std/thread/futures/futures.async/async.pass.cpp
+++ b/libcxx/test/std/thread/futures/futures.async/async.pass.cpp
@@ -30,7 +30,7 @@
typedef std::chrono::high_resolution_clock Clock;
typedef std::chrono::milliseconds ms;
-std::atomic_bool invoked = ATOMIC_VAR_INIT(false);
+std::atomic_bool invoked{false};
int f0()
{
More information about the libcxx-commits
mailing list