[libcxx-commits] [libcxx] [libc++] Use a different smart ptr type alias (PR #102089)
Brian Cain via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Aug 6 12:50:43 PDT 2024
https://github.com/androm3da updated https://github.com/llvm/llvm-project/pull/102089
>From 7aea4ecc113213554a1d9c0316df8694a1552db7 Mon Sep 17 00:00:00 2001
From: Brian Cain <bcain at quicinc.com>
Date: Mon, 5 Aug 2024 17:48:18 -0700
Subject: [PATCH] [libc++] Use a different smart ptr type alias
The `_SP` type is used by some C libraries and this alias could conflict
with it.
---
libcxx/include/__memory/inout_ptr.h | 10 +++++-----
libcxx/include/__memory/out_ptr.h | 8 ++++----
libcxx/test/libcxx/system_reserved_names.gen.py | 12 ++++++++++++
3 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/libcxx/include/__memory/inout_ptr.h b/libcxx/include/__memory/inout_ptr.h
index 72e1a21ad68671..e5f3ac5d027e8e 100644
--- a/libcxx/include/__memory/inout_ptr.h
+++ b/libcxx/include/__memory/inout_ptr.h
@@ -63,17 +63,17 @@ class _LIBCPP_TEMPLATE_VIS inout_ptr_t {
}
}
- using _SP = __pointer_of_or_t<_Smart, _Pointer>;
+ using _SmartPtr = __pointer_of_or_t<_Smart, _Pointer>;
if constexpr (is_pointer_v<_Smart>) {
- std::apply([&](auto&&... __args) { __s_ = _Smart(static_cast<_SP>(__p_), std::forward<_Args>(__args)...); },
+ std::apply([&](auto&&... __args) { __s_ = _Smart(static_cast<_SmartPtr>(__p_), std::forward<_Args>(__args)...); },
std::move(__a_));
} else if constexpr (__resettable_smart_pointer_with_args<_Smart, _Pointer, _Args...>) {
- std::apply([&](auto&&... __args) { __s_.reset(static_cast<_SP>(__p_), std::forward<_Args>(__args)...); },
+ std::apply([&](auto&&... __args) { __s_.reset(static_cast<_SmartPtr>(__p_), std::forward<_Args>(__args)...); },
std::move(__a_));
} else {
- static_assert(is_constructible_v<_Smart, _SP, _Args...>,
+ static_assert(is_constructible_v<_Smart, _SmartPtr, _Args...>,
"The smart pointer must be constructible from arguments of types _Smart, _Pointer, _Args...");
- std::apply([&](auto&&... __args) { __s_ = _Smart(static_cast<_SP>(__p_), std::forward<_Args>(__args)...); },
+ std::apply([&](auto&&... __args) { __s_ = _Smart(static_cast<_SmartPtr>(__p_), std::forward<_Args>(__args)...); },
std::move(__a_));
}
}
diff --git a/libcxx/include/__memory/out_ptr.h b/libcxx/include/__memory/out_ptr.h
index 95aa2029c92314..fd99110790cc89 100644
--- a/libcxx/include/__memory/out_ptr.h
+++ b/libcxx/include/__memory/out_ptr.h
@@ -58,14 +58,14 @@ class _LIBCPP_TEMPLATE_VIS out_ptr_t {
return;
}
- using _SP = __pointer_of_or_t<_Smart, _Pointer>;
+ using _SmartPtr = __pointer_of_or_t<_Smart, _Pointer>;
if constexpr (__resettable_smart_pointer_with_args<_Smart, _Pointer, _Args...>) {
- std::apply([&](auto&&... __args) { __s_.reset(static_cast<_SP>(__p_), std::forward<_Args>(__args)...); },
+ std::apply([&](auto&&... __args) { __s_.reset(static_cast<_SmartPtr>(__p_), std::forward<_Args>(__args)...); },
std::move(__a_));
} else {
- static_assert(is_constructible_v<_Smart, _SP, _Args...>,
+ static_assert(is_constructible_v<_Smart, _SmartPtr, _Args...>,
"The smart pointer must be constructible from arguments of types _Smart, _Pointer, _Args...");
- std::apply([&](auto&&... __args) { __s_ = _Smart(static_cast<_SP>(__p_), std::forward<_Args>(__args)...); },
+ std::apply([&](auto&&... __args) { __s_ = _Smart(static_cast<_SmartPtr>(__p_), std::forward<_Args>(__args)...); },
std::move(__a_));
}
}
diff --git a/libcxx/test/libcxx/system_reserved_names.gen.py b/libcxx/test/libcxx/system_reserved_names.gen.py
index 0d935a18addeee..32de9cba663511 100644
--- a/libcxx/test/libcxx/system_reserved_names.gen.py
+++ b/libcxx/test/libcxx/system_reserved_names.gen.py
@@ -162,6 +162,18 @@
#define erase SYSTEM_RESERVED_NAME
#define refresh SYSTEM_RESERVED_NAME
+// Dinkumware libc ctype.h uses these definitions
+#define _XA SYSTEM_RESERVED_NAME
+#define _XS SYSTEM_RESERVED_NAME
+#define _BB SYSTEM_RESERVED_NAME
+#define _CN SYSTEM_RESERVED_NAME
+#define _DI SYSTEM_RESERVED_NAME
+#define _LO SYSTEM_RESERVED_NAME
+#define _PU SYSTEM_RESERVED_NAME
+#define _SP SYSTEM_RESERVED_NAME
+#define _UP SYSTEM_RESERVED_NAME
+#define _XD SYSTEM_RESERVED_NAME
+
#include <{header}>
// Make sure we don't swallow the definition of the macros we push/pop
More information about the libcxx-commits
mailing list