-
Notifications
You must be signed in to change notification settings - Fork 12.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[libc++] Use a different smart ptr type alias #102089
Conversation
@llvm/pr-subscribers-libcxx Author: Brian Cain (androm3da) ChangesThe Full diff: https://github.com/llvm/llvm-project/pull/102089.diff 2 Files Affected:
diff --git a/libcxx/include/__memory/inout_ptr.h b/libcxx/include/__memory/inout_ptr.h
index 72e1a21ad6867..e5f3ac5d027e8 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 95aa2029c9231..fd99110790cc8 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_));
}
}
|
e.g. here is someone's copy of this C library: https://github.com/wuzhouhui/c_standard_lib/blob/e11548ad943686d303f0029d71ac2526d8b39cc5/_HEADERS/CTYPE.H#L12 cc @H-G-Hristov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking into this!
Can you update the test libcxx/test/libcxx/system_reserved_names.gen.py
with these ctype.h
macros? That avoids us to use these names in the future.
270f2fd
to
7aea4ec
Compare
done |
✅ With the latest revision this PR passed the Python code formatter. |
7aea4ec
to
79ca0ad
Compare
The `_SP` type is used by some C libraries and this alias could conflict with it.
79ca0ad
to
baa72c4
Compare
Thank you! LGTM. IMO. This should be cherrypicked into LLVM 19 too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks LGTM!
/cherry-pick baa72c4 |
Failed to cherry-pick: baa72c4 https://github.com/llvm/llvm-project/actions/runs/10363622325 Please manually backport the fix and push it to your github fork. Once this is done, please create a pull request |
whoops wrong SHA. I will fix it. |
/cherry-pick 7951673 |
The `_SP` type is used by some C libraries and this alias could conflict with it. (cherry picked from commit 7951673)
/pull-request #103003 |
The `_SP` type is used by some C libraries and this alias could conflict with it. (cherry picked from commit 7951673)
The `_SP` type is used by some C libraries and this alias could conflict with it.
The `_SP` type is used by some C libraries and this alias could conflict with it. (cherry picked from commit 7951673)
The
_SP
type is used by some C libraries and this alias could conflict with it.