Skip to content

Commit 7951673

Browse files
authored
[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.
1 parent f1fe451 commit 7951673

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

libcxx/include/__memory/inout_ptr.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,17 @@ class _LIBCPP_TEMPLATE_VIS inout_ptr_t {
6363
}
6464
}
6565

66-
using _SP = __pointer_of_or_t<_Smart, _Pointer>;
66+
using _SmartPtr = __pointer_of_or_t<_Smart, _Pointer>;
6767
if constexpr (is_pointer_v<_Smart>) {
68-
std::apply([&](auto&&... __args) { __s_ = _Smart(static_cast<_SP>(__p_), std::forward<_Args>(__args)...); },
68+
std::apply([&](auto&&... __args) { __s_ = _Smart(static_cast<_SmartPtr>(__p_), std::forward<_Args>(__args)...); },
6969
std::move(__a_));
7070
} else if constexpr (__resettable_smart_pointer_with_args<_Smart, _Pointer, _Args...>) {
71-
std::apply([&](auto&&... __args) { __s_.reset(static_cast<_SP>(__p_), std::forward<_Args>(__args)...); },
71+
std::apply([&](auto&&... __args) { __s_.reset(static_cast<_SmartPtr>(__p_), std::forward<_Args>(__args)...); },
7272
std::move(__a_));
7373
} else {
74-
static_assert(is_constructible_v<_Smart, _SP, _Args...>,
74+
static_assert(is_constructible_v<_Smart, _SmartPtr, _Args...>,
7575
"The smart pointer must be constructible from arguments of types _Smart, _Pointer, _Args...");
76-
std::apply([&](auto&&... __args) { __s_ = _Smart(static_cast<_SP>(__p_), std::forward<_Args>(__args)...); },
76+
std::apply([&](auto&&... __args) { __s_ = _Smart(static_cast<_SmartPtr>(__p_), std::forward<_Args>(__args)...); },
7777
std::move(__a_));
7878
}
7979
}

libcxx/include/__memory/out_ptr.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ class _LIBCPP_TEMPLATE_VIS out_ptr_t {
5858
return;
5959
}
6060

61-
using _SP = __pointer_of_or_t<_Smart, _Pointer>;
61+
using _SmartPtr = __pointer_of_or_t<_Smart, _Pointer>;
6262
if constexpr (__resettable_smart_pointer_with_args<_Smart, _Pointer, _Args...>) {
63-
std::apply([&](auto&&... __args) { __s_.reset(static_cast<_SP>(__p_), std::forward<_Args>(__args)...); },
63+
std::apply([&](auto&&... __args) { __s_.reset(static_cast<_SmartPtr>(__p_), std::forward<_Args>(__args)...); },
6464
std::move(__a_));
6565
} else {
66-
static_assert(is_constructible_v<_Smart, _SP, _Args...>,
66+
static_assert(is_constructible_v<_Smart, _SmartPtr, _Args...>,
6767
"The smart pointer must be constructible from arguments of types _Smart, _Pointer, _Args...");
68-
std::apply([&](auto&&... __args) { __s_ = _Smart(static_cast<_SP>(__p_), std::forward<_Args>(__args)...); },
68+
std::apply([&](auto&&... __args) { __s_ = _Smart(static_cast<_SmartPtr>(__p_), std::forward<_Args>(__args)...); },
6969
std::move(__a_));
7070
}
7171
}

libcxx/test/libcxx/system_reserved_names.gen.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
from libcxx.header_information import lit_header_restrictions, public_headers
1818

1919
for header in public_headers:
20-
print(f"""\
20+
print(
21+
f"""\
2122
//--- {header}.compile.pass.cpp
2223
{lit_header_restrictions.get(header, '')}
2324
@@ -162,6 +163,18 @@
162163
#define erase SYSTEM_RESERVED_NAME
163164
#define refresh SYSTEM_RESERVED_NAME
164165
166+
// Dinkumware libc ctype.h uses these definitions
167+
#define _XA SYSTEM_RESERVED_NAME
168+
#define _XS SYSTEM_RESERVED_NAME
169+
#define _BB SYSTEM_RESERVED_NAME
170+
#define _CN SYSTEM_RESERVED_NAME
171+
#define _DI SYSTEM_RESERVED_NAME
172+
#define _LO SYSTEM_RESERVED_NAME
173+
#define _PU SYSTEM_RESERVED_NAME
174+
#define _SP SYSTEM_RESERVED_NAME
175+
#define _UP SYSTEM_RESERVED_NAME
176+
#define _XD SYSTEM_RESERVED_NAME
177+
165178
#include <{header}>
166179
167180
// Make sure we don't swallow the definition of the macros we push/pop
@@ -172,4 +185,5 @@
172185
static_assert(__builtin_strcmp(STRINGIFY(move), STRINGIFY(SYSTEM_RESERVED_NAME)) == 0, "");
173186
static_assert(__builtin_strcmp(STRINGIFY(erase), STRINGIFY(SYSTEM_RESERVED_NAME)) == 0, "");
174187
static_assert(__builtin_strcmp(STRINGIFY(refresh), STRINGIFY(SYSTEM_RESERVED_NAME)) == 0, "");
175-
""")
188+
"""
189+
)

0 commit comments

Comments
 (0)