authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-01-17 05:25:15+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-04-22 15:31:56+02:00
logc32618eed06a4d8c8755f5d7871d0ff7f21091fa
tree0d7efb4d1011cd0d2e2e1799c4e56ac174ebbbb7
parentc81170dcd680d94e6f6474874e5dbb5f87712036
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

libcxxabi: update to LLVM 22


11 files changed, 235 insertions(+), 71 deletions(-)

lib/libcxxabi/include/__cxxabi_config.h+42-23
......@@ -14,10 +14,6 @@
1414#define _LIBCXXABI_ARM_EHABI
1515#endif
1616
17#if !defined(__has_attribute)
18#define __has_attribute(_attribute_) 0
19#endif
20
2117#if defined(__clang__)
2218# define _LIBCXXABI_COMPILER_CLANG
2319# ifndef __apple_build_version__
......@@ -25,10 +21,6 @@
2521# endif
2622#elif defined(__GNUC__)
2723# define _LIBCXXABI_COMPILER_GCC
28#elif defined(_MSC_VER)
29# define _LIBCXXABI_COMPILER_MSVC
30#elif defined(__IBMCPP__)
31# define _LIBCXXABI_COMPILER_IBM
3224#endif
3325
3426#if defined(_WIN32)
......@@ -66,17 +58,7 @@
6658 #endif
6759#endif
6860
69#if defined(_LIBCXXABI_COMPILER_MSVC)
70#define _LIBCXXABI_WEAK
71#else
7261#define _LIBCXXABI_WEAK __attribute__((__weak__))
73#endif
74
75#if defined(__clang__)
76#define _LIBCXXABI_COMPILER_CLANG
77#elif defined(__GNUC__)
78#define _LIBCXXABI_COMPILER_GCC
79#endif
8062
8163#if __has_attribute(__no_sanitize__) && defined(_LIBCXXABI_COMPILER_CLANG)
8264#define _LIBCXXABI_NO_CFI __attribute__((__no_sanitize__("cfi")))
......@@ -89,11 +71,7 @@
8971# define _LIBCXXABI_GUARD_ABI_ARM
9072#endif
9173
92#if defined(_LIBCXXABI_COMPILER_CLANG)
93# if !__has_feature(cxx_exceptions)
94# define _LIBCXXABI_NO_EXCEPTIONS
95# endif
96#elif defined(_LIBCXXABI_COMPILER_GCC) && !defined(__EXCEPTIONS)
74#if !defined(__cpp_exceptions) || __cpp_exceptions < 199711L
9775# define _LIBCXXABI_NO_EXCEPTIONS
9876#endif
9977
......@@ -103,6 +81,47 @@
10381#define _LIBCXXABI_DTOR_FUNC
10482#endif
10583
84#if __has_include(<ptrauth.h>)
85# include <ptrauth.h>
86#endif
87
88#if __has_feature(ptrauth_calls)
89
90// ptrauth_string_discriminator("__cxa_exception::actionRecord") == 0xFC91
91# define __ptrauth_cxxabi_action_record __ptrauth(ptrauth_key_process_dependent_data, 1, 0xFC91)
92
93// ptrauth_string_discriminator("__cxa_exception::languageSpecificData") == 0xE8EE
94# define __ptrauth_cxxabi_lsd __ptrauth(ptrauth_key_process_dependent_data, 1, 0xE8EE)
95
96// ptrauth_string_discriminator("__cxa_exception::catchTemp") == 0xFA58
97# define __ptrauth_cxxabi_catch_temp_disc 0xFA58
98# define __ptrauth_cxxabi_catch_temp_key ptrauth_key_process_dependent_data
99# define __ptrauth_cxxabi_catch_temp __ptrauth(__ptrauth_cxxabi_catch_temp_key, 1, __ptrauth_cxxabi_catch_temp_disc)
100
101// ptrauth_string_discriminator("__cxa_exception::adjustedPtr") == 0x99E4
102# define __ptrauth_cxxabi_adjusted_ptr __ptrauth(ptrauth_key_process_dependent_data, 1, 0x99E4)
103
104// ptrauth_string_discriminator("__cxa_exception::unexpectedHandler") == 0x99A9
105# define __ptrauth_cxxabi_unexpected_handler __ptrauth(ptrauth_key_function_pointer, 1, 0x99A9)
106
107// ptrauth_string_discriminator("__cxa_exception::terminateHandler") == 0x0886)
108# define __ptrauth_cxxabi_terminate_handler __ptrauth(ptrauth_key_function_pointer, 1, 0x886)
109
110// ptrauth_string_discriminator("__cxa_exception::exceptionDestructor") == 0xC088
111# define __ptrauth_cxxabi_exception_destructor __ptrauth(ptrauth_key_function_pointer, 1, 0xC088)
112
113#else
114
115# define __ptrauth_cxxabi_action_record
116# define __ptrauth_cxxabi_lsd
117# define __ptrauth_cxxabi_catch_temp
118# define __ptrauth_cxxabi_adjusted_ptr
119# define __ptrauth_cxxabi_unexpected_handler
120# define __ptrauth_cxxabi_terminate_handler
121# define __ptrauth_cxxabi_exception_destructor
122
123#endif
124
106125#if __cplusplus < 201103L
107126# define _LIBCXXABI_NOEXCEPT throw()
108127#else
lib/libcxxabi/src/cxa_exception.cpp+4-2
......@@ -192,7 +192,9 @@ void *__cxa_allocate_exception(size_t thrown_size) throw() {
192192 std::terminate();
193193 __cxa_exception *exception_header =
194194 static_cast<__cxa_exception *>((void *)(raw_buffer + header_offset));
195 ::memset(exception_header, 0, actual_size);
195 // We warn on memset to a non-trivially castable type. We might want to
196 // change that diagnostic to not fire on a trivially obvious zero fill.
197 ::memset(static_cast<void*>(exception_header), 0, actual_size);
196198 return thrown_object_from_cxa_exception(exception_header);
197199}
198200
......@@ -226,7 +228,7 @@ __cxa_exception* __cxa_init_primary_exception(void* object, std::type_info* tinf
226228}
227229
228230// This function shall allocate a __cxa_dependent_exception and
229// return a pointer to it. (Really to the object, not past its' end).
231// return a pointer to it. (Really to the object, not past its end).
230232// Otherwise, it will work like __cxa_allocate_exception.
231233void * __cxa_allocate_dependent_exception () {
232234 size_t actual_size = sizeof(__cxa_dependent_exception);
lib/libcxxabi/src/cxa_exception.h+16-14
......@@ -47,10 +47,10 @@ struct _LIBCXXABI_HIDDEN __cxa_exception {
4747 // In Wasm, a destructor returns its argument
4848 void *(_LIBCXXABI_DTOR_FUNC *exceptionDestructor)(void *);
4949#else
50 void (_LIBCXXABI_DTOR_FUNC *exceptionDestructor)(void *);
50 void (_LIBCXXABI_DTOR_FUNC *__ptrauth_cxxabi_exception_destructor exceptionDestructor)(void *);
5151#endif
52 std::unexpected_handler unexpectedHandler;
53 std::terminate_handler terminateHandler;
52 std::unexpected_handler __ptrauth_cxxabi_unexpected_handler unexpectedHandler;
53 std::terminate_handler __ptrauth_cxxabi_terminate_handler terminateHandler;
5454
5555 __cxa_exception *nextException;
5656
......@@ -61,10 +61,10 @@ struct _LIBCXXABI_HIDDEN __cxa_exception {
6161 int propagationCount;
6262#else
6363 int handlerSwitchValue;
64 const unsigned char *actionRecord;
65 const unsigned char *languageSpecificData;
66 void *catchTemp;
67 void *adjustedPtr;
64 const unsigned char *__ptrauth_cxxabi_action_record actionRecord;
65 const unsigned char *__ptrauth_cxxabi_lsd languageSpecificData;
66 void *__ptrauth_cxxabi_catch_temp catchTemp;
67 void *__ptrauth_cxxabi_adjusted_ptr adjustedPtr;
6868#endif
6969
7070#if !defined(__LP64__) && !defined(_WIN64) && !defined(_LIBCXXABI_ARM_EHABI)
......@@ -79,6 +79,8 @@ struct _LIBCXXABI_HIDDEN __cxa_exception {
7979// http://sourcery.mentor.com/archives/cxx-abi-dev/msg01924.html
8080// The layout of this structure MUST match the layout of __cxa_exception, with
8181// primaryException instead of referenceCount.
82// The pointer authentication schemas specified here must also match those of
83// the corresponding members in __cxa_exception.
8284struct _LIBCXXABI_HIDDEN __cxa_dependent_exception {
8385#if defined(__LP64__) || defined(_WIN64) || defined(_LIBCXXABI_ARM_EHABI)
8486 void* reserve; // padding.
......@@ -86,9 +88,9 @@ struct _LIBCXXABI_HIDDEN __cxa_dependent_exception {
8688#endif
8789
8890 std::type_info *exceptionType;
89 void (_LIBCXXABI_DTOR_FUNC *exceptionDestructor)(void *);
90 std::unexpected_handler unexpectedHandler;
91 std::terminate_handler terminateHandler;
91 void (_LIBCXXABI_DTOR_FUNC *__ptrauth_cxxabi_exception_destructor exceptionDestructor)(void *);
92 std::unexpected_handler __ptrauth_cxxabi_unexpected_handler unexpectedHandler;
93 std::terminate_handler __ptrauth_cxxabi_terminate_handler terminateHandler;
9294
9395 __cxa_exception *nextException;
9496
......@@ -99,10 +101,10 @@ struct _LIBCXXABI_HIDDEN __cxa_dependent_exception {
99101 int propagationCount;
100102#else
101103 int handlerSwitchValue;
102 const unsigned char *actionRecord;
103 const unsigned char *languageSpecificData;
104 void * catchTemp;
105 void *adjustedPtr;
104 const unsigned char *__ptrauth_cxxabi_action_record actionRecord;
105 const unsigned char *__ptrauth_cxxabi_lsd languageSpecificData;
106 void *__ptrauth_cxxabi_catch_temp catchTemp;
107 void *__ptrauth_cxxabi_adjusted_ptr adjustedPtr;
106108#endif
107109
108110#if !defined(__LP64__) && !defined(_WIN64) && !defined(_LIBCXXABI_ARM_EHABI)
lib/libcxxabi/src/cxa_personality.cpp+125-12
......@@ -20,7 +20,52 @@
2020#include "cxa_exception.h"
2121#include "cxa_handlers.h"
2222#include "private_typeinfo.h"
23#include "unwind.h"
23
24#if __has_feature(ptrauth_calls)
25
26// CXXABI depends on defintions in libunwind as pointer auth couples the
27// definitions
28# include "libunwind.h"
29
30// The actual value of the discriminators listed below is not important.
31// The derivation of the constants is only being included for the purpose
32// of maintaining a record of how they were originally produced.
33
34// ptrauth_string_discriminator("scan_results::languageSpecificData") == 0xE50D)
35# define __ptrauth_scan_results_lsd __ptrauth(ptrauth_key_process_dependent_code, 1, 0xE50D)
36
37// ptrauth_string_discriminator("scan_results::actionRecord") == 0x9823
38# define __ptrauth_scan_results_action_record __ptrauth(ptrauth_key_process_dependent_code, 1, 0x9823)
39
40// scan result is broken up as we have a manual re-sign that requires each component
41# define __ptrauth_scan_results_landingpad_key ptrauth_key_process_dependent_code
42// ptrauth_string_discriminator("scan_results::landingPad") == 0xD27C
43# define __ptrauth_scan_results_landingpad_disc 0xD27C
44# define __ptrauth_scan_results_landingpad \
45 __ptrauth(__ptrauth_scan_results_landingpad_key, 1, __ptrauth_scan_results_landingpad_disc)
46
47// `__ptrauth_restricted_intptr` is a feature of apple clang that predates
48// support for direct application of `__ptrauth` to integer types. This
49// guard is necessary to support compilation with those compiler.
50# if __has_extension(ptrauth_restricted_intptr_qualifier)
51# define __ptrauth_scan_results_landingpad_intptr \
52 __ptrauth_restricted_intptr(__ptrauth_scan_results_landingpad_key, 1, __ptrauth_scan_results_landingpad_disc)
53# else
54# define __ptrauth_scan_results_landingpad_intptr \
55 __ptrauth(__ptrauth_scan_results_landingpad_key, 1, __ptrauth_scan_results_landingpad_disc)
56# endif
57
58#else
59# define __ptrauth_scan_results_lsd
60# define __ptrauth_scan_results_action_record
61# define __ptrauth_scan_results_landingpad
62# define __ptrauth_scan_results_landingpad_intptr
63#endif
64
65// The functions defined in this file are magic functions called only by the compiler.
66#ifdef __clang__
67# pragma clang diagnostic ignored "-Wmissing-prototypes"
68#endif
2469
2570// TODO: This is a temporary workaround for libc++abi to recognize that it's being
2671// built against LLVM's libunwind. LLVM's libunwind started reporting _LIBUNWIND_VERSION
......@@ -527,12 +572,17 @@ get_thrown_object_ptr(_Unwind_Exception* unwind_exception)
527572namespace
528573{
529574
575typedef const uint8_t *__ptrauth_scan_results_lsd lsd_ptr_t;
576typedef const uint8_t *__ptrauth_scan_results_action_record action_ptr_t;
577typedef uintptr_t __ptrauth_scan_results_landingpad_intptr landing_pad_t;
578typedef void *__ptrauth_scan_results_landingpad landing_pad_ptr_t;
579
530580struct scan_results
531581{
532582 int64_t ttypeIndex; // > 0 catch handler, < 0 exception spec handler, == 0 a cleanup
533 const uint8_t* actionRecord; // Currently unused. Retained to ease future maintenance.
534 const uint8_t* languageSpecificData; // Needed only for __cxa_call_unexpected
535 uintptr_t landingPad; // null -> nothing found, else something found
583 action_ptr_t actionRecord; // Currently unused. Retained to ease future maintenance.
584 lsd_ptr_t languageSpecificData; // Needed only for __cxa_call_unexpected
585 landing_pad_t landingPad; // null -> nothing found, else something found
536586 void* adjustedPtr; // Used in cxa_exception.cpp
537587 _Unwind_Reason_Code reason; // One of _URC_FATAL_PHASE1_ERROR,
538588 // _URC_FATAL_PHASE2_ERROR,
......@@ -557,7 +607,23 @@ set_registers(_Unwind_Exception* unwind_exception, _Unwind_Context* context,
557607 reinterpret_cast<uintptr_t>(unwind_exception));
558608 _Unwind_SetGR(context, __builtin_eh_return_data_regno(1),
559609 static_cast<uintptr_t>(results.ttypeIndex));
610#if __has_feature(ptrauth_calls)
611 auto stackPointer = _Unwind_GetGR(context, UNW_REG_SP);
612 // We manually re-sign the IP as the __ptrauth qualifiers cannot
613 // express the required relationship with the destination address
614 const auto existingDiscriminator =
615 ptrauth_blend_discriminator(&results.landingPad,
616 __ptrauth_scan_results_landingpad_disc);
617 unw_word_t newIP /* opaque __ptrauth(ptrauth_key_return_address, stackPointer, 0) */ =
618 (unw_word_t)ptrauth_auth_and_resign(*(void* const*)&results.landingPad,
619 __ptrauth_scan_results_landingpad_key,
620 existingDiscriminator,
621 ptrauth_key_return_address,
622 stackPointer);
623 _Unwind_SetIP(context, newIP);
624#else
560625 _Unwind_SetIP(context, results.landingPad);
626#endif
561627}
562628
563629/*
......@@ -691,12 +757,12 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions,
691757 // The call sites are ordered in increasing value of start
692758 uintptr_t start = readEncodedPointer(&callSitePtr, callSiteEncoding);
693759 uintptr_t length = readEncodedPointer(&callSitePtr, callSiteEncoding);
694 uintptr_t landingPad = readEncodedPointer(&callSitePtr, callSiteEncoding);
760 landing_pad_t landingPad = readEncodedPointer(&callSitePtr, callSiteEncoding);
695761 uintptr_t actionEntry = readULEB128(&callSitePtr);
696762 if ((start <= ipOffset) && (ipOffset < (start + length)))
697763#else // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__
698764 // ip is 1-based index into this table
699 uintptr_t landingPad = readULEB128(&callSitePtr);
765 landing_pad_t landingPad = readULEB128(&callSitePtr);
700766 uintptr_t actionEntry = readULEB128(&callSitePtr);
701767 if (--ip == 0)
702768#endif // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__
......@@ -903,6 +969,57 @@ _UA_CLEANUP_PHASE
903969*/
904970
905971#if !defined(_LIBCXXABI_ARM_EHABI)
972
973// We use these helper functions to work around the behavior of casting between
974// integers (even those that are authenticated) and authenticated pointers.
975// Because the schemas being used are address discriminated we cannot use a
976// trivial value union to coerce the types so instead we perform the re-signing
977// manually.
978using __cxa_catch_temp_type = decltype(__cxa_exception::catchTemp);
979static inline void set_landing_pad(scan_results& results,
980 const __cxa_catch_temp_type& source) {
981#if __has_feature(ptrauth_calls)
982 const uintptr_t sourceDiscriminator =
983 ptrauth_blend_discriminator(&source, __ptrauth_cxxabi_catch_temp_disc);
984 const uintptr_t targetDiscriminator =
985 ptrauth_blend_discriminator(&results.landingPad,
986 __ptrauth_scan_results_landingpad_disc);
987 uintptr_t reauthenticatedLandingPad =
988 (uintptr_t)ptrauth_auth_and_resign(*reinterpret_cast<void* const*>(&source),
989 __ptrauth_cxxabi_catch_temp_key,
990 sourceDiscriminator,
991 __ptrauth_scan_results_landingpad_key,
992 targetDiscriminator);
993 memmove(reinterpret_cast<void *>(&results.landingPad),
994 reinterpret_cast<void *>(&reauthenticatedLandingPad),
995 sizeof(reauthenticatedLandingPad));
996#else
997 results.landingPad = reinterpret_cast<landing_pad_t>(source);
998#endif
999}
1000
1001static inline void get_landing_pad(__cxa_catch_temp_type &dest,
1002 const scan_results &results) {
1003#if __has_feature(ptrauth_calls)
1004 const uintptr_t sourceDiscriminator =
1005 ptrauth_blend_discriminator(&results.landingPad,
1006 __ptrauth_scan_results_landingpad_disc);
1007 const uintptr_t targetDiscriminator =
1008 ptrauth_blend_discriminator(&dest, __ptrauth_cxxabi_catch_temp_disc);
1009 uintptr_t reauthenticatedPointer =
1010 (uintptr_t)ptrauth_auth_and_resign(*reinterpret_cast<void* const*>(&results.landingPad),
1011 __ptrauth_scan_results_landingpad_key,
1012 sourceDiscriminator,
1013 __ptrauth_cxxabi_catch_temp_key,
1014 targetDiscriminator);
1015 memmove(reinterpret_cast<void *>(&dest),
1016 reinterpret_cast<void *>(&reauthenticatedPointer),
1017 sizeof(reauthenticatedPointer));
1018#else
1019 dest = reinterpret_cast<__cxa_catch_temp_type>(results.landingPad);
1020#endif
1021}
1022
9061023#ifdef __WASM_EXCEPTIONS__
9071024_Unwind_Reason_Code __gxx_personality_wasm0
9081025#elif defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__)
......@@ -935,8 +1052,7 @@ __gxx_personality_v0
9351052 results.ttypeIndex = exception_header->handlerSwitchValue;
9361053 results.actionRecord = exception_header->actionRecord;
9371054 results.languageSpecificData = exception_header->languageSpecificData;
938 results.landingPad =
939 reinterpret_cast<uintptr_t>(exception_header->catchTemp);
1055 set_landing_pad(results, exception_header->catchTemp);
9401056 results.adjustedPtr = exception_header->adjustedPtr;
9411057
9421058 // Jump to the handler.
......@@ -970,7 +1086,7 @@ __gxx_personality_v0
9701086 exc->handlerSwitchValue = static_cast<int>(results.ttypeIndex);
9711087 exc->actionRecord = results.actionRecord;
9721088 exc->languageSpecificData = results.languageSpecificData;
973 exc->catchTemp = reinterpret_cast<void*>(results.landingPad);
1089 get_landing_pad(exc->catchTemp, results);
9741090 exc->adjustedPtr = results.adjustedPtr;
9751091#ifdef __WASM_EXCEPTIONS__
9761092 // Wasm only uses a single phase (_UA_SEARCH_PHASE), so save the
......@@ -1009,9 +1125,6 @@ __gxx_personality_seh0(PEXCEPTION_RECORD ms_exc, void *this_frame,
10091125
10101126#else
10111127
1012extern "C" _Unwind_Reason_Code __gnu_unwind_frame(_Unwind_Exception*,
1013 _Unwind_Context*);
1014
10151128// Helper function to unwind one frame.
10161129// ARM EHABI 7.3 and 7.4: If the personality function returns _URC_CONTINUE_UNWIND, the
10171130// personality routine should update the virtual register set (VRS) according to the
lib/libcxxabi/src/cxa_thread_atexit.cpp+2-1
......@@ -106,6 +106,7 @@ namespace {
106106
107107#endif // HAVE___CXA_THREAD_ATEXIT_IMPL
108108
109#if defined(__linux__) || defined(__Fuchsia__)
109110extern "C" {
110111
111112 _LIBCXXABI_FUNC_VIS int __cxa_thread_atexit(Dtor dtor, void* obj, void* dso_symbol) throw() {
......@@ -140,6 +141,6 @@ extern "C" {
140141 }
141142#endif // HAVE___CXA_THREAD_ATEXIT_IMPL
142143 }
143
144144} // extern "C"
145#endif // defined(__linux__) || defined(__Fuchsia__)
145146} // namespace __cxxabiv1
lib/libcxxabi/src/demangle/DemangleConfig.h+4
......@@ -115,4 +115,8 @@
115115#define DEMANGLE_NAMESPACE_BEGIN namespace { namespace itanium_demangle {
116116#define DEMANGLE_NAMESPACE_END } }
117117
118// The DEMANGLE_ABI macro resolves to nothing when building libc++abi. Only
119// the llvm copy defines DEMANGLE_ABI as a visibility attribute.
120#define DEMANGLE_ABI
121
118122#endif // LIBCXXABI_DEMANGLE_DEMANGLE_CONFIG_H
lib/libcxxabi/src/demangle/ItaniumDemangle.h+9-6
......@@ -1366,7 +1366,7 @@ public:
13661366 template <typename Fn> void match(Fn F) const { F(Name, Params, Requires); }
13671367
13681368 void printLeft(OutputBuffer &OB) const override {
1369 ScopedOverride<unsigned> LT(OB.GtIsGt, 0);
1369 ScopedOverride<bool> LT(OB.TemplateTracker.InsideTemplate, true);
13701370 OB += "template<";
13711371 Params.printWithComma(OB);
13721372 OB += "> typename ";
......@@ -1550,7 +1550,7 @@ public:
15501550 NodeArray getParams() { return Params; }
15511551
15521552 void printLeft(OutputBuffer &OB) const override {
1553 ScopedOverride<unsigned> LT(OB.GtIsGt, 0);
1553 ScopedOverride<bool> LT(OB.TemplateTracker.InsideTemplate, true);
15541554 OB += "<";
15551555 Params.printWithComma(OB);
15561556 OB += ">";
......@@ -1824,7 +1824,7 @@ public:
18241824
18251825 void printDeclarator(OutputBuffer &OB) const {
18261826 if (!TemplateParams.empty()) {
1827 ScopedOverride<unsigned> LT(OB.GtIsGt, 0);
1827 ScopedOverride<bool> LT(OB.TemplateTracker.InsideTemplate, true);
18281828 OB += "<";
18291829 TemplateParams.printWithComma(OB);
18301830 OB += ">";
......@@ -1885,7 +1885,9 @@ public:
18851885 }
18861886
18871887 void printLeft(OutputBuffer &OB) const override {
1888 bool ParenAll = OB.isGtInsideTemplateArgs() &&
1888 // If we're printing a '<' inside of a template argument, and we haven't
1889 // yet parenthesized the expression, do so now.
1890 bool ParenAll = !OB.isInParensInTemplateArgs() &&
18891891 (InfixOperator == ">" || InfixOperator == ">>");
18901892 if (ParenAll)
18911893 OB.printOpen();
......@@ -2061,7 +2063,7 @@ public:
20612063 void printLeft(OutputBuffer &OB) const override {
20622064 OB += CastKind;
20632065 {
2064 ScopedOverride<unsigned> LT(OB.GtIsGt, 0);
2066 ScopedOverride<bool> LT(OB.TemplateTracker.InsideTemplate, true);
20652067 OB += "<";
20662068 OB.printLeft(*To);
20672069 OB += ">";
......@@ -3049,7 +3051,8 @@ template <typename Derived, typename Alloc> struct AbstractManglingParser {
30493051 Node *parse(bool ParseParams = true);
30503052};
30513053
3052const char* parse_discriminator(const char* first, const char* last);
3054DEMANGLE_ABI const char *parse_discriminator(const char *first,
3055 const char *last);
30533056
30543057// <name> ::= <nested-name> // N
30553058// ::= <local-name> # See Scope Encoding below // Z
lib/libcxxabi/src/demangle/Utility.h+21-7
......@@ -81,7 +81,7 @@ public:
8181 OutputBuffer(const OutputBuffer &) = delete;
8282 OutputBuffer &operator=(const OutputBuffer &) = delete;
8383
84 virtual ~OutputBuffer() {}
84 virtual ~OutputBuffer() = default;
8585
8686 operator std::string_view() const {
8787 return std::string_view(Buffer, CurrentPosition);
......@@ -104,18 +104,32 @@ public:
104104 unsigned CurrentPackIndex = std::numeric_limits<unsigned>::max();
105105 unsigned CurrentPackMax = std::numeric_limits<unsigned>::max();
106106
107 /// When zero, we're printing template args and '>' needs to be parenthesized.
108 /// Use a counter so we can simply increment inside parentheses.
109 unsigned GtIsGt = 1;
107 struct {
108 /// The depth of '(' and ')' inside the currently printed template
109 /// arguments.
110 unsigned ParenDepth = 0;
110111
111 bool isGtInsideTemplateArgs() const { return GtIsGt == 0; }
112 /// True if we're currently printing a template argument.
113 bool InsideTemplate = false;
114 } TemplateTracker;
115
116 /// Returns true if we're currently between a '(' and ')' when printing
117 /// template args.
118 bool isInParensInTemplateArgs() const {
119 return TemplateTracker.ParenDepth > 0;
120 }
121
122 /// Returns true if we're printing template args.
123 bool isInsideTemplateArgs() const { return TemplateTracker.InsideTemplate; }
112124
113125 void printOpen(char Open = '(') {
114 GtIsGt++;
126 if (isInsideTemplateArgs())
127 TemplateTracker.ParenDepth++;
115128 *this += Open;
116129 }
117130 void printClose(char Close = ')') {
118 GtIsGt--;
131 if (isInsideTemplateArgs())
132 TemplateTracker.ParenDepth--;
119133 *this += Close;
120134 }
121135
lib/libcxxabi/src/fallback_malloc.cpp+1-1
......@@ -16,7 +16,7 @@
1616#endif
1717#endif
1818
19#include <__memory/aligned_alloc.h>
19#include "include/aligned_alloc.h" // from libc++
2020#include <__assert>
2121#include <stdlib.h> // for malloc, calloc, free
2222#include <string.h> // for memset
lib/libcxxabi/src/private_typeinfo.cpp+6
......@@ -831,6 +831,10 @@ bool __pointer_to_member_type_info::can_catch_nested(
831831#pragma clang diagnostic ignored "-Wmissing-field-initializers"
832832#endif
833833
834#pragma GCC diagnostic push
835// __dynamic_cast is called by the compiler, so there is no prototype
836#pragma GCC diagnostic ignored "-Wmissing-prototypes"
837
834838// __dynamic_cast
835839
836840// static_ptr: pointer to an object of type static_type; nonnull, and since the
......@@ -953,6 +957,8 @@ __dynamic_cast(const void *static_ptr, const __class_type_info *static_type,
953957 return const_cast<void*>(dst_ptr);
954958}
955959
960#pragma GCC diagnostic pop
961
956962#ifdef __clang__
957963#pragma clang diagnostic pop
958964#endif
lib/libcxxabi/src/stdlib_new_delete.cpp+5-5
......@@ -8,8 +8,8 @@
88
99#include "__cxxabi_config.h"
1010#include "abort_message.h"
11#include "include/aligned_alloc.h" // from libc++
1112#include "include/overridable_function.h" // from libc++
12#include <__memory/aligned_alloc.h>
1313#include <cstddef>
1414#include <cstdlib>
1515#include <new>
......@@ -63,7 +63,7 @@ static void* operator_new_impl(std::size_t size) {
6363 return p;
6464}
6565
66_LIBCPP_OVERRIDABLE_FUNCTION(void*, operator new, (std::size_t size)) _THROW_BAD_ALLOC {
66OVERRIDABLE_FUNCTION void* operator new(std::size_t size) _THROW_BAD_ALLOC {
6767 void* p = operator_new_impl(size);
6868 if (p == nullptr)
6969 __throw_bad_alloc_shim();
......@@ -94,7 +94,7 @@ _LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept {
9494#endif
9595}
9696
97_LIBCPP_OVERRIDABLE_FUNCTION(void*, operator new[], (size_t size)) _THROW_BAD_ALLOC { return ::operator new(size); }
97OVERRIDABLE_FUNCTION void* operator new[](size_t size) _THROW_BAD_ALLOC { return ::operator new(size); }
9898
9999_LIBCPP_WEAK void* operator new[](size_t size, const std::nothrow_t&) noexcept {
100100#if !_LIBCPP_HAS_EXCEPTIONS
......@@ -154,7 +154,7 @@ static void* operator_new_aligned_impl(std::size_t size, std::align_val_t alignm
154154 return p;
155155}
156156
157_LIBCPP_OVERRIDABLE_FUNCTION(void*, operator new, (std::size_t size, std::align_val_t alignment)) _THROW_BAD_ALLOC {
157OVERRIDABLE_FUNCTION void* operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC {
158158 void* p = operator_new_aligned_impl(size, alignment);
159159 if (p == nullptr)
160160 __throw_bad_alloc_shim();
......@@ -185,7 +185,7 @@ _LIBCPP_WEAK void* operator new(size_t size, std::align_val_t alignment, const s
185185# endif
186186}
187187
188_LIBCPP_OVERRIDABLE_FUNCTION(void*, operator new[], (size_t size, std::align_val_t alignment)) _THROW_BAD_ALLOC {
188OVERRIDABLE_FUNCTION void* operator new[](size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC {
189189 return ::operator new(size, alignment);
190190}
191191