[libcxx-commits] [libcxx] Add `_LIBCPP_PLACEMENT_NEW_DEFINED` macro to allow for user defined placement new operators (PR #70538)
via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Oct 31 16:27:40 PDT 2023
MaxEW707 wrote:
> Clang always treats placement-new as an intrinsic, so I think we can close this: https://godbolt.org/z/fPjKja3cK
Since clang always treats the reserved placement-new as an intrinsic, even going back to clang 3.x, can we remove `_LIBCPP_INLINE_VISIBILITY` and thus the `abi_tag` on clang since the placement-new operator calls will never be generated.
This would allow us to declare the placement-new operator without getting a re-declaration error since a function cannot be re-declared with the `abi_tag` attribute.
The definition would go from
```
_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY void* operator new (std::size_t, void* __p) _NOEXCEPT {return __p;}
```
to this
```
#if defined(__clang__)
#define _LIBCPP_PLACEMENT_NEW_VIS
#else
#define _LIBCPP_PLACEMENT_NEW_VIS _LIBCPP_INLINE_VISIBILITY
#endif
_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_PLACEMENT_NEW_VIS void* operator new (std::size_t, void* __p) _NOEXCEPT {return __p;}
```
https://github.com/llvm/llvm-project/pull/70538
More information about the libcxx-commits
mailing list