[libc++] Use a different smart ptr type alias (#102089)

The `_SP` type is used by some C libraries and this alias could conflict
with it.

(cherry picked from commit 7951673d408ee64744d0b924a49db78e8243d876)
This commit is contained in:
Brian Cain 2024-08-12 20:07:08 -05:00 committed by Tobias Hieta
parent dec94b04c0
commit a3b18fcd24
3 changed files with 25 additions and 11 deletions

View File

@ -63,17 +63,17 @@ public:
} }
} }
using _SP = __pointer_of_or_t<_Smart, _Pointer>; using _SmartPtr = __pointer_of_or_t<_Smart, _Pointer>;
if constexpr (is_pointer_v<_Smart>) { 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_)); std::move(__a_));
} else if constexpr (__resettable_smart_pointer_with_args<_Smart, _Pointer, _Args...>) { } 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_)); std::move(__a_));
} else { } 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..."); "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_)); std::move(__a_));
} }
} }

View File

@ -58,14 +58,14 @@ public:
return; 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...>) { 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_)); std::move(__a_));
} else { } 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..."); "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_)); std::move(__a_));
} }
} }

View File

@ -17,7 +17,8 @@ sys.path.append(sys.argv[1])
from libcxx.header_information import lit_header_restrictions, public_headers from libcxx.header_information import lit_header_restrictions, public_headers
for header in public_headers: for header in public_headers:
print(f"""\ print(
f"""\
//--- {header}.compile.pass.cpp //--- {header}.compile.pass.cpp
{lit_header_restrictions.get(header, '')} {lit_header_restrictions.get(header, '')}
@ -162,6 +163,18 @@ for header in public_headers:
#define erase SYSTEM_RESERVED_NAME #define erase SYSTEM_RESERVED_NAME
#define refresh 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}> #include <{header}>
// Make sure we don't swallow the definition of the macros we push/pop // Make sure we don't swallow the definition of the macros we push/pop
@ -172,4 +185,5 @@ static_assert(__builtin_strcmp(STRINGIFY(max), STRINGIFY(SYSTEM_RESERVED_NAME))
static_assert(__builtin_strcmp(STRINGIFY(move), STRINGIFY(SYSTEM_RESERVED_NAME)) == 0, ""); static_assert(__builtin_strcmp(STRINGIFY(move), STRINGIFY(SYSTEM_RESERVED_NAME)) == 0, "");
static_assert(__builtin_strcmp(STRINGIFY(erase), STRINGIFY(SYSTEM_RESERVED_NAME)) == 0, ""); static_assert(__builtin_strcmp(STRINGIFY(erase), STRINGIFY(SYSTEM_RESERVED_NAME)) == 0, "");
static_assert(__builtin_strcmp(STRINGIFY(refresh), STRINGIFY(SYSTEM_RESERVED_NAME)) == 0, ""); static_assert(__builtin_strcmp(STRINGIFY(refresh), STRINGIFY(SYSTEM_RESERVED_NAME)) == 0, "");
""") """
)