authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-07-16 10:35:26+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-08-30 06:36:40+02:00
loge84e9d3a01e4332ad6b7a239c74d823f283d7f8f
tree29ba7d0b697775ae0a917aa706366b2e74b314fb
parentce7339e80a11e0a8f466e779212ee328a7ddc9e5
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

libcxxabi: update to LLVM 21


5 files changed, 124 insertions(+), 70 deletions(-)

lib/libcxxabi/src/cxa_default_handlers.cpp+2-1
......@@ -9,6 +9,7 @@
99// new_handler.
1010//===----------------------------------------------------------------------===//
1111
12#include <cstdlib> // std::abort
1213#include <exception>
1314#include <new>
1415#include "abort_message.h"
......@@ -94,7 +95,7 @@ static void demangling_unexpected_handler()
9495static constexpr std::terminate_handler default_terminate_handler = demangling_terminate_handler;
9596static constexpr std::terminate_handler default_unexpected_handler = demangling_unexpected_handler;
9697#else // !LIBCXXABI_SILENT_TERMINATE
97static constexpr std::terminate_handler default_terminate_handler = ::abort;
98static constexpr std::terminate_handler default_terminate_handler = std::abort;
9899static constexpr std::terminate_handler default_unexpected_handler = std::terminate;
99100#endif // !LIBCXXABI_SILENT_TERMINATE
100101
lib/libcxxabi/src/demangle/DemangleConfig.h+8
......@@ -19,6 +19,14 @@
1919#include "../abort_message.h"
2020#endif
2121
22#ifndef _LIBCPP_LOG_HARDENING_FAILURE
23// Libc++abi does not have any functionality to log and continue, so we drop
24// error messages when we build the demangler with `observe` assertion semantic.
25// Once the layering with libc++ is improved, this could use the libc++
26// functionality to log hardening failures.
27#define _LIBCPP_LOG_HARDENING_FAILURE(message) ((void)0)
28#endif
29
2230#include <version>
2331
2432#ifdef _MSC_VER
lib/libcxxabi/src/demangle/ItaniumDemangle.h+78-54
......@@ -21,6 +21,7 @@
2121#include "Utility.h"
2222#include <algorithm>
2323#include <cctype>
24#include <cstdint>
2425#include <cstdio>
2526#include <cstdlib>
2627#include <cstring>
......@@ -38,8 +39,10 @@
3839DEMANGLE_NAMESPACE_BEGIN
3940
4041template <class T, size_t N> class PODSmallVector {
41 static_assert(std::is_trivial<T>::value,
42 "T is required to be a trivial type");
42 static_assert(std::is_trivially_copyable<T>::value,
43 "T is required to be a trivially copyable type");
44 static_assert(std::is_trivially_default_constructible<T>::value,
45 "T is required to be trivially default constructible");
4346 T *First = nullptr;
4447 T *Last = nullptr;
4548 T *Cap = nullptr;
......@@ -162,18 +165,18 @@ class NodeArray;
162165// traversed by the printLeft/Right functions to produce a demangled string.
163166class Node {
164167public:
165 enum Kind : unsigned char {
168 enum Kind : uint8_t {
166169#define NODE(NodeKind) K##NodeKind,
167170#include "ItaniumNodes.def"
168171 };
169172
170173 /// Three-way bool to track a cached value. Unknown is possible if this node
171174 /// has an unexpanded parameter pack below it that may affect this cache.
172 enum class Cache : unsigned char { Yes, No, Unknown, };
175 enum class Cache : uint8_t { Yes, No, Unknown, };
173176
174177 /// Operator precedence for expression nodes. Used to determine required
175178 /// parens in expression emission.
176 enum class Prec {
179 enum class Prec : uint8_t {
177180 Primary,
178181 Postfix,
179182 Unary,
......@@ -281,20 +284,11 @@ public:
281284 }
282285
283286 void print(OutputBuffer &OB) const {
284 printLeft(OB);
287 OB.printLeft(*this);
285288 if (RHSComponentCache != Cache::No)
286 printRight(OB);
289 OB.printRight(*this);
287290 }
288291
289 // Print the "left" side of this Node into OutputBuffer.
290 virtual void printLeft(OutputBuffer &) const = 0;
291
292 // Print the "right". This distinction is necessary to represent C++ types
293 // that appear on the RHS of their subtype, such as arrays or functions.
294 // Since most types don't have such a component, provide a default
295 // implementation.
296 virtual void printRight(OutputBuffer &) const {}
297
298292 // Print an initializer list of this type. Returns true if we printed a custom
299293 // representation, false if nothing has been printed and the default
300294 // representation should be used.
......@@ -310,6 +304,24 @@ public:
310304#ifndef NDEBUG
311305 DEMANGLE_DUMP_METHOD void dump() const;
312306#endif
307
308private:
309 friend class OutputBuffer;
310
311 // Print the "left" side of this Node into OutputBuffer.
312 //
313 // Note, should only be called from OutputBuffer implementations.
314 // Call \ref OutputBuffer::printLeft instead.
315 virtual void printLeft(OutputBuffer &) const = 0;
316
317 // Print the "right". This distinction is necessary to represent C++ types
318 // that appear on the RHS of their subtype, such as arrays or functions.
319 // Since most types don't have such a component, provide a default
320 // implementation.
321 //
322 // Note, should only be called from OutputBuffer implementations.
323 // Call \ref OutputBuffer::printRight instead.
324 virtual void printRight(OutputBuffer &) const {}
313325};
314326
315327class NodeArray {
......@@ -458,11 +470,11 @@ public:
458470 }
459471
460472 void printLeft(OutputBuffer &OB) const override {
461 Child->printLeft(OB);
473 OB.printLeft(*Child);
462474 printQuals(OB);
463475 }
464476
465 void printRight(OutputBuffer &OB) const override { Child->printRight(OB); }
477 void printRight(OutputBuffer &OB) const override { OB.printRight(*Child); }
466478};
467479
468480class ConversionOperatorType final : public Node {
......@@ -491,7 +503,7 @@ public:
491503 template<typename Fn> void match(Fn F) const { F(Ty, Postfix); }
492504
493505 void printLeft(OutputBuffer &OB) const override {
494 Ty->printLeft(OB);
506 OB.printLeft(*Ty);
495507 OB += Postfix;
496508 }
497509};
......@@ -577,7 +589,7 @@ struct AbiTagAttr : Node {
577589 std::string_view getBaseName() const override { return Base->getBaseName(); }
578590
579591 void printLeft(OutputBuffer &OB) const override {
580 Base->printLeft(OB);
592 OB.printLeft(*Base);
581593 OB += "[abi:";
582594 OB += Tag;
583595 OB += "]";
......@@ -603,8 +615,6 @@ class ObjCProtoName : public Node {
603615 const Node *Ty;
604616 std::string_view Protocol;
605617
606 friend class PointerType;
607
608618public:
609619 ObjCProtoName(const Node *Ty_, std::string_view Protocol_)
610620 : Node(KObjCProtoName), Ty(Ty_), Protocol(Protocol_) {}
......@@ -616,6 +626,8 @@ public:
616626 static_cast<const NameType *>(Ty)->getName() == "objc_object";
617627 }
618628
629 std::string_view getProtocol() const { return Protocol; }
630
619631 void printLeft(OutputBuffer &OB) const override {
620632 Ty->print(OB);
621633 OB += "<";
......@@ -644,7 +656,7 @@ public:
644656 // We rewrite objc_object<SomeProtocol>* into id<SomeProtocol>.
645657 if (Pointee->getKind() != KObjCProtoName ||
646658 !static_cast<const ObjCProtoName *>(Pointee)->isObjCObject()) {
647 Pointee->printLeft(OB);
659 OB.printLeft(*Pointee);
648660 if (Pointee->hasArray(OB))
649661 OB += " ";
650662 if (Pointee->hasArray(OB) || Pointee->hasFunction(OB))
......@@ -653,7 +665,7 @@ public:
653665 } else {
654666 const auto *objcProto = static_cast<const ObjCProtoName *>(Pointee);
655667 OB += "id<";
656 OB += objcProto->Protocol;
668 OB += objcProto->getProtocol();
657669 OB += ">";
658670 }
659671 }
......@@ -663,7 +675,7 @@ public:
663675 !static_cast<const ObjCProtoName *>(Pointee)->isObjCObject()) {
664676 if (Pointee->hasArray(OB) || Pointee->hasFunction(OB))
665677 OB += ")";
666 Pointee->printRight(OB);
678 OB.printRight(*Pointee);
667679 }
668680 }
669681};
......@@ -729,7 +741,7 @@ public:
729741 std::pair<ReferenceKind, const Node *> Collapsed = collapse(OB);
730742 if (!Collapsed.second)
731743 return;
732 Collapsed.second->printLeft(OB);
744 OB.printLeft(*Collapsed.second);
733745 if (Collapsed.second->hasArray(OB))
734746 OB += " ";
735747 if (Collapsed.second->hasArray(OB) || Collapsed.second->hasFunction(OB))
......@@ -746,7 +758,7 @@ public:
746758 return;
747759 if (Collapsed.second->hasArray(OB) || Collapsed.second->hasFunction(OB))
748760 OB += ")";
749 Collapsed.second->printRight(OB);
761 OB.printRight(*Collapsed.second);
750762 }
751763};
752764
......@@ -766,7 +778,7 @@ public:
766778 }
767779
768780 void printLeft(OutputBuffer &OB) const override {
769 MemberType->printLeft(OB);
781 OB.printLeft(*MemberType);
770782 if (MemberType->hasArray(OB) || MemberType->hasFunction(OB))
771783 OB += "(";
772784 else
......@@ -778,7 +790,7 @@ public:
778790 void printRight(OutputBuffer &OB) const override {
779791 if (MemberType->hasArray(OB) || MemberType->hasFunction(OB))
780792 OB += ")";
781 MemberType->printRight(OB);
793 OB.printRight(*MemberType);
782794 }
783795};
784796
......@@ -798,7 +810,7 @@ public:
798810 bool hasRHSComponentSlow(OutputBuffer &) const override { return true; }
799811 bool hasArraySlow(OutputBuffer &) const override { return true; }
800812
801 void printLeft(OutputBuffer &OB) const override { Base->printLeft(OB); }
813 void printLeft(OutputBuffer &OB) const override { OB.printLeft(*Base); }
802814
803815 void printRight(OutputBuffer &OB) const override {
804816 if (OB.back() != ']')
......@@ -807,7 +819,7 @@ public:
807819 if (Dimension)
808820 Dimension->print(OB);
809821 OB += "]";
810 Base->printRight(OB);
822 OB.printRight(*Base);
811823 }
812824
813825 bool printInitListAsType(OutputBuffer &OB,
......@@ -851,7 +863,7 @@ public:
851863 // by printing out the return types's left, then print our parameters, then
852864 // finally print right of the return type.
853865 void printLeft(OutputBuffer &OB) const override {
854 Ret->printLeft(OB);
866 OB.printLeft(*Ret);
855867 OB += " ";
856868 }
857869
......@@ -859,7 +871,7 @@ public:
859871 OB.printOpen();
860872 Params.printWithComma(OB);
861873 OB.printClose();
862 Ret->printRight(OB);
874 OB.printRight(*Ret);
863875
864876 if (CVQuals & QualConst)
865877 OB += " const";
......@@ -964,6 +976,8 @@ public:
964976 FunctionRefQual getRefQual() const { return RefQual; }
965977 NodeArray getParams() const { return Params; }
966978 const Node *getReturnType() const { return Ret; }
979 const Node *getAttrs() const { return Attrs; }
980 const Node *getRequires() const { return Requires; }
967981
968982 bool hasRHSComponentSlow(OutputBuffer &) const override { return true; }
969983 bool hasFunctionSlow(OutputBuffer &) const override { return true; }
......@@ -972,10 +986,11 @@ public:
972986
973987 void printLeft(OutputBuffer &OB) const override {
974988 if (Ret) {
975 Ret->printLeft(OB);
989 OB.printLeft(*Ret);
976990 if (!Ret->hasRHSComponent(OB))
977991 OB += " ";
978992 }
993
979994 Name->print(OB);
980995 }
981996
......@@ -983,8 +998,9 @@ public:
983998 OB.printOpen();
984999 Params.printWithComma(OB);
9851000 OB.printClose();
1001
9861002 if (Ret)
987 Ret->printRight(OB);
1003 OB.printRight(*Ret);
9881004
9891005 if (CVQuals & QualConst)
9901006 OB += " const";
......@@ -1324,14 +1340,14 @@ public:
13241340 template<typename Fn> void match(Fn F) const { F(Name, Type); }
13251341
13261342 void printLeft(OutputBuffer &OB) const override {
1327 Type->printLeft(OB);
1343 OB.printLeft(*Type);
13281344 if (!Type->hasRHSComponent(OB))
13291345 OB += " ";
13301346 }
13311347
13321348 void printRight(OutputBuffer &OB) const override {
13331349 Name->print(OB);
1334 Type->printRight(OB);
1350 OB.printRight(*Type);
13351351 }
13361352};
13371353
......@@ -1376,11 +1392,11 @@ public:
13761392 template<typename Fn> void match(Fn F) const { F(Param); }
13771393
13781394 void printLeft(OutputBuffer &OB) const override {
1379 Param->printLeft(OB);
1395 OB.printLeft(*Param);
13801396 OB += "...";
13811397 }
13821398
1383 void printRight(OutputBuffer &OB) const override { Param->printRight(OB); }
1399 void printRight(OutputBuffer &OB) const override { OB.printRight(*Param); }
13841400};
13851401
13861402/// An unexpanded parameter pack (either in the expression or type context). If
......@@ -1445,13 +1461,13 @@ public:
14451461 initializePackExpansion(OB);
14461462 size_t Idx = OB.CurrentPackIndex;
14471463 if (Idx < Data.size())
1448 Data[Idx]->printLeft(OB);
1464 OB.printLeft(*Data[Idx]);
14491465 }
14501466 void printRight(OutputBuffer &OB) const override {
14511467 initializePackExpansion(OB);
14521468 size_t Idx = OB.CurrentPackIndex;
14531469 if (Idx < Data.size())
1454 Data[Idx]->printRight(OB);
1470 OB.printRight(*Data[Idx]);
14551471 }
14561472};
14571473
......@@ -1609,13 +1625,13 @@ struct ForwardTemplateReference : Node {
16091625 if (Printing)
16101626 return;
16111627 ScopedOverride<bool> SavePrinting(Printing, true);
1612 Ref->printLeft(OB);
1628 OB.printLeft(*Ref);
16131629 }
16141630 void printRight(OutputBuffer &OB) const override {
16151631 if (Printing)
16161632 return;
16171633 ScopedOverride<bool> SavePrinting(Printing, true);
1618 Ref->printRight(OB);
1634 OB.printRight(*Ref);
16191635 }
16201636};
16211637
......@@ -1767,7 +1783,7 @@ public:
17671783
17681784 void printLeft(OutputBuffer &OB) const override {
17691785 OB += "~";
1770 Base->printLeft(OB);
1786 OB.printLeft(*Base);
17711787 }
17721788};
17731789
......@@ -2047,7 +2063,7 @@ public:
20472063 {
20482064 ScopedOverride<unsigned> LT(OB.GtIsGt, 0);
20492065 OB += "<";
2050 To->printLeft(OB);
2066 OB.printLeft(*To);
20512067 OB += ">";
20522068 }
20532069 OB.printOpen();
......@@ -3406,7 +3422,7 @@ const typename AbstractManglingParser<
34063422 {"or", OperatorInfo::Binary, false, Node::Prec::Ior, "operator|"},
34073423 {"pL", OperatorInfo::Binary, false, Node::Prec::Assign, "operator+="},
34083424 {"pl", OperatorInfo::Binary, false, Node::Prec::Additive, "operator+"},
3409 {"pm", OperatorInfo::Member, /*Named*/ false, Node::Prec::PtrMem,
3425 {"pm", OperatorInfo::Member, /*Named*/ true, Node::Prec::PtrMem,
34103426 "operator->*"},
34113427 {"pp", OperatorInfo::Postfix, false, Node::Prec::Postfix, "operator++"},
34123428 {"ps", OperatorInfo::Prefix, false, Node::Prec::Unary, "operator+"},
......@@ -4452,7 +4468,9 @@ Node *AbstractManglingParser<Derived, Alloc>::parseType() {
44524468 return nullptr;
44534469 if (!consumeIf('_'))
44544470 return nullptr;
4455 return make<BitIntType>(Size, Signed);
4471 // The front end expects this to be available for Substitution
4472 Result = make<BitIntType>(Size, Signed);
4473 break;
44564474 }
44574475 // ::= Di # char32_t
44584476 case 'i':
......@@ -5739,14 +5757,16 @@ struct FloatData<double>
57395757template <>
57405758struct FloatData<long double>
57415759{
5742#if defined(__mips__) && defined(__mips_n64) || defined(__aarch64__) || \
5743 defined(__wasm__) || defined(__riscv) || defined(__loongarch__) || \
5744 defined(__ve__)
5745 static const size_t mangled_size = 32;
5746#elif defined(__arm__) || defined(__mips__) || defined(__hexagon__)
5747 static const size_t mangled_size = 16;
5760#if __LDBL_MANT_DIG__ == 113 || __LDBL_MANT_DIG__ == 106
5761 static const size_t mangled_size = 32;
5762#elif __LDBL_MANT_DIG__ == 53 || defined(_MSC_VER)
5763 // MSVC doesn't define __LDBL_MANT_DIG__, but it has long double equal to
5764 // regular double on all current architectures.
5765 static const size_t mangled_size = 16;
5766#elif __LDBL_MANT_DIG__ == 64
5767 static const size_t mangled_size = 20;
57485768#else
5749 static const size_t mangled_size = 20; // May need to be adjusted to 16 or 24 on other platforms
5769#error Unknown size for __LDBL_MANT_DIG__
57505770#endif
57515771 // `-0x1.ffffffffffffffffffffffffffffp+16383` + 'L' + '\0' == 42 bytes.
57525772 // 28 'f's * 4 bits == 112 bits, which is the number of mantissa bits.
......@@ -6176,6 +6196,10 @@ struct ManglingParser : AbstractManglingParser<ManglingParser<Alloc>, Alloc> {
61766196 Alloc>::AbstractManglingParser;
61776197};
61786198
6199inline void OutputBuffer::printLeft(const Node &N) { N.printLeft(*this); }
6200
6201inline void OutputBuffer::printRight(const Node &N) { N.printRight(*this); }
6202
61796203DEMANGLE_NAMESPACE_END
61806204
61816205#if defined(__clang__)
lib/libcxxabi/src/demangle/Utility.h+27-1
......@@ -27,6 +27,8 @@
2727
2828DEMANGLE_NAMESPACE_BEGIN
2929
30class Node;
31
3032// Stream that AST nodes write their string representation into after the AST
3133// has been parsed.
3234class OutputBuffer {
......@@ -79,10 +81,24 @@ public:
7981 OutputBuffer(const OutputBuffer &) = delete;
8082 OutputBuffer &operator=(const OutputBuffer &) = delete;
8183
84 virtual ~OutputBuffer() {}
85
8286 operator std::string_view() const {
8387 return std::string_view(Buffer, CurrentPosition);
8488 }
8589
90 /// Called by the demangler when printing the demangle tree. By
91 /// default calls into \c Node::print{Left|Right} but can be overriden
92 /// by clients to track additional state when printing the demangled name.
93 virtual void printLeft(const Node &N);
94 virtual void printRight(const Node &N);
95
96 /// Called when we write to this object anywhere other than the end.
97 virtual void notifyInsertion(size_t /*Position*/, size_t /*Count*/) {}
98
99 /// Called when we make the \c CurrentPosition of this object smaller.
100 virtual void notifyDeletion(size_t /*OldPos*/, size_t /*NewPos*/) {}
101
86102 /// If a ParameterPackExpansion (or similar type) is encountered, the offset
87103 /// into the pack that we're currently printing.
88104 unsigned CurrentPackIndex = std::numeric_limits<unsigned>::max();
......@@ -120,12 +136,16 @@ public:
120136
121137 OutputBuffer &prepend(std::string_view R) {
122138 size_t Size = R.size();
139 if (!Size)
140 return *this;
123141
124142 grow(Size);
125143 std::memmove(Buffer + Size, Buffer, CurrentPosition);
126144 std::memcpy(Buffer, &*R.begin(), Size);
127145 CurrentPosition += Size;
128146
147 notifyInsertion(/*Position=*/0, /*Count=*/Size);
148
129149 return *this;
130150 }
131151
......@@ -161,14 +181,20 @@ public:
161181 DEMANGLE_ASSERT(Pos <= CurrentPosition, "");
162182 if (N == 0)
163183 return;
184
164185 grow(N);
165186 std::memmove(Buffer + Pos + N, Buffer + Pos, CurrentPosition - Pos);
166187 std::memcpy(Buffer + Pos, S, N);
167188 CurrentPosition += N;
189
190 notifyInsertion(Pos, N);
168191 }
169192
170193 size_t getCurrentPosition() const { return CurrentPosition; }
171 void setCurrentPosition(size_t NewPos) { CurrentPosition = NewPos; }
194 void setCurrentPosition(size_t NewPos) {
195 notifyDeletion(CurrentPosition, NewPos);
196 CurrentPosition = NewPos;
197 }
172198
173199 char back() const {
174200 DEMANGLE_ASSERT(CurrentPosition, "");
lib/libcxxabi/src/stdlib_new_delete.cpp+9-14
......@@ -63,7 +63,7 @@ static void* operator_new_impl(std::size_t size) {
6363 return p;
6464}
6565
66_LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void* operator new(std::size_t size) _THROW_BAD_ALLOC {
66_LIBCPP_OVERRIDABLE_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();
......@@ -74,7 +74,7 @@ _LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept {
7474#if !_LIBCPP_HAS_EXCEPTIONS
7575# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION
7676 _LIBCPP_ASSERT_SHIM(
77 !std::__is_function_overridden(static_cast<void* (*)(std::size_t)>(&operator new)),
77 (!std::__is_function_overridden < void*(std::size_t), &operator new>()),
7878 "libc++ was configured with exceptions disabled and `operator new(size_t)` has been overridden, "
7979 "but `operator new(size_t, nothrow_t)` has not been overridden. This is problematic because "
8080 "`operator new(size_t, nothrow_t)` must call `operator new(size_t)`, which will terminate in case "
......@@ -94,15 +94,13 @@ _LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept {
9494#endif
9595}
9696
97_LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void* operator new[](size_t size) _THROW_BAD_ALLOC {
98 return ::operator new(size);
99}
97_LIBCPP_OVERRIDABLE_FUNCTION(void*, operator new[], (size_t size)) _THROW_BAD_ALLOC { return ::operator new(size); }
10098
10199_LIBCPP_WEAK void* operator new[](size_t size, const std::nothrow_t&) noexcept {
102100#if !_LIBCPP_HAS_EXCEPTIONS
103101# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION
104102 _LIBCPP_ASSERT_SHIM(
105 !std::__is_function_overridden(static_cast<void* (*)(std::size_t)>(&operator new[])),
103 (!std::__is_function_overridden < void*(std::size_t), &operator new[]>()),
106104 "libc++ was configured with exceptions disabled and `operator new[](size_t)` has been overridden, "
107105 "but `operator new[](size_t, nothrow_t)` has not been overridden. This is problematic because "
108106 "`operator new[](size_t, nothrow_t)` must call `operator new[](size_t)`, which will terminate in case "
......@@ -156,8 +154,7 @@ static void* operator_new_aligned_impl(std::size_t size, std::align_val_t alignm
156154 return p;
157155}
158156
159_LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void*
160operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC {
157_LIBCPP_OVERRIDABLE_FUNCTION(void*, operator new, (std::size_t size, std::align_val_t alignment)) _THROW_BAD_ALLOC {
161158 void* p = operator_new_aligned_impl(size, alignment);
162159 if (p == nullptr)
163160 __throw_bad_alloc_shim();
......@@ -168,7 +165,7 @@ _LIBCPP_WEAK void* operator new(size_t size, std::align_val_t alignment, const s
168165# if !_LIBCPP_HAS_EXCEPTIONS
169166# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION
170167 _LIBCPP_ASSERT_SHIM(
171 !std::__is_function_overridden(static_cast<void* (*)(std::size_t, std::align_val_t)>(&operator new)),
168 (!std::__is_function_overridden < void*(std::size_t, std::align_val_t), &operator new>()),
172169 "libc++ was configured with exceptions disabled and `operator new(size_t, align_val_t)` has been overridden, "
173170 "but `operator new(size_t, align_val_t, nothrow_t)` has not been overridden. This is problematic because "
174171 "`operator new(size_t, align_val_t, nothrow_t)` must call `operator new(size_t, align_val_t)`, which will "
......@@ -188,8 +185,7 @@ _LIBCPP_WEAK void* operator new(size_t size, std::align_val_t alignment, const s
188185# endif
189186}
190187
191_LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void*
192operator new[](size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC {
188_LIBCPP_OVERRIDABLE_FUNCTION(void*, operator new[], (size_t size, std::align_val_t alignment)) _THROW_BAD_ALLOC {
193189 return ::operator new(size, alignment);
194190}
195191
......@@ -197,14 +193,13 @@ _LIBCPP_WEAK void* operator new[](size_t size, std::align_val_t alignment, const
197193# if !_LIBCPP_HAS_EXCEPTIONS
198194# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION
199195 _LIBCPP_ASSERT_SHIM(
200 !std::__is_function_overridden(static_cast<void* (*)(std::size_t, std::align_val_t)>(&operator new[])),
196 (!std::__is_function_overridden < void*(std::size_t, std::align_val_t), &operator new[]>()),
201197 "libc++ was configured with exceptions disabled and `operator new[](size_t, align_val_t)` has been overridden, "
202198 "but `operator new[](size_t, align_val_t, nothrow_t)` has not been overridden. This is problematic because "
203199 "`operator new[](size_t, align_val_t, nothrow_t)` must call `operator new[](size_t, align_val_t)`, which will "
204200 "terminate in case it fails to allocate, making it impossible for `operator new[](size_t, align_val_t, "
205201 "nothrow_t)` to fulfill its contract (since it should return nullptr upon failure). Please make sure you "
206 "override "
207 "`operator new[](size_t, align_val_t, nothrow_t)` as well.");
202 "override `operator new[](size_t, align_val_t, nothrow_t)` as well.");
208203# endif
209204
210205 return operator_new_aligned_impl(size, alignment);