authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-02-05 10:31:16+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-04-04 06:08:09+02:00
log7ab01c9a42fa0262d67d9ff1a0ecde24fb7031e7
treeac7e366fc073b59ac1707421b998797e3d002c93
parenta89b3432563c20b344bdf3f5ec686021e7de5e23
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

libcxxabi: Update to Clang 20.


18 files changed, 344 insertions(+), 124 deletions(-)

lib/libcxxabi/include/__cxxabi_config.h+6
...@@ -103,4 +103,10 @@...@@ -103,4 +103,10 @@
103#define _LIBCXXABI_DTOR_FUNC103#define _LIBCXXABI_DTOR_FUNC
104#endif104#endif
105105
106#if __cplusplus < 201103L
107# define _LIBCXXABI_NOEXCEPT throw()
108#else
109# define _LIBCXXABI_NOEXCEPT noexcept
110#endif
111
106#endif // ____CXXABI_CONFIG_H112#endif // ____CXXABI_CONFIG_H
lib/libcxxabi/include/cxxabi.h+14-14
...@@ -43,16 +43,16 @@ extern "C" {...@@ -43,16 +43,16 @@ extern "C" {
4343
44// 2.4.2 Allocating the Exception Object44// 2.4.2 Allocating the Exception Object
45extern _LIBCXXABI_FUNC_VIS void *45extern _LIBCXXABI_FUNC_VIS void *
46__cxa_allocate_exception(size_t thrown_size) throw();46__cxa_allocate_exception(size_t thrown_size) _LIBCXXABI_NOEXCEPT;
47extern _LIBCXXABI_FUNC_VIS void47extern _LIBCXXABI_FUNC_VIS void
48__cxa_free_exception(void *thrown_exception) throw();48__cxa_free_exception(void *thrown_exception) _LIBCXXABI_NOEXCEPT;
49// This function is an LLVM extension, which mirrors the same extension in libsupc++ and libcxxrt49// This function is an LLVM extension, which mirrors the same extension in libsupc++ and libcxxrt
50extern _LIBCXXABI_FUNC_VIS __cxa_exception*50extern _LIBCXXABI_FUNC_VIS __cxa_exception*
51#ifdef __wasm__51#ifdef __wasm__
52// In Wasm, a destructor returns its argument52// In Wasm, a destructor returns its argument
53__cxa_init_primary_exception(void* object, std::type_info* tinfo, void*(_LIBCXXABI_DTOR_FUNC* dest)(void*)) throw();53__cxa_init_primary_exception(void* object, std::type_info* tinfo, void*(_LIBCXXABI_DTOR_FUNC* dest)(void*)) _LIBCXXABI_NOEXCEPT;
54#else54#else
55__cxa_init_primary_exception(void* object, std::type_info* tinfo, void(_LIBCXXABI_DTOR_FUNC* dest)(void*)) throw();55__cxa_init_primary_exception(void* object, std::type_info* tinfo, void(_LIBCXXABI_DTOR_FUNC* dest)(void*)) _LIBCXXABI_NOEXCEPT;
56#endif56#endif
5757
58// 2.4.3 Throwing the Exception Object58// 2.4.3 Throwing the Exception Object
...@@ -66,13 +66,13 @@ __cxa_throw(void *thrown_exception, std::type_info *tinfo,...@@ -66,13 +66,13 @@ __cxa_throw(void *thrown_exception, std::type_info *tinfo,
6666
67// 2.5.3 Exception Handlers67// 2.5.3 Exception Handlers
68extern _LIBCXXABI_FUNC_VIS void *68extern _LIBCXXABI_FUNC_VIS void *
69__cxa_get_exception_ptr(void *exceptionObject) throw();69__cxa_get_exception_ptr(void *exceptionObject) _LIBCXXABI_NOEXCEPT;
70extern _LIBCXXABI_FUNC_VIS void *70extern _LIBCXXABI_FUNC_VIS void *
71__cxa_begin_catch(void *exceptionObject) throw();71__cxa_begin_catch(void *exceptionObject) _LIBCXXABI_NOEXCEPT;
72extern _LIBCXXABI_FUNC_VIS void __cxa_end_catch();72extern _LIBCXXABI_FUNC_VIS void __cxa_end_catch();
73#if defined(_LIBCXXABI_ARM_EHABI)73#if defined(_LIBCXXABI_ARM_EHABI)
74extern _LIBCXXABI_FUNC_VIS bool74extern _LIBCXXABI_FUNC_VIS bool
75__cxa_begin_cleanup(void *exceptionObject) throw();75__cxa_begin_cleanup(void *exceptionObject) _LIBCXXABI_NOEXCEPT;
76extern _LIBCXXABI_FUNC_VIS void __cxa_end_cleanup();76extern _LIBCXXABI_FUNC_VIS void __cxa_end_cleanup();
77#endif77#endif
78extern _LIBCXXABI_FUNC_VIS std::type_info *__cxa_current_exception_type();78extern _LIBCXXABI_FUNC_VIS std::type_info *__cxa_current_exception_type();
...@@ -80,7 +80,7 @@ extern _LIBCXXABI_FUNC_VIS std::type_info *__cxa_current_exception_type();...@@ -80,7 +80,7 @@ extern _LIBCXXABI_FUNC_VIS std::type_info *__cxa_current_exception_type();
80// GNU extension80// GNU extension
81// Calls `terminate` with the current exception being caught. This function is used by GCC when a `noexcept` function81// Calls `terminate` with the current exception being caught. This function is used by GCC when a `noexcept` function
82// throws an exception inside a try/catch block and doesn't catch it.82// throws an exception inside a try/catch block and doesn't catch it.
83extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_call_terminate(void*) throw();83extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_call_terminate(void*) _LIBCXXABI_NOEXCEPT;
8484
85// 2.5.4 Rethrowing Exceptions85// 2.5.4 Rethrowing Exceptions
86extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_rethrow();86extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_rethrow();
...@@ -168,23 +168,23 @@ extern _LIBCXXABI_FUNC_VIS char *__cxa_demangle(const char *mangled_name,...@@ -168,23 +168,23 @@ extern _LIBCXXABI_FUNC_VIS char *__cxa_demangle(const char *mangled_name,
168168
169// Apple additions to support C++ 0x exception_ptr class169// Apple additions to support C++ 0x exception_ptr class
170// These are primitives to wrap a smart pointer around an exception object170// These are primitives to wrap a smart pointer around an exception object
171extern _LIBCXXABI_FUNC_VIS void *__cxa_current_primary_exception() throw();171extern _LIBCXXABI_FUNC_VIS void *__cxa_current_primary_exception() _LIBCXXABI_NOEXCEPT;
172extern _LIBCXXABI_FUNC_VIS void172extern _LIBCXXABI_FUNC_VIS void
173__cxa_rethrow_primary_exception(void *primary_exception);173__cxa_rethrow_primary_exception(void *primary_exception);
174extern _LIBCXXABI_FUNC_VIS void174extern _LIBCXXABI_FUNC_VIS void
175__cxa_increment_exception_refcount(void *primary_exception) throw();175__cxa_increment_exception_refcount(void *primary_exception) _LIBCXXABI_NOEXCEPT;
176extern _LIBCXXABI_FUNC_VIS void176extern _LIBCXXABI_FUNC_VIS void
177__cxa_decrement_exception_refcount(void *primary_exception) throw();177__cxa_decrement_exception_refcount(void *primary_exception) _LIBCXXABI_NOEXCEPT;
178178
179// Apple extension to support std::uncaught_exception()179// Apple extension to support std::uncaught_exception()
180extern _LIBCXXABI_FUNC_VIS bool __cxa_uncaught_exception() throw();180extern _LIBCXXABI_FUNC_VIS bool __cxa_uncaught_exception() _LIBCXXABI_NOEXCEPT;
181extern _LIBCXXABI_FUNC_VIS unsigned int __cxa_uncaught_exceptions() throw();181extern _LIBCXXABI_FUNC_VIS unsigned int __cxa_uncaught_exceptions() _LIBCXXABI_NOEXCEPT;
182182
183#if defined(__linux__) || defined(__Fuchsia__)183#if defined(__linux__) || defined(__Fuchsia__)
184// Linux and Fuchsia TLS support. Not yet an official part of the Itanium ABI.184// Linux and Fuchsia TLS support. Not yet an official part of the Itanium ABI.
185// https://sourceware.org/glibc/wiki/Destructor%20support%20for%20thread_local%20variables185// https://sourceware.org/glibc/wiki/Destructor%20support%20for%20thread_local%20variables
186extern _LIBCXXABI_FUNC_VIS int __cxa_thread_atexit(void (*)(void *), void *,186extern _LIBCXXABI_FUNC_VIS int __cxa_thread_atexit(void (*)(void *), void *,
187 void *) throw();187 void *) _LIBCXXABI_NOEXCEPT;
188#endif188#endif
189189
190} // extern "C"190} // extern "C"
lib/libcxxabi/src/abort_message.cpp+3-15
...@@ -12,13 +12,8 @@...@@ -12,13 +12,8 @@
12#include "abort_message.h"12#include "abort_message.h"
1313
14#ifdef __BIONIC__14#ifdef __BIONIC__
15# include <android/api-level.h>15# include <syslog.h>
16# if __ANDROID_API__ >= 2116extern "C" void android_set_abort_message(const char* msg);
17# include <syslog.h>
18 extern "C" void android_set_abort_message(const char* msg);
19# else
20# include <assert.h>
21# endif // __ANDROID_API__ >= 21
22#endif // __BIONIC__17#endif // __BIONIC__
2318
24#if defined(__APPLE__) && __has_include(<CrashReporterClient.h>)19#if defined(__APPLE__) && __has_include(<CrashReporterClient.h>)
...@@ -26,7 +21,7 @@...@@ -26,7 +21,7 @@
26# define _LIBCXXABI_USE_CRASHREPORTER_CLIENT21# define _LIBCXXABI_USE_CRASHREPORTER_CLIENT
27#endif22#endif
2823
29void abort_message(const char* format, ...)24void __abort_message(const char* format, ...)
30{25{
31 // Write message to stderr. We do this before formatting into a26 // Write message to stderr. We do this before formatting into a
32 // variable-size buffer so that we still get some information if27 // variable-size buffer so that we still get some information if
...@@ -59,7 +54,6 @@ void abort_message(const char* format, ...)...@@ -59,7 +54,6 @@ void abort_message(const char* format, ...)
59 vasprintf(&buffer, format, list);54 vasprintf(&buffer, format, list);
60 va_end(list);55 va_end(list);
6156
62# if __ANDROID_API__ >= 21
63 // Show error in tombstone.57 // Show error in tombstone.
64 android_set_abort_message(buffer);58 android_set_abort_message(buffer);
6559
...@@ -67,12 +61,6 @@ void abort_message(const char* format, ...)...@@ -67,12 +61,6 @@ void abort_message(const char* format, ...)
67 openlog("libc++abi", 0, 0);61 openlog("libc++abi", 0, 0);
68 syslog(LOG_CRIT, "%s", buffer);62 syslog(LOG_CRIT, "%s", buffer);
69 closelog();63 closelog();
70# else
71 // The good error reporting wasn't available in Android until L. Since we're
72 // about to abort anyway, just call __assert2, which will log _somewhere_
73 // (tombstone and/or logcat) in older releases.
74 __assert2(__FILE__, __LINE__, __func__, buffer);
75# endif // __ANDROID_API__ >= 21
76#endif // __BIONIC__64#endif // __BIONIC__
7765
78 abort();66 abort();
lib/libcxxabi/src/abort_message.h+2-2
...@@ -12,7 +12,7 @@...@@ -12,7 +12,7 @@
12#include "cxxabi.h"12#include "cxxabi.h"
1313
14extern "C" _LIBCXXABI_HIDDEN _LIBCXXABI_NORETURN void14extern "C" _LIBCXXABI_HIDDEN _LIBCXXABI_NORETURN void
15abort_message(const char *format, ...) __attribute__((format(printf, 1, 2)));15__abort_message(const char *format, ...) __attribute__((format(printf, 1, 2)));
1616
17#ifndef _LIBCXXABI_ASSERT17#ifndef _LIBCXXABI_ASSERT
18// zig patch: respect NDEBUG. Otherwise the file path makes it into the binary,18// zig patch: respect NDEBUG. Otherwise the file path makes it into the binary,
...@@ -24,7 +24,7 @@ abort_message(const char *format, ...) __attribute__((format(printf, 1, 2)));...@@ -24,7 +24,7 @@ abort_message(const char *format, ...) __attribute__((format(printf, 1, 2)));
24 do { \24 do { \
25 if (!(expr)) { \25 if (!(expr)) { \
26 char const* __msg = (msg); \26 char const* __msg = (msg); \
27 ::abort_message("%s:%d: %s", __FILE__, __LINE__, __msg); \27 ::__abort_message("%s:%d: %s", __FILE__, __LINE__, __msg); \
28 } \28 } \
29 } while (false)29 } while (false)
3030
lib/libcxxabi/src/cxa_default_handlers.cpp+19-20
...@@ -10,8 +10,7 @@...@@ -10,8 +10,7 @@
10//===----------------------------------------------------------------------===//10//===----------------------------------------------------------------------===//
1111
12#include <exception>12#include <exception>
13#include <memory>13#include <new>
14#include <stdlib.h>
15#include "abort_message.h"14#include "abort_message.h"
16#include "cxxabi.h"15#include "cxxabi.h"
17#include "cxa_handlers.h"16#include "cxa_handlers.h"
...@@ -23,17 +22,7 @@...@@ -23,17 +22,7 @@
2322
24static constinit const char* cause = "uncaught";23static constinit const char* cause = "uncaught";
2524
26#ifndef _LIBCXXABI_NO_EXCEPTIONS25# ifndef _LIBCXXABI_NO_EXCEPTIONS
27// Demangle the given string, or return the string as-is in case of an error.
28static std::unique_ptr<char const, void (*)(char const*)> demangle(char const* str)
29{
30#if !defined(LIBCXXABI_NON_DEMANGLING_TERMINATE)
31 if (const char* result = __cxxabiv1::__cxa_demangle(str, nullptr, nullptr, nullptr))
32 return {result, [](char const* p) { std::free(const_cast<char*>(p)); }};
33#endif
34 return {str, [](char const*) { /* nothing to free */ }};
35}
36
37__attribute__((noreturn))26__attribute__((noreturn))
38static void demangling_terminate_handler()27static void demangling_terminate_handler()
39{28{
...@@ -42,18 +31,18 @@ static void demangling_terminate_handler()...@@ -42,18 +31,18 @@ static void demangling_terminate_handler()
4231
43 // If there is no uncaught exception, just note that we're terminating32 // If there is no uncaught exception, just note that we're terminating
44 if (!globals)33 if (!globals)
45 abort_message("terminating");34 __abort_message("terminating");
4635
47 __cxa_exception* exception_header = globals->caughtExceptions;36 __cxa_exception* exception_header = globals->caughtExceptions;
48 if (!exception_header)37 if (!exception_header)
49 abort_message("terminating");38 __abort_message("terminating");
5039
51 _Unwind_Exception* unwind_exception =40 _Unwind_Exception* unwind_exception =
52 reinterpret_cast<_Unwind_Exception*>(exception_header + 1) - 1;41 reinterpret_cast<_Unwind_Exception*>(exception_header + 1) - 1;
5342
54 // If we're terminating due to a foreign exception43 // If we're terminating due to a foreign exception
55 if (!__isOurExceptionClass(unwind_exception))44 if (!__isOurExceptionClass(unwind_exception))
56 abort_message("terminating due to %s foreign exception", cause);45 __abort_message("terminating due to %s foreign exception", cause);
5746
58 void* thrown_object =47 void* thrown_object =
59 __getExceptionClass(unwind_exception) == kOurDependentExceptionClass ?48 __getExceptionClass(unwind_exception) == kOurDependentExceptionClass ?
...@@ -61,7 +50,17 @@ static void demangling_terminate_handler()...@@ -61,7 +50,17 @@ static void demangling_terminate_handler()
61 exception_header + 1;50 exception_header + 1;
62 const __shim_type_info* thrown_type =51 const __shim_type_info* thrown_type =
63 static_cast<const __shim_type_info*>(exception_header->exceptionType);52 static_cast<const __shim_type_info*>(exception_header->exceptionType);
64 auto name = demangle(thrown_type->name());53
54 auto name = [str = thrown_type->name()] {
55# ifndef LIBCXXABI_NON_DEMANGLING_TERMINATE
56 if (const char* result = __cxxabiv1::__cxa_demangle(str, nullptr, nullptr, nullptr))
57 // We're about to abort(), this memory can never be freed; so it's fine
58 // to just return a raw pointer
59 return result;
60# endif
61 return str;
62 }();
63
65 // If the uncaught exception can be caught with std::exception&64 // If the uncaught exception can be caught with std::exception&
66 const __shim_type_info* catch_type =65 const __shim_type_info* catch_type =
67 static_cast<const __shim_type_info*>(&typeid(std::exception));66 static_cast<const __shim_type_info*>(&typeid(std::exception));
...@@ -69,19 +68,19 @@ static void demangling_terminate_handler()...@@ -69,19 +68,19 @@ static void demangling_terminate_handler()
69 {68 {
70 // Include the what() message from the exception69 // Include the what() message from the exception
71 const std::exception* e = static_cast<const std::exception*>(thrown_object);70 const std::exception* e = static_cast<const std::exception*>(thrown_object);
72 abort_message("terminating due to %s exception of type %s: %s", cause, name.get(), e->what());71 __abort_message("terminating due to %s exception of type %s: %s", cause, name, e->what());
73 }72 }
74 else73 else
75 {74 {
76 // Else just note that we're terminating due to an exception75 // Else just note that we're terminating due to an exception
77 abort_message("terminating due to %s exception of type %s", cause, name.get());76 __abort_message("terminating due to %s exception of type %s", cause, name);
78 }77 }
79}78}
80#else // !_LIBCXXABI_NO_EXCEPTIONS79#else // !_LIBCXXABI_NO_EXCEPTIONS
81__attribute__((noreturn))80__attribute__((noreturn))
82static void demangling_terminate_handler()81static void demangling_terminate_handler()
83{82{
84 abort_message("terminating");83 __abort_message("terminating");
85}84}
86#endif // !_LIBCXXABI_NO_EXCEPTIONS85#endif // !_LIBCXXABI_NO_EXCEPTIONS
8786
lib/libcxxabi/src/cxa_demangle.cpp-4
...@@ -28,10 +28,6 @@...@@ -28,10 +28,6 @@
2828
29using namespace itanium_demangle;29using namespace itanium_demangle;
3030
31constexpr const char *itanium_demangle::FloatData<float>::spec;
32constexpr const char *itanium_demangle::FloatData<double>::spec;
33constexpr const char *itanium_demangle::FloatData<long double>::spec;
34
35// <discriminator> := _ <non-negative number> # when number < 1031// <discriminator> := _ <non-negative number> # when number < 10
36// := __ <non-negative number> _ # when number >= 1032// := __ <non-negative number> _ # when number >= 10
37// extension := decimal-digit+ # at the end of string33// extension := decimal-digit+ # at the end of string
lib/libcxxabi/src/cxa_exception_storage.cpp+6-6
...@@ -56,17 +56,17 @@ extern "C" {...@@ -56,17 +56,17 @@ extern "C" {
56namespace __cxxabiv1 {56namespace __cxxabiv1 {
57namespace {57namespace {
58 std::__libcpp_tls_key key_;58 std::__libcpp_tls_key key_;
59 std::__libcpp_exec_once_flag flag_ = _LIBCPP_EXEC_ONCE_INITIALIZER;59 constinit std::__libcpp_exec_once_flag flag_ = _LIBCPP_EXEC_ONCE_INITIALIZER;
6060
61 void _LIBCPP_TLS_DESTRUCTOR_CC destruct_(void *p) {61 void _LIBCPP_TLS_DESTRUCTOR_CC destruct_(void *p) {
62 __free_with_fallback(p);62 __free_with_fallback(p);
63 if (0 != std::__libcpp_tls_set(key_, NULL))63 if (0 != std::__libcpp_tls_set(key_, NULL))
64 abort_message("cannot zero out thread value for __cxa_get_globals()");64 __abort_message("cannot zero out thread value for __cxa_get_globals()");
65 }65 }
6666
67 void construct_() {67 void construct_() {
68 if (0 != std::__libcpp_tls_create(&key_, destruct_))68 if (0 != std::__libcpp_tls_create(&key_, destruct_))
69 abort_message("cannot create thread specific key for __cxa_get_globals()");69 __abort_message("cannot create thread specific key for __cxa_get_globals()");
70 }70 }
71} // namespace71} // namespace
7272
...@@ -80,9 +80,9 @@ extern "C" {...@@ -80,9 +80,9 @@ extern "C" {
80 retVal = static_cast<__cxa_eh_globals*>(80 retVal = static_cast<__cxa_eh_globals*>(
81 __calloc_with_fallback(1, sizeof(__cxa_eh_globals)));81 __calloc_with_fallback(1, sizeof(__cxa_eh_globals)));
82 if (NULL == retVal)82 if (NULL == retVal)
83 abort_message("cannot allocate __cxa_eh_globals");83 __abort_message("cannot allocate __cxa_eh_globals");
84 if (0 != std::__libcpp_tls_set(key_, retVal))84 if (0 != std::__libcpp_tls_set(key_, retVal))
85 abort_message("std::__libcpp_tls_set failure in __cxa_get_globals()");85 __abort_message("std::__libcpp_tls_set failure in __cxa_get_globals()");
86 }86 }
87 return retVal;87 return retVal;
88 }88 }
...@@ -94,7 +94,7 @@ extern "C" {...@@ -94,7 +94,7 @@ extern "C" {
94 __cxa_eh_globals *__cxa_get_globals_fast() {94 __cxa_eh_globals *__cxa_get_globals_fast() {
95 // First time through, create the key.95 // First time through, create the key.
96 if (0 != std::__libcpp_execute_once(&flag_, construct_))96 if (0 != std::__libcpp_execute_once(&flag_, construct_))
97 abort_message("execute once failure in __cxa_get_globals_fast()");97 __abort_message("execute once failure in __cxa_get_globals_fast()");
98 return static_cast<__cxa_eh_globals*>(std::__libcpp_tls_get(key_));98 return static_cast<__cxa_eh_globals*>(std::__libcpp_tls_get(key_));
99 }99 }
100} // extern "C"100} // extern "C"
lib/libcxxabi/src/cxa_guard_impl.h+5-5
...@@ -91,7 +91,7 @@...@@ -91,7 +91,7 @@
91// the former.91// the former.
92#ifdef BUILDING_CXA_GUARD92#ifdef BUILDING_CXA_GUARD
93# include "abort_message.h"93# include "abort_message.h"
94# define ABORT_WITH_MESSAGE(...) ::abort_message(__VA_ARGS__)94# define ABORT_WITH_MESSAGE(...) ::__abort_message(__VA_ARGS__)
95#elif defined(TESTING_CXA_GUARD)95#elif defined(TESTING_CXA_GUARD)
96# define ABORT_WITH_MESSAGE(...) ::abort()96# define ABORT_WITH_MESSAGE(...) ::abort()
97#else97#else
...@@ -156,12 +156,12 @@ private:...@@ -156,12 +156,12 @@ private:
156// PlatformGetThreadID156// PlatformGetThreadID
157//===----------------------------------------------------------------------===//157//===----------------------------------------------------------------------===//
158158
159#if defined(__APPLE__) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)159#if defined(__APPLE__) && _LIBCPP_HAS_THREAD_API_PTHREAD
160uint32_t PlatformThreadID() {160uint32_t PlatformThreadID() {
161 static_assert(sizeof(mach_port_t) == sizeof(uint32_t), "");161 static_assert(sizeof(mach_port_t) == sizeof(uint32_t), "");
162 return static_cast<uint32_t>(pthread_mach_thread_np(std::__libcpp_thread_get_current_id()));162 return static_cast<uint32_t>(pthread_mach_thread_np(std::__libcpp_thread_get_current_id()));
163}163}
164#elif defined(SYS_gettid) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD)164#elif defined(SYS_gettid) && _LIBCPP_HAS_THREAD_API_PTHREAD
165uint32_t PlatformThreadID() {165uint32_t PlatformThreadID() {
166 static_assert(sizeof(pid_t) == sizeof(uint32_t), "");166 static_assert(sizeof(pid_t) == sizeof(uint32_t), "");
167 return static_cast<uint32_t>(syscall(SYS_gettid));167 return static_cast<uint32_t>(syscall(SYS_gettid));
...@@ -676,8 +676,8 @@ static_assert(CurrentImplementation != Implementation::Futex || PlatformSupports...@@ -676,8 +676,8 @@ static_assert(CurrentImplementation != Implementation::Futex || PlatformSupports
676676
677using SelectedImplementation = SelectImplementation<CurrentImplementation>::type;677using SelectedImplementation = SelectImplementation<CurrentImplementation>::type;
678678
679} // end namespace679} // namespace
680} // end namespace __cxxabiv1680} // namespace __cxxabiv1
681681
682#if defined(__clang__)682#if defined(__clang__)
683# pragma clang diagnostic pop683# pragma clang diagnostic pop
lib/libcxxabi/src/cxa_handlers.cpp+3-3
...@@ -33,7 +33,7 @@ __unexpected(unexpected_handler func)...@@ -33,7 +33,7 @@ __unexpected(unexpected_handler func)
33{33{
34 func();34 func();
35 // unexpected handler should not return35 // unexpected handler should not return
36 abort_message("unexpected_handler unexpectedly returned");36 __abort_message("unexpected_handler unexpectedly returned");
37}37}
3838
39__attribute__((noreturn))39__attribute__((noreturn))
...@@ -58,13 +58,13 @@ __terminate(terminate_handler func) noexcept...@@ -58,13 +58,13 @@ __terminate(terminate_handler func) noexcept
58#endif // _LIBCXXABI_NO_EXCEPTIONS58#endif // _LIBCXXABI_NO_EXCEPTIONS
59 func();59 func();
60 // handler should not return60 // handler should not return
61 abort_message("terminate_handler unexpectedly returned");61 __abort_message("terminate_handler unexpectedly returned");
62#ifndef _LIBCXXABI_NO_EXCEPTIONS62#ifndef _LIBCXXABI_NO_EXCEPTIONS
63 }63 }
64 catch (...)64 catch (...)
65 {65 {
66 // handler should not throw exception66 // handler should not throw exception
67 abort_message("terminate_handler unexpectedly threw an exception");67 __abort_message("terminate_handler unexpectedly threw an exception");
68 }68 }
69#endif // _LIBCXXABI_NO_EXCEPTIONS69#endif // _LIBCXXABI_NO_EXCEPTIONS
70}70}
lib/libcxxabi/src/cxa_personality.cpp+1-1
...@@ -167,7 +167,7 @@ uintptr_t readPointerHelper(const uint8_t*& p) {...@@ -167,7 +167,7 @@ uintptr_t readPointerHelper(const uint8_t*& p) {
167 return static_cast<uintptr_t>(value);167 return static_cast<uintptr_t>(value);
168}168}
169169
170} // end namespace170} // namespace
171171
172extern "C"172extern "C"
173{173{
lib/libcxxabi/src/cxa_thread_atexit.cpp+1-1
...@@ -89,7 +89,7 @@ namespace {...@@ -89,7 +89,7 @@ namespace {
89 // __cxa_thread_atexit() may be called arbitrarily late (for example, from89 // __cxa_thread_atexit() may be called arbitrarily late (for example, from
90 // global destructors or atexit() handlers).90 // global destructors or atexit() handlers).
91 if (std::__libcpp_tls_create(&dtors_key, run_dtors) != 0) {91 if (std::__libcpp_tls_create(&dtors_key, run_dtors) != 0) {
92 abort_message("std::__libcpp_tls_create() failed in __cxa_thread_atexit()");92 __abort_message("std::__libcpp_tls_create() failed in __cxa_thread_atexit()");
93 }93 }
94 }94 }
9595
lib/libcxxabi/src/cxa_vector.cpp+1-1
...@@ -121,7 +121,7 @@ void throw_bad_array_new_length() {...@@ -121,7 +121,7 @@ void throw_bad_array_new_length() {
121#ifndef _LIBCXXABI_NO_EXCEPTIONS121#ifndef _LIBCXXABI_NO_EXCEPTIONS
122 throw std::bad_array_new_length();122 throw std::bad_array_new_length();
123#else123#else
124 abort_message("__cxa_vec_new failed to allocate memory");124 __abort_message("__cxa_vec_new failed to allocate memory");
125#endif125#endif
126}126}
127127
lib/libcxxabi/src/cxa_virtual.cpp+2-2
...@@ -13,12 +13,12 @@ namespace __cxxabiv1 {...@@ -13,12 +13,12 @@ namespace __cxxabiv1 {
13extern "C" {13extern "C" {
14_LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN14_LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN
15void __cxa_pure_virtual(void) {15void __cxa_pure_virtual(void) {
16 abort_message("Pure virtual function called!");16 __abort_message("Pure virtual function called!");
17}17}
1818
19_LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN19_LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN
20void __cxa_deleted_virtual(void) {20void __cxa_deleted_virtual(void) {
21 abort_message("Deleted virtual function called!");21 __abort_message("Deleted virtual function called!");
22}22}
23} // extern "C"23} // extern "C"
24} // abi24} // abi
lib/libcxxabi/src/demangle/DemangleConfig.h+1-1
...@@ -15,7 +15,7 @@...@@ -15,7 +15,7 @@
15// build systems to override this value.15// build systems to override this value.
16// https://libcxx.llvm.org/UsingLibcxx.html#enabling-the-safe-libc-mode16// https://libcxx.llvm.org/UsingLibcxx.html#enabling-the-safe-libc-mode
17#ifndef _LIBCPP_VERBOSE_ABORT17#ifndef _LIBCPP_VERBOSE_ABORT
18#define _LIBCPP_VERBOSE_ABORT(...) abort_message(__VA_ARGS__)18#define _LIBCPP_VERBOSE_ABORT(...) __abort_message(__VA_ARGS__)
19#include "../abort_message.h"19#include "../abort_message.h"
20#endif20#endif
2121
lib/libcxxabi/src/demangle/ItaniumDemangle.h+262-32
...@@ -19,7 +19,6 @@...@@ -19,7 +19,6 @@
19#include "DemangleConfig.h"19#include "DemangleConfig.h"
20#include "StringViewExtras.h"20#include "StringViewExtras.h"
21#include "Utility.h"21#include "Utility.h"
22#include <__cxxabi_config.h>
23#include <algorithm>22#include <algorithm>
24#include <cctype>23#include <cctype>
25#include <cstdio>24#include <cstdio>
...@@ -31,7 +30,7 @@...@@ -31,7 +30,7 @@
31#include <type_traits>30#include <type_traits>
32#include <utility>31#include <utility>
3332
34#ifdef _LIBCXXABI_COMPILER_CLANG33#if defined(__clang__)
35#pragma clang diagnostic push34#pragma clang diagnostic push
36#pragma clang diagnostic ignored "-Wunused-template"35#pragma clang diagnostic ignored "-Wunused-template"
37#endif36#endif
...@@ -157,6 +156,8 @@ public:...@@ -157,6 +156,8 @@ public:
157 }156 }
158};157};
159158
159class NodeArray;
160
160// Base class of all AST nodes. The AST is built by the parser, then is161// Base class of all AST nodes. The AST is built by the parser, then is
161// traversed by the printLeft/Right functions to produce a demangled string.162// traversed by the printLeft/Right functions to produce a demangled string.
162class Node {163class Node {
...@@ -200,8 +201,7 @@ private:...@@ -200,8 +201,7 @@ private:
200201
201 Prec Precedence : 6;202 Prec Precedence : 6;
202203
203 // FIXME: Make these protected.204protected:
204public:
205 /// Tracks if this node has a component on its right side, in which case we205 /// Tracks if this node has a component on its right side, in which case we
206 /// need to call printRight.206 /// need to call printRight.
207 Cache RHSComponentCache : 2;207 Cache RHSComponentCache : 2;
...@@ -255,6 +255,9 @@ public:...@@ -255,6 +255,9 @@ public:
255 Kind getKind() const { return K; }255 Kind getKind() const { return K; }
256256
257 Prec getPrecedence() const { return Precedence; }257 Prec getPrecedence() const { return Precedence; }
258 Cache getRHSComponentCache() const { return RHSComponentCache; }
259 Cache getArrayCache() const { return ArrayCache; }
260 Cache getFunctionCache() const { return FunctionCache; }
258261
259 virtual bool hasRHSComponentSlow(OutputBuffer &) const { return false; }262 virtual bool hasRHSComponentSlow(OutputBuffer &) const { return false; }
260 virtual bool hasArraySlow(OutputBuffer &) const { return false; }263 virtual bool hasArraySlow(OutputBuffer &) const { return false; }
...@@ -292,6 +295,13 @@ public:...@@ -292,6 +295,13 @@ public:
292 // implementation.295 // implementation.
293 virtual void printRight(OutputBuffer &) const {}296 virtual void printRight(OutputBuffer &) const {}
294297
298 // Print an initializer list of this type. Returns true if we printed a custom
299 // representation, false if nothing has been printed and the default
300 // representation should be used.
301 virtual bool printInitListAsType(OutputBuffer &, const NodeArray &) const {
302 return false;
303 }
304
295 virtual std::string_view getBaseName() const { return {}; }305 virtual std::string_view getBaseName() const { return {}; }
296306
297 // Silence compiler warnings, this dtor will never be called.307 // Silence compiler warnings, this dtor will never be called.
...@@ -338,6 +348,10 @@ public:...@@ -338,6 +348,10 @@ public:
338 FirstElement = false;348 FirstElement = false;
339 }349 }
340 }350 }
351
352 // Print an array of integer literals as a string literal. Returns whether we
353 // could do so.
354 bool printAsString(OutputBuffer &OB) const;
341};355};
342356
343struct NodeArrayNode : Node {357struct NodeArrayNode : Node {
...@@ -424,8 +438,8 @@ protected:...@@ -424,8 +438,8 @@ protected:
424438
425public:439public:
426 QualType(const Node *Child_, Qualifiers Quals_)440 QualType(const Node *Child_, Qualifiers Quals_)
427 : Node(KQualType, Child_->RHSComponentCache,441 : Node(KQualType, Child_->getRHSComponentCache(), Child_->getArrayCache(),
428 Child_->ArrayCache, Child_->FunctionCache),442 Child_->getFunctionCache()),
429 Quals(Quals_), Child(Child_) {}443 Quals(Quals_), Child(Child_) {}
430444
431 Qualifiers getQuals() const { return Quals; }445 Qualifiers getQuals() const { return Quals; }
...@@ -554,8 +568,8 @@ struct AbiTagAttr : Node {...@@ -554,8 +568,8 @@ struct AbiTagAttr : Node {
554 std::string_view Tag;568 std::string_view Tag;
555569
556 AbiTagAttr(Node *Base_, std::string_view Tag_)570 AbiTagAttr(Node *Base_, std::string_view Tag_)
557 : Node(KAbiTagAttr, Base_->RHSComponentCache, Base_->ArrayCache,571 : Node(KAbiTagAttr, Base_->getRHSComponentCache(), Base_->getArrayCache(),
558 Base_->FunctionCache),572 Base_->getFunctionCache()),
559 Base(Base_), Tag(Tag_) {}573 Base(Base_), Tag(Tag_) {}
560574
561 template<typename Fn> void match(Fn F) const { F(Base, Tag); }575 template<typename Fn> void match(Fn F) const { F(Base, Tag); }
...@@ -615,7 +629,7 @@ class PointerType final : public Node {...@@ -615,7 +629,7 @@ class PointerType final : public Node {
615629
616public:630public:
617 PointerType(const Node *Pointee_)631 PointerType(const Node *Pointee_)
618 : Node(KPointerType, Pointee_->RHSComponentCache),632 : Node(KPointerType, Pointee_->getRHSComponentCache()),
619 Pointee(Pointee_) {}633 Pointee(Pointee_) {}
620634
621 const Node *getPointee() const { return Pointee; }635 const Node *getPointee() const { return Pointee; }
...@@ -699,7 +713,7 @@ class ReferenceType : public Node {...@@ -699,7 +713,7 @@ class ReferenceType : public Node {
699713
700public:714public:
701 ReferenceType(const Node *Pointee_, ReferenceKind RK_)715 ReferenceType(const Node *Pointee_, ReferenceKind RK_)
702 : Node(KReferenceType, Pointee_->RHSComponentCache),716 : Node(KReferenceType, Pointee_->getRHSComponentCache()),
703 Pointee(Pointee_), RK(RK_) {}717 Pointee(Pointee_), RK(RK_) {}
704718
705 template<typename Fn> void match(Fn F) const { F(Pointee, RK); }719 template<typename Fn> void match(Fn F) const { F(Pointee, RK); }
...@@ -742,7 +756,7 @@ class PointerToMemberType final : public Node {...@@ -742,7 +756,7 @@ class PointerToMemberType final : public Node {
742756
743public:757public:
744 PointerToMemberType(const Node *ClassType_, const Node *MemberType_)758 PointerToMemberType(const Node *ClassType_, const Node *MemberType_)
745 : Node(KPointerToMemberType, MemberType_->RHSComponentCache),759 : Node(KPointerToMemberType, MemberType_->getRHSComponentCache()),
746 ClassType(ClassType_), MemberType(MemberType_) {}760 ClassType(ClassType_), MemberType(MemberType_) {}
747761
748 template<typename Fn> void match(Fn F) const { F(ClassType, MemberType); }762 template<typename Fn> void match(Fn F) const { F(ClassType, MemberType); }
...@@ -795,6 +809,15 @@ public:...@@ -795,6 +809,15 @@ public:
795 OB += "]";809 OB += "]";
796 Base->printRight(OB);810 Base->printRight(OB);
797 }811 }
812
813 bool printInitListAsType(OutputBuffer &OB,
814 const NodeArray &Elements) const override {
815 if (Base->getKind() == KNameType &&
816 static_cast<const NameType *>(Base)->getName() == "char") {
817 return Elements.printAsString(OB);
818 }
819 return false;
820 }
798};821};
799822
800class FunctionType final : public Node {823class FunctionType final : public Node {
...@@ -1383,16 +1406,14 @@ class ParameterPack final : public Node {...@@ -1383,16 +1406,14 @@ class ParameterPack final : public Node {
1383public:1406public:
1384 ParameterPack(NodeArray Data_) : Node(KParameterPack), Data(Data_) {1407 ParameterPack(NodeArray Data_) : Node(KParameterPack), Data(Data_) {
1385 ArrayCache = FunctionCache = RHSComponentCache = Cache::Unknown;1408 ArrayCache = FunctionCache = RHSComponentCache = Cache::Unknown;
1386 if (std::all_of(Data.begin(), Data.end(), [](Node* P) {1409 if (std::all_of(Data.begin(), Data.end(),
1387 return P->ArrayCache == Cache::No;1410 [](Node *P) { return P->getArrayCache() == Cache::No; }))
1388 }))
1389 ArrayCache = Cache::No;1411 ArrayCache = Cache::No;
1390 if (std::all_of(Data.begin(), Data.end(), [](Node* P) {1412 if (std::all_of(Data.begin(), Data.end(),
1391 return P->FunctionCache == Cache::No;1413 [](Node *P) { return P->getFunctionCache() == Cache::No; }))
1392 }))
1393 FunctionCache = Cache::No;1414 FunctionCache = Cache::No;
1394 if (std::all_of(Data.begin(), Data.end(), [](Node* P) {1415 if (std::all_of(Data.begin(), Data.end(), [](Node *P) {
1395 return P->RHSComponentCache == Cache::No;1416 return P->getRHSComponentCache() == Cache::No;
1396 }))1417 }))
1397 RHSComponentCache = Cache::No;1418 RHSComponentCache = Cache::No;
1398 }1419 }
...@@ -2056,17 +2077,23 @@ public:...@@ -2056,17 +2077,23 @@ public:
2056class CallExpr : public Node {2077class CallExpr : public Node {
2057 const Node *Callee;2078 const Node *Callee;
2058 NodeArray Args;2079 NodeArray Args;
2080 bool IsParen; // (func)(args ...) ?
20592081
2060public:2082public:
2061 CallExpr(const Node *Callee_, NodeArray Args_, Prec Prec_)2083 CallExpr(const Node *Callee_, NodeArray Args_, bool IsParen_, Prec Prec_)
2062 : Node(KCallExpr, Prec_), Callee(Callee_), Args(Args_) {}2084 : Node(KCallExpr, Prec_), Callee(Callee_), Args(Args_),
2085 IsParen(IsParen_) {}
20632086
2064 template <typename Fn> void match(Fn F) const {2087 template <typename Fn> void match(Fn F) const {
2065 F(Callee, Args, getPrecedence());2088 F(Callee, Args, IsParen, getPrecedence());
2066 }2089 }
20672090
2068 void printLeft(OutputBuffer &OB) const override {2091 void printLeft(OutputBuffer &OB) const override {
2092 if (IsParen)
2093 OB.printOpen();
2069 Callee->print(OB);2094 Callee->print(OB);
2095 if (IsParen)
2096 OB.printClose();
2070 OB.printOpen();2097 OB.printOpen();
2071 Args.printWithComma(OB);2098 Args.printWithComma(OB);
2072 OB.printClose();2099 OB.printClose();
...@@ -2226,8 +2253,11 @@ public:...@@ -2226,8 +2253,11 @@ public:
2226 template<typename Fn> void match(Fn F) const { F(Ty, Inits); }2253 template<typename Fn> void match(Fn F) const { F(Ty, Inits); }
22272254
2228 void printLeft(OutputBuffer &OB) const override {2255 void printLeft(OutputBuffer &OB) const override {
2229 if (Ty)2256 if (Ty) {
2257 if (Ty->printInitListAsType(OB, Inits))
2258 return;
2230 Ty->print(OB);2259 Ty->print(OB);
2260 }
2231 OB += '{';2261 OB += '{';
2232 Inits.printWithComma(OB);2262 Inits.printWithComma(OB);
2233 OB += '}';2263 OB += '}';
...@@ -2434,6 +2464,8 @@ public:...@@ -2434,6 +2464,8 @@ public:
2434 if (Type.size() <= 3)2464 if (Type.size() <= 3)
2435 OB += Type;2465 OB += Type;
2436 }2466 }
2467
2468 std::string_view value() const { return Value; }
2437};2469};
24382470
2439class RequiresExpr : public Node {2471class RequiresExpr : public Node {
...@@ -2605,6 +2637,94 @@ template<typename NodeT> struct NodeKind;...@@ -2605,6 +2637,94 @@ template<typename NodeT> struct NodeKind;
2605 };2637 };
2606#include "ItaniumNodes.def"2638#include "ItaniumNodes.def"
26072639
2640inline bool NodeArray::printAsString(OutputBuffer &OB) const {
2641 auto StartPos = OB.getCurrentPosition();
2642 auto Fail = [&OB, StartPos] {
2643 OB.setCurrentPosition(StartPos);
2644 return false;
2645 };
2646
2647 OB += '"';
2648 bool LastWasNumericEscape = false;
2649 for (const Node *Element : *this) {
2650 if (Element->getKind() != Node::KIntegerLiteral)
2651 return Fail();
2652 int integer_value = 0;
2653 for (char c : static_cast<const IntegerLiteral *>(Element)->value()) {
2654 if (c < '0' || c > '9' || integer_value > 25)
2655 return Fail();
2656 integer_value *= 10;
2657 integer_value += c - '0';
2658 }
2659 if (integer_value > 255)
2660 return Fail();
2661
2662 // Insert a `""` to avoid accidentally extending a numeric escape.
2663 if (LastWasNumericEscape) {
2664 if ((integer_value >= '0' && integer_value <= '9') ||
2665 (integer_value >= 'a' && integer_value <= 'f') ||
2666 (integer_value >= 'A' && integer_value <= 'F')) {
2667 OB += "\"\"";
2668 }
2669 }
2670
2671 LastWasNumericEscape = false;
2672
2673 // Determine how to print this character.
2674 switch (integer_value) {
2675 case '\a':
2676 OB += "\\a";
2677 break;
2678 case '\b':
2679 OB += "\\b";
2680 break;
2681 case '\f':
2682 OB += "\\f";
2683 break;
2684 case '\n':
2685 OB += "\\n";
2686 break;
2687 case '\r':
2688 OB += "\\r";
2689 break;
2690 case '\t':
2691 OB += "\\t";
2692 break;
2693 case '\v':
2694 OB += "\\v";
2695 break;
2696
2697 case '"':
2698 OB += "\\\"";
2699 break;
2700 case '\\':
2701 OB += "\\\\";
2702 break;
2703
2704 default:
2705 // We assume that the character is ASCII, and use a numeric escape for all
2706 // remaining non-printable ASCII characters.
2707 if (integer_value < 32 || integer_value == 127) {
2708 constexpr char Hex[] = "0123456789ABCDEF";
2709 OB += '\\';
2710 if (integer_value > 7)
2711 OB += 'x';
2712 if (integer_value >= 16)
2713 OB += Hex[integer_value >> 4];
2714 OB += Hex[integer_value & 0xF];
2715 LastWasNumericEscape = true;
2716 break;
2717 }
2718
2719 // Assume all remaining characters are directly printable.
2720 OB += (char)integer_value;
2721 break;
2722 }
2723 }
2724 OB += '"';
2725 return true;
2726}
2727
2608template <typename Derived, typename Alloc> struct AbstractManglingParser {2728template <typename Derived, typename Alloc> struct AbstractManglingParser {
2609 const char *First;2729 const char *First;
2610 const char *Last;2730 const char *Last;
...@@ -2678,7 +2798,7 @@ template <typename Derived, typename Alloc> struct AbstractManglingParser {...@@ -2678,7 +2798,7 @@ template <typename Derived, typename Alloc> struct AbstractManglingParser {
26782798
2679 bool TryToParseTemplateArgs = true;2799 bool TryToParseTemplateArgs = true;
2680 bool PermitForwardTemplateReferences = false;2800 bool PermitForwardTemplateReferences = false;
2681 bool InConstraintExpr = false;2801 bool HasIncompleteTemplateParameterTracking = false;
2682 size_t ParsingLambdaParamsAtLevel = (size_t)-1;2802 size_t ParsingLambdaParamsAtLevel = (size_t)-1;
26832803
2684 unsigned NumSyntheticTemplateParameters[3] = {};2804 unsigned NumSyntheticTemplateParameters[3] = {};
...@@ -3240,9 +3360,12 @@ const typename AbstractManglingParser<...@@ -3240,9 +3360,12 @@ const typename AbstractManglingParser<
3240 "operator co_await"},3360 "operator co_await"},
3241 {"az", OperatorInfo::OfIdOp, /*Type*/ false, Node::Prec::Unary, "alignof "},3361 {"az", OperatorInfo::OfIdOp, /*Type*/ false, Node::Prec::Unary, "alignof "},
3242 {"cc", OperatorInfo::NamedCast, false, Node::Prec::Postfix, "const_cast"},3362 {"cc", OperatorInfo::NamedCast, false, Node::Prec::Postfix, "const_cast"},
3243 {"cl", OperatorInfo::Call, false, Node::Prec::Postfix, "operator()"},3363 {"cl", OperatorInfo::Call, /*Paren*/ false, Node::Prec::Postfix,
3364 "operator()"},
3244 {"cm", OperatorInfo::Binary, false, Node::Prec::Comma, "operator,"},3365 {"cm", OperatorInfo::Binary, false, Node::Prec::Comma, "operator,"},
3245 {"co", OperatorInfo::Prefix, false, Node::Prec::Unary, "operator~"},3366 {"co", OperatorInfo::Prefix, false, Node::Prec::Unary, "operator~"},
3367 {"cp", OperatorInfo::Call, /*Paren*/ true, Node::Prec::Postfix,
3368 "operator()"},
3246 {"cv", OperatorInfo::CCast, false, Node::Prec::Cast, "operator"}, // C Cast3369 {"cv", OperatorInfo::CCast, false, Node::Prec::Cast, "operator"}, // C Cast
3247 {"dV", OperatorInfo::Binary, false, Node::Prec::Assign, "operator/="},3370 {"dV", OperatorInfo::Binary, false, Node::Prec::Assign, "operator/="},
3248 {"da", OperatorInfo::Del, /*Ary*/ true, Node::Prec::Unary,3371 {"da", OperatorInfo::Del, /*Ary*/ true, Node::Prec::Unary,
...@@ -3319,7 +3442,7 @@ AbstractManglingParser<Derived, Alloc>::parseOperatorEncoding() {...@@ -3319,7 +3442,7 @@ AbstractManglingParser<Derived, Alloc>::parseOperatorEncoding() {
3319 return nullptr;3442 return nullptr;
33203443
3321 // We can't use lower_bound as that can link to symbols in the C++ library,3444 // We can't use lower_bound as that can link to symbols in the C++ library,
3322 // and this must remain independant of that.3445 // and this must remain independent of that.
3323 size_t lower = 0u, upper = NumOps - 1; // Inclusive bounds.3446 size_t lower = 0u, upper = NumOps - 1; // Inclusive bounds.
3324 while (upper != lower) {3447 while (upper != lower) {
3325 size_t middle = (upper + lower) / 2;3448 size_t middle = (upper + lower) / 2;
...@@ -4207,9 +4330,12 @@ Node *AbstractManglingParser<Derived, Alloc>::parseType() {...@@ -4207,9 +4330,12 @@ Node *AbstractManglingParser<Derived, Alloc>::parseType() {
4207 case 'h':4330 case 'h':
4208 First += 2;4331 First += 2;
4209 return make<NameType>("half");4332 return make<NameType>("half");
4210 // ::= DF <number> _ # ISO/IEC TS 18661 binary floating point (N bits)4333 // ::= DF16b # C++23 std::bfloat16_t
4334 // ::= DF <number> _ # ISO/IEC TS 18661 binary floating point (N bits)
4211 case 'F': {4335 case 'F': {
4212 First += 2;4336 First += 2;
4337 if (consumeIf("16b"))
4338 return make<NameType>("std::bfloat16_t");
4213 Node *DimensionNumber = make<NameType>(parseNumber());4339 Node *DimensionNumber = make<NameType>(parseNumber());
4214 if (!DimensionNumber)4340 if (!DimensionNumber)
4215 return nullptr;4341 return nullptr;
...@@ -4217,6 +4343,101 @@ Node *AbstractManglingParser<Derived, Alloc>::parseType() {...@@ -4217,6 +4343,101 @@ Node *AbstractManglingParser<Derived, Alloc>::parseType() {
4217 return nullptr;4343 return nullptr;
4218 return make<BinaryFPType>(DimensionNumber);4344 return make<BinaryFPType>(DimensionNumber);
4219 }4345 }
4346 // ::= [DS] DA # N1169 fixed-point [_Sat] T _Accum
4347 // ::= [DS] DR # N1169 fixed-point [_Sat] T _Frac
4348 // <fixed-point-size>
4349 // ::= s # short
4350 // ::= t # unsigned short
4351 // ::= i # plain
4352 // ::= j # unsigned
4353 // ::= l # long
4354 // ::= m # unsigned long
4355 case 'A': {
4356 char c = look(2);
4357 First += 3;
4358 switch (c) {
4359 case 's':
4360 return make<NameType>("short _Accum");
4361 case 't':
4362 return make<NameType>("unsigned short _Accum");
4363 case 'i':
4364 return make<NameType>("_Accum");
4365 case 'j':
4366 return make<NameType>("unsigned _Accum");
4367 case 'l':
4368 return make<NameType>("long _Accum");
4369 case 'm':
4370 return make<NameType>("unsigned long _Accum");
4371 default:
4372 return nullptr;
4373 }
4374 }
4375 case 'R': {
4376 char c = look(2);
4377 First += 3;
4378 switch (c) {
4379 case 's':
4380 return make<NameType>("short _Fract");
4381 case 't':
4382 return make<NameType>("unsigned short _Fract");
4383 case 'i':
4384 return make<NameType>("_Fract");
4385 case 'j':
4386 return make<NameType>("unsigned _Fract");
4387 case 'l':
4388 return make<NameType>("long _Fract");
4389 case 'm':
4390 return make<NameType>("unsigned long _Fract");
4391 default:
4392 return nullptr;
4393 }
4394 }
4395 case 'S': {
4396 First += 2;
4397 if (look() != 'D')
4398 return nullptr;
4399 if (look(1) == 'A') {
4400 char c = look(2);
4401 First += 3;
4402 switch (c) {
4403 case 's':
4404 return make<NameType>("_Sat short _Accum");
4405 case 't':
4406 return make<NameType>("_Sat unsigned short _Accum");
4407 case 'i':
4408 return make<NameType>("_Sat _Accum");
4409 case 'j':
4410 return make<NameType>("_Sat unsigned _Accum");
4411 case 'l':
4412 return make<NameType>("_Sat long _Accum");
4413 case 'm':
4414 return make<NameType>("_Sat unsigned long _Accum");
4415 default:
4416 return nullptr;
4417 }
4418 }
4419 if (look(1) == 'R') {
4420 char c = look(2);
4421 First += 3;
4422 switch (c) {
4423 case 's':
4424 return make<NameType>("_Sat short _Fract");
4425 case 't':
4426 return make<NameType>("_Sat unsigned short _Fract");
4427 case 'i':
4428 return make<NameType>("_Sat _Fract");
4429 case 'j':
4430 return make<NameType>("_Sat unsigned _Fract");
4431 case 'l':
4432 return make<NameType>("_Sat long _Fract");
4433 case 'm':
4434 return make<NameType>("_Sat unsigned long _Fract");
4435 default:
4436 return nullptr;
4437 }
4438 }
4439 return nullptr;
4440 }
4220 // ::= DB <number> _ # C23 signed _BitInt(N)4441 // ::= DB <number> _ # C23 signed _BitInt(N)
4221 // ::= DB <instantiation-dependent expression> _ # C23 signed _BitInt(N)4442 // ::= DB <instantiation-dependent expression> _ # C23 signed _BitInt(N)
4222 // ::= DU <number> _ # C23 unsigned _BitInt(N)4443 // ::= DU <number> _ # C23 unsigned _BitInt(N)
...@@ -4337,6 +4558,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseType() {...@@ -4337,6 +4558,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseType() {
4337 // parse them, take the second production.4558 // parse them, take the second production.
43384559
4339 if (TryToParseTemplateArgs && look() == 'I') {4560 if (TryToParseTemplateArgs && look() == 'I') {
4561 Subs.push_back(Result);
4340 Node *TA = getDerived().parseTemplateArgs();4562 Node *TA = getDerived().parseTemplateArgs();
4341 if (TA == nullptr)4563 if (TA == nullptr)
4342 return nullptr;4564 return nullptr;
...@@ -4819,7 +5041,8 @@ template <typename Derived, typename Alloc>...@@ -4819,7 +5041,8 @@ template <typename Derived, typename Alloc>
4819Node *AbstractManglingParser<Derived, Alloc>::parseConstraintExpr() {5041Node *AbstractManglingParser<Derived, Alloc>::parseConstraintExpr() {
4820 // Within this expression, all enclosing template parameter lists are in5042 // Within this expression, all enclosing template parameter lists are in
4821 // scope.5043 // scope.
4822 ScopedOverride<bool> SaveInConstraintExpr(InConstraintExpr, true);5044 ScopedOverride<bool> SaveIncompleteTemplateParameterTracking(
5045 HasIncompleteTemplateParameterTracking, true);
4823 return getDerived().parseExpr();5046 return getDerived().parseExpr();
4824}5047}
48255048
...@@ -4888,6 +5111,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseRequiresExpr() {...@@ -4888,6 +5111,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseRequiresExpr() {
4888// ::= <binary operator-name> <expression> <expression>5111// ::= <binary operator-name> <expression> <expression>
4889// ::= <ternary operator-name> <expression> <expression> <expression>5112// ::= <ternary operator-name> <expression> <expression> <expression>
4890// ::= cl <expression>+ E # call5113// ::= cl <expression>+ E # call
5114// ::= cp <base-unresolved-name> <expression>* E # (name) (expr-list), call that would use argument-dependent lookup but for the parentheses
4891// ::= cv <type> <expression> # conversion with one argument5115// ::= cv <type> <expression> # conversion with one argument
4892// ::= cv <type> _ <expression>* E # conversion with a different number of arguments5116// ::= cv <type> _ <expression>* E # conversion with a different number of arguments
4893// ::= [gs] nw <expression>* _ <type> E # new (expr-list) type5117// ::= [gs] nw <expression>* _ <type> E # new (expr-list) type
...@@ -5023,7 +5247,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseExpr() {...@@ -5023,7 +5247,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseExpr() {
5023 Names.push_back(E);5247 Names.push_back(E);
5024 }5248 }
5025 return make<CallExpr>(Callee, popTrailingNodeArray(ExprsBegin),5249 return make<CallExpr>(Callee, popTrailingNodeArray(ExprsBegin),
5026 Op->getPrecedence());5250 /*IsParen=*/Op->getFlag(), Op->getPrecedence());
5027 }5251 }
5028 case OperatorInfo::CCast: {5252 case OperatorInfo::CCast: {
5029 // C Cast: (type)expr5253 // C Cast: (type)expr
...@@ -5210,7 +5434,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseExpr() {...@@ -5210,7 +5434,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseExpr() {
5210 }5434 }
5211 }5435 }
5212 return make<CallExpr>(Name, popTrailingNodeArray(ExprsBegin),5436 return make<CallExpr>(Name, popTrailingNodeArray(ExprsBegin),
5213 Node::Prec::Postfix);5437 /*IsParen=*/false, Node::Prec::Postfix);
5214 }5438 }
52155439
5216 // Only unresolved names remain.5440 // Only unresolved names remain.
...@@ -5677,7 +5901,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseTemplateParam() {...@@ -5677,7 +5901,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseTemplateParam() {
5677 // substitute them all within a <constraint-expression>, so print the5901 // substitute them all within a <constraint-expression>, so print the
5678 // parameter numbering instead for now.5902 // parameter numbering instead for now.
5679 // TODO: Track all enclosing template parameters and substitute them here.5903 // TODO: Track all enclosing template parameters and substitute them here.
5680 if (InConstraintExpr) {5904 if (HasIncompleteTemplateParameterTracking) {
5681 return make<NameType>(std::string_view(Begin, First - 1 - Begin));5905 return make<NameType>(std::string_view(Begin, First - 1 - Begin));
5682 }5906 }
56835907
...@@ -5738,6 +5962,12 @@ Node *AbstractManglingParser<Derived, Alloc>::parseTemplateParamDecl(...@@ -5738,6 +5962,12 @@ Node *AbstractManglingParser<Derived, Alloc>::parseTemplateParamDecl(
5738 }5962 }
57395963
5740 if (consumeIf("Tk")) {5964 if (consumeIf("Tk")) {
5965 // We don't track enclosing template parameter levels well enough to
5966 // reliably demangle template parameter substitutions, so print an arbitrary
5967 // string in place of a parameter for now.
5968 // TODO: Track all enclosing template parameters and demangle substitutions.
5969 ScopedOverride<bool> SaveIncompleteTemplateParameterTrackingExpr(
5970 HasIncompleteTemplateParameterTracking, true);
5741 Node *Constraint = getDerived().parseName();5971 Node *Constraint = getDerived().parseName();
5742 if (!Constraint)5972 if (!Constraint)
5743 return nullptr;5973 return nullptr;
...@@ -5948,7 +6178,7 @@ struct ManglingParser : AbstractManglingParser<ManglingParser<Alloc>, Alloc> {...@@ -5948,7 +6178,7 @@ struct ManglingParser : AbstractManglingParser<ManglingParser<Alloc>, Alloc> {
59486178
5949DEMANGLE_NAMESPACE_END6179DEMANGLE_NAMESPACE_END
59506180
5951#ifdef _LIBCXXABI_COMPILER_CLANG6181#if defined(__clang__)
5952#pragma clang diagnostic pop6182#pragma clang diagnostic pop
5953#endif6183#endif
59546184
lib/libcxxabi/src/fallback_malloc.cpp+2-2
...@@ -259,7 +259,7 @@ void* __aligned_malloc_with_fallback(size_t size) {...@@ -259,7 +259,7 @@ void* __aligned_malloc_with_fallback(size_t size) {
259#if defined(_WIN32)259#if defined(_WIN32)
260 if (void* dest = std::__libcpp_aligned_alloc(alignof(__aligned_type), size))260 if (void* dest = std::__libcpp_aligned_alloc(alignof(__aligned_type), size))
261 return dest;261 return dest;
262#elif defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION)262#elif !_LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION
263 if (void* dest = ::malloc(size))263 if (void* dest = ::malloc(size))
264 return dest;264 return dest;
265#else265#else
...@@ -286,7 +286,7 @@ void __aligned_free_with_fallback(void* ptr) {...@@ -286,7 +286,7 @@ void __aligned_free_with_fallback(void* ptr) {
286 if (is_fallback_ptr(ptr))286 if (is_fallback_ptr(ptr))
287 fallback_free(ptr);287 fallback_free(ptr);
288 else {288 else {
289#if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION)289#if !_LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION
290 ::free(ptr);290 ::free(ptr);
291#else291#else
292 std::__libcpp_aligned_free(ptr);292 std::__libcpp_aligned_free(ptr);
lib/libcxxabi/src/private_typeinfo.cpp+6-5
...@@ -41,9 +41,11 @@...@@ -41,9 +41,11 @@
41// Defining _LIBCXXABI_FORGIVING_DYNAMIC_CAST does not help since can_catch() calls41// Defining _LIBCXXABI_FORGIVING_DYNAMIC_CAST does not help since can_catch() calls
42// is_equal() with use_strcmp=false so the string names are not compared.42// is_equal() with use_strcmp=false so the string names are not compared.
4343
44#include <cstdint>
45#include <cassert>44#include <cassert>
45#include <cstddef>
46#include <cstdint>
46#include <string.h>47#include <string.h>
48
47#include "abort_message.h"49#include "abort_message.h"
4850
49#ifdef _LIBCXXABI_FORGIVING_DYNAMIC_CAST51#ifdef _LIBCXXABI_FORGIVING_DYNAMIC_CAST
...@@ -589,10 +591,9 @@ __base_class_type_info::has_unambiguous_public_base(__dynamic_cast_info* info,...@@ -589,10 +591,9 @@ __base_class_type_info::has_unambiguous_public_base(__dynamic_cast_info* info,
589 // .. and reset the pointer.591 // .. and reset the pointer.
590 adjustedPtr = nullptr;592 adjustedPtr = nullptr;
591 }593 }
592 __base_type->has_unambiguous_public_base(594 __base_type->has_unambiguous_public_base(
593 info,595 info, reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(adjustedPtr) + offset_to_base),
594 static_cast<char*>(adjustedPtr) + offset_to_base,596 (__offset_flags & __public_mask) ? path_below : not_public_path);
595 (__offset_flags & __public_mask) ? path_below : not_public_path);
596}597}
597598
598void599void
lib/libcxxabi/src/stdlib_new_delete.cpp+10-10
...@@ -24,22 +24,22 @@...@@ -24,22 +24,22 @@
24# error The _LIBCPP_WEAK macro should be already defined by libc++24# error The _LIBCPP_WEAK macro should be already defined by libc++
25#endif25#endif
2626
27#if defined(_LIBCXXABI_NO_EXCEPTIONS) != defined(_LIBCPP_HAS_NO_EXCEPTIONS)27#if defined(_LIBCXXABI_NO_EXCEPTIONS) != !_LIBCPP_HAS_EXCEPTIONS
28# error libc++ and libc++abi seem to disagree on whether exceptions are enabled28# error libc++ and libc++abi seem to disagree on whether exceptions are enabled
29#endif29#endif
3030
31inline void __throw_bad_alloc_shim() {31inline void __throw_bad_alloc_shim() {
32#ifndef _LIBCPP_HAS_NO_EXCEPTIONS32#if _LIBCPP_HAS_EXCEPTIONS
33 throw std::bad_alloc();33 throw std::bad_alloc();
34#else34#else
35 abort_message("bad_alloc was thrown in -fno-exceptions mode");35 __abort_message("bad_alloc was thrown in -fno-exceptions mode");
36#endif36#endif
37}37}
3838
39#define _LIBCPP_ASSERT_SHIM(expr, str) \39#define _LIBCPP_ASSERT_SHIM(expr, str) \
40 do { \40 do { \
41 if (!expr) \41 if (!expr) \
42 abort_message(str); \42 __abort_message(str); \
43 } while (false)43 } while (false)
4444
45// ------------------ BEGIN COPY ------------------45// ------------------ BEGIN COPY ------------------
...@@ -71,7 +71,7 @@ _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void* operator new(std...@@ -71,7 +71,7 @@ _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void* operator new(std
71}71}
7272
73_LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept {73_LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept {
74#ifdef _LIBCPP_HAS_NO_EXCEPTIONS74#if !_LIBCPP_HAS_EXCEPTIONS
75# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION75# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION
76 _LIBCPP_ASSERT_SHIM(76 _LIBCPP_ASSERT_SHIM(
77 !std::__is_function_overridden(static_cast<void* (*)(std::size_t)>(&operator new)),77 !std::__is_function_overridden(static_cast<void* (*)(std::size_t)>(&operator new)),
...@@ -99,7 +99,7 @@ _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void* operator new[](s...@@ -99,7 +99,7 @@ _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void* operator new[](s
99}99}
100100
101_LIBCPP_WEAK void* operator new[](size_t size, const std::nothrow_t&) noexcept {101_LIBCPP_WEAK void* operator new[](size_t size, const std::nothrow_t&) noexcept {
102#ifdef _LIBCPP_HAS_NO_EXCEPTIONS102#if !_LIBCPP_HAS_EXCEPTIONS
103# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION103# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION
104 _LIBCPP_ASSERT_SHIM(104 _LIBCPP_ASSERT_SHIM(
105 !std::__is_function_overridden(static_cast<void* (*)(std::size_t)>(&operator new[])),105 !std::__is_function_overridden(static_cast<void* (*)(std::size_t)>(&operator new[])),
...@@ -134,7 +134,7 @@ _LIBCPP_WEAK void operator delete[](void* ptr, const std::nothrow_t&) noexcept {...@@ -134,7 +134,7 @@ _LIBCPP_WEAK void operator delete[](void* ptr, const std::nothrow_t&) noexcept {
134134
135_LIBCPP_WEAK void operator delete[](void* ptr, size_t) noexcept { ::operator delete[](ptr); }135_LIBCPP_WEAK void operator delete[](void* ptr, size_t) noexcept { ::operator delete[](ptr); }
136136
137#if !defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION)137#if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION
138138
139static void* operator_new_aligned_impl(std::size_t size, std::align_val_t alignment) {139static void* operator_new_aligned_impl(std::size_t size, std::align_val_t alignment) {
140 if (size == 0)140 if (size == 0)
...@@ -165,7 +165,7 @@ operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC {...@@ -165,7 +165,7 @@ operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC {
165}165}
166166
167_LIBCPP_WEAK void* operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept {167_LIBCPP_WEAK void* operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept {
168# ifdef _LIBCPP_HAS_NO_EXCEPTIONS168# if !_LIBCPP_HAS_EXCEPTIONS
169# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION169# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION
170 _LIBCPP_ASSERT_SHIM(170 _LIBCPP_ASSERT_SHIM(
171 !std::__is_function_overridden(static_cast<void* (*)(std::size_t, std::align_val_t)>(&operator new)),171 !std::__is_function_overridden(static_cast<void* (*)(std::size_t, std::align_val_t)>(&operator new)),
...@@ -194,7 +194,7 @@ operator new[](size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC {...@@ -194,7 +194,7 @@ operator new[](size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC {
194}194}
195195
196_LIBCPP_WEAK void* operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept {196_LIBCPP_WEAK void* operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept {
197# ifdef _LIBCPP_HAS_NO_EXCEPTIONS197# if !_LIBCPP_HAS_EXCEPTIONS
198# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION198# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION
199 _LIBCPP_ASSERT_SHIM(199 _LIBCPP_ASSERT_SHIM(
200 !std::__is_function_overridden(static_cast<void* (*)(std::size_t, std::align_val_t)>(&operator new[])),200 !std::__is_function_overridden(static_cast<void* (*)(std::size_t, std::align_val_t)>(&operator new[])),
...@@ -240,5 +240,5 @@ _LIBCPP_WEAK void operator delete[](void* ptr, size_t, std::align_val_t alignmen...@@ -240,5 +240,5 @@ _LIBCPP_WEAK void operator delete[](void* ptr, size_t, std::align_val_t alignmen
240 ::operator delete[](ptr, alignment);240 ::operator delete[](ptr, alignment);
241}241}
242242
243#endif // !_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION243#endif // _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION
244// ------------------ END COPY ------------------244// ------------------ END COPY ------------------