diff --git a/lib/libcxxabi/include/__cxxabi_config.h b/lib/libcxxabi/include/__cxxabi_config.h index e4fd845b1fb35596e603309612471fdb2aafc893..6ec10e469387e52a9091f7e53663d6be73c5a331 100644 --- a/lib/libcxxabi/include/__cxxabi_config.h +++ b/lib/libcxxabi/include/__cxxabi_config.h @@ -128,4 +128,10 @@ # define _LIBCXXABI_NOEXCEPT noexcept #endif +#if defined(__POINTER_FIELD_PROTECTION_ABI__) +# define _LIBCXXABI_DISABLE_POINTER_FIELD_PROTECTION [[_Clang::__no_field_protection__]] +#else +# define _LIBCXXABI_DISABLE_POINTER_FIELD_PROTECTION +#endif + #endif // ____CXXABI_CONFIG_H diff --git a/lib/libcxxabi/include/cxxabi.h b/lib/libcxxabi/include/cxxabi.h index 9ea93680f62e06365ddba048b7a26a19c5b0fa45..c65e353d68daf5237e550e34522dec6d838780d0 100644 --- a/lib/libcxxabi/include/cxxabi.h +++ b/lib/libcxxabi/include/cxxabi.h @@ -19,8 +19,7 @@ #include <__cxxabi_config.h> -#define _LIBCPPABI_VERSION 15000 -#define _LIBCXXABI_NORETURN __attribute__((noreturn)) +#define _LIBCPPABI_VERSION 230000 #define _LIBCXXABI_ALWAYS_COLD __attribute__((cold)) #ifdef __cplusplus @@ -31,7 +30,7 @@ class _LIBCXXABI_TYPE_VIS type_info; // forward declaration #else class type_info; // forward declaration #endif -} +} // namespace std // runtime routines use C calling conventions, but are in __cxxabiv1 namespace @@ -56,7 +55,7 @@ __cxa_init_primary_exception(void* object, std::type_info* tinfo, void(_LIBCXXAB #endif // 2.4.3 Throwing the Exception Object -extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void +[[__noreturn__]] extern _LIBCXXABI_FUNC_VIS void __cxa_throw(void *thrown_exception, std::type_info *tinfo, #ifdef __wasm__ void *(_LIBCXXABI_DTOR_FUNC *dest)(void *)); @@ -80,22 +79,22 @@ extern _LIBCXXABI_FUNC_VIS std::type_info *__cxa_current_exception_type(); // GNU extension // Calls `terminate` with the current exception being caught. This function is used by GCC when a `noexcept` function // throws an exception inside a try/catch block and doesn't catch it. -extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_call_terminate(void*) _LIBCXXABI_NOEXCEPT; +[[__noreturn__]] extern _LIBCXXABI_FUNC_VIS void __cxa_call_terminate(void*) _LIBCXXABI_NOEXCEPT; // 2.5.4 Rethrowing Exceptions -extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_rethrow(); +[[__noreturn__]] extern _LIBCXXABI_FUNC_VIS void __cxa_rethrow(); // 2.6 Auxiliary Runtime APIs -extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_bad_cast(void); -extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_bad_typeid(void); -extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void +[[__noreturn__]] extern _LIBCXXABI_FUNC_VIS void __cxa_bad_cast(void); +[[__noreturn__]] extern _LIBCXXABI_FUNC_VIS void __cxa_bad_typeid(void); +[[__noreturn__]] extern _LIBCXXABI_FUNC_VIS void __cxa_throw_bad_array_new_length(void); // 3.2.6 Pure Virtual Function API -extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_pure_virtual(void); +[[__noreturn__]] extern _LIBCXXABI_FUNC_VIS void __cxa_pure_virtual(void); // 3.2.7 Deleted Virtual Function API -extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_deleted_virtual(void); +[[__noreturn__]] extern _LIBCXXABI_FUNC_VIS void __cxa_deleted_virtual(void); // 3.3.2 One-time Construction API #if defined(_LIBCXXABI_GUARD_ABI_ARM) diff --git a/lib/libcxxabi/src/abort_message.h b/lib/libcxxabi/src/abort_message.h index 85d6ba36e275e284af65a3d351488cdc625028d0..6d3b11194e9285248d97029129807a7b6deb45bf 100644 --- a/lib/libcxxabi/src/abort_message.h +++ b/lib/libcxxabi/src/abort_message.h @@ -11,7 +11,7 @@ #include "cxxabi.h" -extern "C" _LIBCXXABI_HIDDEN _LIBCXXABI_NORETURN void +extern "C" [[noreturn]] _LIBCXXABI_HIDDEN void __abort_message(const char *format, ...) __attribute__((format(printf, 1, 2))); #ifndef _LIBCXXABI_ASSERT diff --git a/lib/libcxxabi/src/cxa_aux_runtime.cpp b/lib/libcxxabi/src/cxa_aux_runtime.cpp index 5e6040d75a2629a6d7b2bbda961e2f441b58a6b2..e6bac221d8be86f152008162ad39c834eaf1985e 100644 --- a/lib/libcxxabi/src/cxa_aux_runtime.cpp +++ b/lib/libcxxabi/src/cxa_aux_runtime.cpp @@ -16,7 +16,7 @@ namespace __cxxabiv1 { extern "C" { -_LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_bad_cast(void) { +[[noreturn]] _LIBCXXABI_FUNC_VIS void __cxa_bad_cast(void) { #ifndef _LIBCXXABI_NO_EXCEPTIONS throw std::bad_cast(); #else @@ -24,7 +24,7 @@ _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_bad_cast(void) { #endif } -_LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_bad_typeid(void) { +[[noreturn]] _LIBCXXABI_FUNC_VIS void __cxa_bad_typeid(void) { #ifndef _LIBCXXABI_NO_EXCEPTIONS throw std::bad_typeid(); #else @@ -32,7 +32,7 @@ _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_bad_typeid(void) { #endif } -_LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void +[[noreturn]] _LIBCXXABI_FUNC_VIS void __cxa_throw_bad_array_new_length(void) { #ifndef _LIBCXXABI_NO_EXCEPTIONS throw std::bad_array_new_length(); diff --git a/lib/libcxxabi/src/cxa_default_handlers.cpp b/lib/libcxxabi/src/cxa_default_handlers.cpp index 97a6765fde8e9ff1758f7c9da0b378670a42f56a..5daf78b34ee542c98360c1e4ff98366240c13d93 100644 --- a/lib/libcxxabi/src/cxa_default_handlers.cpp +++ b/lib/libcxxabi/src/cxa_default_handlers.cpp @@ -24,8 +24,7 @@ static constinit const char* cause = "uncaught"; # ifndef _LIBCXXABI_NO_EXCEPTIONS -__attribute__((noreturn)) -static void demangling_terminate_handler() +[[noreturn]] static void demangling_terminate_handler() { using namespace __cxxabiv1; __cxa_eh_globals* globals = __cxa_get_globals_fast(); @@ -78,15 +77,14 @@ static void demangling_terminate_handler() } } #else // !_LIBCXXABI_NO_EXCEPTIONS -__attribute__((noreturn)) -static void demangling_terminate_handler() +[[noreturn]] static void demangling_terminate_handler() { + (void)cause; __abort_message("terminating"); } #endif // !_LIBCXXABI_NO_EXCEPTIONS -__attribute__((noreturn)) -static void demangling_unexpected_handler() +[[noreturn]] static void demangling_unexpected_handler() { cause = "unexpected"; std::terminate(); diff --git a/lib/libcxxabi/src/cxa_exception.cpp b/lib/libcxxabi/src/cxa_exception.cpp index 5d7edae697d67492fe500daa0dc82211a0578139..f56ecc248eefb7f1e11518cf54fd4c0229b965dd 100644 --- a/lib/libcxxabi/src/cxa_exception.cpp +++ b/lib/libcxxabi/src/cxa_exception.cpp @@ -140,7 +140,7 @@ exception_cleanup_func(_Unwind_Reason_Code reason, _Unwind_Exception* unwind_exc __cxa_decrement_exception_refcount(unwind_exception + 1); } -static _LIBCXXABI_NORETURN void failed_throw(__cxa_exception* exception_header) { +[[noreturn]] static void failed_throw(__cxa_exception* exception_header) { // Section 2.5.3 says: // * For purposes of this ABI, several things are considered exception handlers: // ** A terminate() call due to a throw. diff --git a/lib/libcxxabi/src/cxa_guard_impl.h b/lib/libcxxabi/src/cxa_guard_impl.h index 191a589176b1a306d634a7de366b1b67d117a8ca..5f51e81c57209339e90030008e40f2824868e434 100644 --- a/lib/libcxxabi/src/cxa_guard_impl.h +++ b/lib/libcxxabi/src/cxa_guard_impl.h @@ -637,7 +637,7 @@ struct GlobalStatic { static T instance; }; template -_LIBCPP_CONSTINIT T GlobalStatic::instance = {}; +constinit T GlobalStatic::instance = {}; enum class Implementation { NoThreads, GlobalMutex, Futex }; diff --git a/lib/libcxxabi/src/cxa_handlers.cpp b/lib/libcxxabi/src/cxa_handlers.cpp index f879ff0d8ff186ce6f6bdab0e1f0ad19a2ffa5ff..0abdc740486b8a04e7c1f4da911a3eba05138bab 100644 --- a/lib/libcxxabi/src/cxa_handlers.cpp +++ b/lib/libcxxabi/src/cxa_handlers.cpp @@ -36,8 +36,7 @@ __unexpected(unexpected_handler func) __abort_message("unexpected_handler unexpectedly returned"); } -__attribute__((noreturn)) -void +[[noreturn]] void unexpected() { __unexpected(get_unexpected()); @@ -69,8 +68,7 @@ __terminate(terminate_handler func) noexcept #endif // _LIBCXXABI_NO_EXCEPTIONS } -__attribute__((noreturn)) -void +[[noreturn]] void terminate() noexcept { #ifndef _LIBCXXABI_NO_EXCEPTIONS diff --git a/lib/libcxxabi/src/cxa_handlers.h b/lib/libcxxabi/src/cxa_handlers.h index 3d8dc6b2de95e421320b438828bdbf68212f77d2..072b85ed89f856f03a78361efacb187c895190c5 100644 --- a/lib/libcxxabi/src/cxa_handlers.h +++ b/lib/libcxxabi/src/cxa_handlers.h @@ -19,11 +19,11 @@ namespace std { -_LIBCXXABI_HIDDEN _LIBCXXABI_NORETURN +[[noreturn]] _LIBCXXABI_HIDDEN void __unexpected(unexpected_handler func); -_LIBCXXABI_HIDDEN _LIBCXXABI_NORETURN +[[noreturn]] _LIBCXXABI_HIDDEN void __terminate(terminate_handler func) noexcept; diff --git a/lib/libcxxabi/src/cxa_personality.cpp b/lib/libcxxabi/src/cxa_personality.cpp index f607fa58dee897355ae48d601f851b4a81f2e0e4..c5050e46c0e85c30190b4dc54c8e49987b11daac 100644 --- a/lib/libcxxabi/src/cxa_personality.cpp +++ b/lib/libcxxabi/src/cxa_personality.cpp @@ -23,7 +23,7 @@ #if __has_feature(ptrauth_calls) -// CXXABI depends on defintions in libunwind as pointer auth couples the +// CXXABI depends on definitions in libunwind as pointer auth couples the // definitions # include "libunwind.h" @@ -67,15 +67,6 @@ # pragma clang diagnostic ignored "-Wmissing-prototypes" #endif -// TODO: This is a temporary workaround for libc++abi to recognize that it's being -// built against LLVM's libunwind. LLVM's libunwind started reporting _LIBUNWIND_VERSION -// in LLVM 15 -- we can remove this workaround after shipping LLVM 17. Once we remove -// this workaround, it won't be possible to build libc++abi against libunwind headers -// from LLVM 14 and before anymore. -#if defined(____LIBUNWIND_CONFIG_H__) && !defined(_LIBUNWIND_VERSION) -# define _LIBUNWIND_VERSION -#endif - #if defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__) #include #include @@ -1125,9 +1116,7 @@ __gxx_personality_seh0(PEXCEPTION_RECORD ms_exc, void *this_frame, #else -// zig patch: https://github.com/llvm/llvm-project/issues/194232 -extern "C" _Unwind_Reason_Code __gnu_unwind_frame(_Unwind_Exception*, - _Unwind_Context*); +extern "C" _Unwind_Reason_Code __gnu_unwind_frame(_Unwind_Exception*, _Unwind_Context*); // Helper function to unwind one frame. // ARM EHABI 7.3 and 7.4: If the personality function returns _URC_CONTINUE_UNWIND, the @@ -1283,8 +1272,7 @@ __gxx_personality_v0(_Unwind_State state, #endif -__attribute__((noreturn)) -_LIBCXXABI_FUNC_VIS void +[[noreturn]] _LIBCXXABI_FUNC_VIS void __cxa_call_unexpected(void* arg) { _Unwind_Exception* unwind_exception = static_cast<_Unwind_Exception*>(arg); diff --git a/lib/libcxxabi/src/cxa_vector.cpp b/lib/libcxxabi/src/cxa_vector.cpp index 857ee27d065c315053f30d135769c835afb4fb07..5eac7a8dc97294d7ad9931d1c55007fe8b4d3cb8 100644 --- a/lib/libcxxabi/src/cxa_vector.cpp +++ b/lib/libcxxabi/src/cxa_vector.cpp @@ -116,8 +116,7 @@ namespace { // namespace { -_LIBCXXABI_NORETURN -void throw_bad_array_new_length() { +[[noreturn]] void throw_bad_array_new_length() { #ifndef _LIBCXXABI_NO_EXCEPTIONS throw std::bad_array_new_length(); #else diff --git a/lib/libcxxabi/src/cxa_virtual.cpp b/lib/libcxxabi/src/cxa_virtual.cpp index 8f4fdd0919f0e2243922e58e208ac1991d0af289..1d3f4c63cf2dea4efe5cecb1f5fb97b12e3aa0c4 100644 --- a/lib/libcxxabi/src/cxa_virtual.cpp +++ b/lib/libcxxabi/src/cxa_virtual.cpp @@ -11,12 +11,12 @@ namespace __cxxabiv1 { extern "C" { -_LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN +[[noreturn]] _LIBCXXABI_FUNC_VIS void __cxa_pure_virtual(void) { __abort_message("Pure virtual function called!"); } -_LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN +[[noreturn]] _LIBCXXABI_FUNC_VIS void __cxa_deleted_virtual(void) { __abort_message("Deleted virtual function called!"); } diff --git a/lib/libcxxabi/src/demangle/ItaniumDemangle.h b/lib/libcxxabi/src/demangle/ItaniumDemangle.h index b999438ff2ca86dd688e0fabcfd882ac4cde15e5..94d780e229631769b2058edf8b1167e636e074e1 100644 --- a/lib/libcxxabi/src/demangle/ItaniumDemangle.h +++ b/lib/libcxxabi/src/demangle/ItaniumDemangle.h @@ -1537,6 +1537,27 @@ public: } }; +class PackIndexing final : public Node { + const Node *Pattern; + const Node *Index; + +public: + PackIndexing(const Node *Pattern_, const Node *Index_) + : Node(KPackIndexing), Pattern(Pattern_), Index(Index_) {} + + template void match(Fn F) const { F(Pattern, Index); } + + void printLeft(OutputBuffer &OB) const override { + OB.printOpen('('); + ParameterPackExpansion PPE(Pattern); + PPE.printLeft(OB); + OB.printClose(')'); + OB.printOpen('['); + OB.printLeft(*Index); + OB.printClose(']'); + } +}; + class TemplateArgs final : public Node { NodeArray Params; Node *Requires; @@ -4531,6 +4552,18 @@ Node *AbstractManglingParser::parseType() { Result = make(Child); break; } + // ::= Dy # pack indexing (C++26) + case 'y': { + First += 2; + Node *Pattern = getDerived().parseType(); + if (!Pattern) + return nullptr; + Node *Index = getDerived().parseExpr(); + if (!Index) + return nullptr; + Result = make(Pattern, Index); + break; + } // Exception specifier on a function type. case 'o': case 'O': @@ -5375,6 +5408,16 @@ Node *AbstractManglingParser::parseExpr() { return nullptr; return make(Child); } + if (consumeIf("sy")) { + Node *Pattern = look() == 'T' ? getDerived().parseTemplateParam() + : getDerived().parseFunctionParam(); + if (Pattern == nullptr) + return nullptr; + Node *Index = getDerived().parseExpr(); + if (Index == nullptr) + return nullptr; + return make(Pattern, Index); + } if (consumeIf("sZ")) { if (look() == 'T') { Node *R = getDerived().parseTemplateParam(); @@ -6157,8 +6200,17 @@ AbstractManglingParser::parseTemplateArgs(bool TagTemplates) { // extension ::= ___Z _block_invoke // extension ::= ___Z _block_invoke+ // extension ::= ___Z _block_invoke_+ +// extension ::= __alloc_token__Z +// extension ::= __alloc_token_+__Z template Node *AbstractManglingParser::parse(bool ParseParams) { + bool AllocToken = consumeIf("__alloc_token_"); + if (AllocToken) { + const char *Saved = First; + if (parseNumber().empty() || !consumeIf('_')) + First = Saved; + } + if (consumeIf("_Z") || consumeIf("__Z")) { Node *Encoding = getDerived().parseEncoding(ParseParams); if (Encoding == nullptr) @@ -6168,6 +6220,8 @@ Node *AbstractManglingParser::parse(bool ParseParams) { make(Encoding, std::string_view(First, Last - First)); First = Last; } + if (AllocToken) + Encoding = make(Encoding, ".alloc_token"); if (numLeft() != 0) return nullptr; return Encoding; diff --git a/lib/libcxxabi/src/demangle/ItaniumNodes.def b/lib/libcxxabi/src/demangle/ItaniumNodes.def index 18f5d52b47e911395927196451dafa88a7bc5f3a..2c183ec5d23f8666f16762a8a2d9974e506cc8a9 100644 --- a/lib/libcxxabi/src/demangle/ItaniumNodes.def +++ b/lib/libcxxabi/src/demangle/ItaniumNodes.def @@ -100,5 +100,5 @@ NODE(ExprRequirement) NODE(TypeRequirement) NODE(NestedRequirement) NODE(ExplicitObjectParameter) - +NODE(PackIndexing) #undef NODE diff --git a/lib/libcxxabi/src/demangle/Utility.h b/lib/libcxxabi/src/demangle/Utility.h index df5b54dca492d4791df38f825bd1c6b1b22a078b..ca420bce66d9ccf4d0d7b7ee32e970cc69ea5f43 100644 --- a/lib/libcxxabi/src/demangle/Utility.h +++ b/lib/libcxxabi/src/demangle/Utility.h @@ -31,7 +31,7 @@ class Node; // Stream that AST nodes write their string representation into after the AST // has been parsed. -class OutputBuffer { +class DEMANGLE_ABI OutputBuffer { char *Buffer = nullptr; size_t CurrentPosition = 0; size_t BufferCapacity = 0; diff --git a/lib/libcxxabi/src/fallback_malloc.cpp b/lib/libcxxabi/src/fallback_malloc.cpp index 6a261e6f009fee3394a11b01dc938966b3160590..81195c9a4dc1743ddc609e0d9bce4be3a75dd730 100644 --- a/lib/libcxxabi/src/fallback_malloc.cpp +++ b/lib/libcxxabi/src/fallback_malloc.cpp @@ -35,9 +35,9 @@ namespace { // When POSIX threads are not available, make the mutex operations a nop #ifndef _LIBCXXABI_HAS_NO_THREADS -static _LIBCPP_CONSTINIT std::__libcpp_mutex_t heap_mutex = _LIBCPP_MUTEX_INITIALIZER; +static constinit std::__libcpp_mutex_t heap_mutex = _LIBCPP_MUTEX_INITIALIZER; #else -static _LIBCPP_CONSTINIT void* heap_mutex = 0; +static constinit void* heap_mutex = 0; #endif class mutexor { diff --git a/lib/libcxxabi/src/private_typeinfo.cpp b/lib/libcxxabi/src/private_typeinfo.cpp index d185f2618a7eab41d19ed83076359d03afcc5e97..ba3da519238b7afd28965cab4ea63ab7ad1b4cfa 100644 --- a/lib/libcxxabi/src/private_typeinfo.cpp +++ b/lib/libcxxabi/src/private_typeinfo.cpp @@ -99,28 +99,27 @@ struct derived_object_info { }; /// A helper function that gets (dynamic_ptr, dynamic_type, offset_to_derived) from static_ptr. -void dyn_cast_get_derived_info(derived_object_info* info, const void* static_ptr) -{ +derived_object_info dyn_cast_get_derived_info(const void* static_ptr) { + derived_object_info info; #if __has_feature(cxx_abi_relative_vtable) - // The vtable address will point to the first virtual function, which is 8 - // bytes after the start of the vtable (4 for the offset from top + 4 for - // the typeinfo component). - const int32_t* vtable = - *reinterpret_cast(static_ptr); - info->offset_to_derived = static_cast(vtable[-2]); - info->dynamic_ptr = static_cast(static_ptr) + info->offset_to_derived; + // The vtable address will point to the first virtual function, which is 8 + // bytes after the start of the vtable (4 for the offset from top + 4 for + // the typeinfo component). + const int32_t* vtable = *reinterpret_cast(static_ptr); + info.offset_to_derived = static_cast(vtable[-2]); + info.dynamic_ptr = static_cast(static_ptr) + info.offset_to_derived; - // The typeinfo component is now a relative offset to a proxy. - int32_t offset_to_ti_proxy = vtable[-1]; - const uint8_t* ptr_to_ti_proxy = - reinterpret_cast(vtable) + offset_to_ti_proxy; - info->dynamic_type = *(reinterpret_cast(ptr_to_ti_proxy)); + // The typeinfo component is now a relative offset to a proxy. + int32_t offset_to_ti_proxy = vtable[-1]; + const uint8_t* ptr_to_ti_proxy = reinterpret_cast(vtable) + offset_to_ti_proxy; + info.dynamic_type = *(reinterpret_cast(ptr_to_ti_proxy)); #else void** vtable = strip_vtable(*static_cast(static_ptr)); - info->offset_to_derived = reinterpret_cast(vtable[-2]); - info->dynamic_ptr = static_cast(static_ptr) + info->offset_to_derived; - info->dynamic_type = static_cast(vtable[-1]); + info.offset_to_derived = reinterpret_cast(vtable[-2]); + info.dynamic_ptr = static_cast(static_ptr) + info.offset_to_derived; + info.dynamic_type = static_cast(vtable[-1]); #endif + return info; } /// A helper function for __dynamic_cast that casts a base sub-object pointer @@ -915,8 +914,7 @@ __dynamic_cast(const void *static_ptr, const __class_type_info *static_type, const __class_type_info *dst_type, std::ptrdiff_t src2dst_offset) { // Get (dynamic_ptr, dynamic_type) from static_ptr - derived_object_info derived_info; - dyn_cast_get_derived_info(&derived_info, static_ptr); + derived_object_info derived_info = dyn_cast_get_derived_info(static_ptr); // Initialize answer to nullptr. This will be changed from the search // results if a non-null answer is found. Regardless, this is what will diff --git a/lib/libcxxabi/src/private_typeinfo.h b/lib/libcxxabi/src/private_typeinfo.h index 328a02edef5c1d88ac3387451d4eb481af5d11f8..e92dc332d986b7313e12be1c130fd082eb7b867e 100644 --- a/lib/libcxxabi/src/private_typeinfo.h +++ b/lib/libcxxabi/src/private_typeinfo.h @@ -145,7 +145,7 @@ public: // Has one non-virtual public base class at offset zero class _LIBCXXABI_TYPE_VIS __si_class_type_info : public __class_type_info { public: - const __class_type_info *__base_type; + _LIBCXXABI_DISABLE_POINTER_FIELD_PROTECTION const __class_type_info* __base_type; _LIBCXXABI_HIDDEN virtual ~__si_class_type_info(); @@ -204,7 +204,7 @@ public: class _LIBCXXABI_TYPE_VIS __pbase_type_info : public __shim_type_info { public: unsigned int __flags; - const __shim_type_info *__pointee; + _LIBCXXABI_DISABLE_POINTER_FIELD_PROTECTION const __shim_type_info* __pointee; enum __masks { __const_mask = 0x1, @@ -245,7 +245,7 @@ public: class _LIBCXXABI_TYPE_VIS __pointer_to_member_type_info : public __pbase_type_info { public: - const __class_type_info *__context; + _LIBCXXABI_DISABLE_POINTER_FIELD_PROTECTION const __class_type_info* __context; _LIBCXXABI_HIDDEN virtual ~__pointer_to_member_type_info(); _LIBCXXABI_HIDDEN virtual bool can_catch(const __shim_type_info *, diff --git a/lib/libcxxabi/src/stdlib_new_delete.cpp b/lib/libcxxabi/src/stdlib_new_delete.cpp index 783357c4351be1cb0922349f5cd9ea18173637ae..164a26335eb38276feaa0c3bac9e612f26cc806e 100644 --- a/lib/libcxxabi/src/stdlib_new_delete.cpp +++ b/lib/libcxxabi/src/stdlib_new_delete.cpp @@ -20,10 +20,6 @@ # error The _THROW_BAD_ALLOC macro should be already defined by libc++ #endif -#ifndef _LIBCPP_WEAK -# error The _LIBCPP_WEAK macro should be already defined by libc++ -#endif - #if defined(_LIBCXXABI_NO_EXCEPTIONS) != !_LIBCPP_HAS_EXCEPTIONS # error libc++ and libc++abi seem to disagree on whether exceptions are enabled #endif @@ -70,7 +66,7 @@ OVERRIDABLE_FUNCTION void* operator new(std::size_t size) _THROW_BAD_ALLOC { return p; } -_LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept { +[[gnu::weak]] void* operator new(size_t size, const std::nothrow_t&) noexcept { #if !_LIBCPP_HAS_EXCEPTIONS # if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION _LIBCPP_ASSERT_SHIM( @@ -96,7 +92,7 @@ _LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept { OVERRIDABLE_FUNCTION void* operator new[](size_t size) _THROW_BAD_ALLOC { return ::operator new(size); } -_LIBCPP_WEAK void* operator new[](size_t size, const std::nothrow_t&) noexcept { +[[gnu::weak]] void* operator new[](size_t size, const std::nothrow_t&) noexcept { #if !_LIBCPP_HAS_EXCEPTIONS # if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION _LIBCPP_ASSERT_SHIM( @@ -120,17 +116,17 @@ _LIBCPP_WEAK void* operator new[](size_t size, const std::nothrow_t&) noexcept { #endif } -_LIBCPP_WEAK void operator delete(void* ptr) noexcept { std::free(ptr); } +[[gnu::weak]] void operator delete(void* ptr) noexcept { std::free(ptr); } -_LIBCPP_WEAK void operator delete(void* ptr, const std::nothrow_t&) noexcept { ::operator delete(ptr); } +[[gnu::weak]] void operator delete(void* ptr, const std::nothrow_t&) noexcept { ::operator delete(ptr); } -_LIBCPP_WEAK void operator delete(void* ptr, size_t) noexcept { ::operator delete(ptr); } +[[gnu::weak]] void operator delete(void* ptr, size_t) noexcept { ::operator delete(ptr); } -_LIBCPP_WEAK void operator delete[](void* ptr) noexcept { ::operator delete(ptr); } +[[gnu::weak]] void operator delete[](void* ptr) noexcept { ::operator delete(ptr); } -_LIBCPP_WEAK void operator delete[](void* ptr, const std::nothrow_t&) noexcept { ::operator delete[](ptr); } +[[gnu::weak]] void operator delete[](void* ptr, const std::nothrow_t&) noexcept { ::operator delete[](ptr); } -_LIBCPP_WEAK void operator delete[](void* ptr, size_t) noexcept { ::operator delete[](ptr); } +[[gnu::weak]] void operator delete[](void* ptr, size_t) noexcept { ::operator delete[](ptr); } #if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION @@ -161,7 +157,7 @@ OVERRIDABLE_FUNCTION void* operator new(std::size_t size, std::align_val_t align return p; } -_LIBCPP_WEAK void* operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept { +[[gnu::weak]] void* operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept { # if !_LIBCPP_HAS_EXCEPTIONS # if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION _LIBCPP_ASSERT_SHIM( @@ -189,7 +185,7 @@ OVERRIDABLE_FUNCTION void* operator new[](size_t size, std::align_val_t alignmen return ::operator new(size, alignment); } -_LIBCPP_WEAK void* operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept { +[[gnu::weak]] void* operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept { # if !_LIBCPP_HAS_EXCEPTIONS # if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION _LIBCPP_ASSERT_SHIM( @@ -213,25 +209,25 @@ _LIBCPP_WEAK void* operator new[](size_t size, std::align_val_t alignment, const # endif } -_LIBCPP_WEAK void operator delete(void* ptr, std::align_val_t) noexcept { std::__libcpp_aligned_free(ptr); } +[[gnu::weak]] void operator delete(void* ptr, std::align_val_t) noexcept { std::__libcpp_aligned_free(ptr); } -_LIBCPP_WEAK void operator delete(void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept { +[[gnu::weak]] void operator delete(void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept { ::operator delete(ptr, alignment); } -_LIBCPP_WEAK void operator delete(void* ptr, size_t, std::align_val_t alignment) noexcept { +[[gnu::weak]] void operator delete(void* ptr, size_t, std::align_val_t alignment) noexcept { ::operator delete(ptr, alignment); } -_LIBCPP_WEAK void operator delete[](void* ptr, std::align_val_t alignment) noexcept { +[[gnu::weak]] void operator delete[](void* ptr, std::align_val_t alignment) noexcept { ::operator delete(ptr, alignment); } -_LIBCPP_WEAK void operator delete[](void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept { +[[gnu::weak]] void operator delete[](void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept { ::operator delete[](ptr, alignment); } -_LIBCPP_WEAK void operator delete[](void* ptr, size_t, std::align_val_t alignment) noexcept { +[[gnu::weak]] void operator delete[](void* ptr, size_t, std::align_val_t alignment) noexcept { ::operator delete[](ptr, alignment); }