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 @@...@@ -9,6 +9,7 @@
9// new_handler.9// new_handler.
10//===----------------------------------------------------------------------===//10//===----------------------------------------------------------------------===//
1111
12#include <cstdlib> // std::abort
12#include <exception>13#include <exception>
13#include <new>14#include <new>
14#include "abort_message.h"15#include "abort_message.h"
...@@ -94,7 +95,7 @@ static void demangling_unexpected_handler()...@@ -94,7 +95,7 @@ static void demangling_unexpected_handler()
94static constexpr std::terminate_handler default_terminate_handler = demangling_terminate_handler;95static constexpr std::terminate_handler default_terminate_handler = demangling_terminate_handler;
95static constexpr std::terminate_handler default_unexpected_handler = demangling_unexpected_handler;96static constexpr std::terminate_handler default_unexpected_handler = demangling_unexpected_handler;
96#else // !LIBCXXABI_SILENT_TERMINATE97#else // !LIBCXXABI_SILENT_TERMINATE
97static constexpr std::terminate_handler default_terminate_handler = ::abort;98static constexpr std::terminate_handler default_terminate_handler = std::abort;
98static constexpr std::terminate_handler default_unexpected_handler = std::terminate;99static constexpr std::terminate_handler default_unexpected_handler = std::terminate;
99#endif // !LIBCXXABI_SILENT_TERMINATE100#endif // !LIBCXXABI_SILENT_TERMINATE
100101
lib/libcxxabi/src/demangle/DemangleConfig.h+8
...@@ -19,6 +19,14 @@...@@ -19,6 +19,14 @@
19#include "../abort_message.h"19#include "../abort_message.h"
20#endif20#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
22#include <version>30#include <version>
2331
24#ifdef _MSC_VER32#ifdef _MSC_VER
lib/libcxxabi/src/demangle/ItaniumDemangle.h+78-54
...@@ -21,6 +21,7 @@...@@ -21,6 +21,7 @@
21#include "Utility.h"21#include "Utility.h"
22#include <algorithm>22#include <algorithm>
23#include <cctype>23#include <cctype>
24#include <cstdint>
24#include <cstdio>25#include <cstdio>
25#include <cstdlib>26#include <cstdlib>
26#include <cstring>27#include <cstring>
...@@ -38,8 +39,10 @@...@@ -38,8 +39,10 @@
38DEMANGLE_NAMESPACE_BEGIN39DEMANGLE_NAMESPACE_BEGIN
3940
40template <class T, size_t N> class PODSmallVector {41template <class T, size_t N> class PODSmallVector {
41 static_assert(std::is_trivial<T>::value,42 static_assert(std::is_trivially_copyable<T>::value,
42 "T is required to be a trivial type");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");
43 T *First = nullptr;46 T *First = nullptr;
44 T *Last = nullptr;47 T *Last = nullptr;
45 T *Cap = nullptr;48 T *Cap = nullptr;
...@@ -162,18 +165,18 @@ class NodeArray;...@@ -162,18 +165,18 @@ class NodeArray;
162// traversed by the printLeft/Right functions to produce a demangled string.165// traversed by the printLeft/Right functions to produce a demangled string.
163class Node {166class Node {
164public:167public:
165 enum Kind : unsigned char {168 enum Kind : uint8_t {
166#define NODE(NodeKind) K##NodeKind,169#define NODE(NodeKind) K##NodeKind,
167#include "ItaniumNodes.def"170#include "ItaniumNodes.def"
168 };171 };
169172
170 /// Three-way bool to track a cached value. Unknown is possible if this node173 /// Three-way bool to track a cached value. Unknown is possible if this node
171 /// has an unexpanded parameter pack below it that may affect this cache.174 /// 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
174 /// Operator precedence for expression nodes. Used to determine required177 /// Operator precedence for expression nodes. Used to determine required
175 /// parens in expression emission.178 /// parens in expression emission.
176 enum class Prec {179 enum class Prec : uint8_t {
177 Primary,180 Primary,
178 Postfix,181 Postfix,
179 Unary,182 Unary,
...@@ -281,20 +284,11 @@ public:...@@ -281,20 +284,11 @@ public:
281 }284 }
282285
283 void print(OutputBuffer &OB) const {286 void print(OutputBuffer &OB) const {
284 printLeft(OB);287 OB.printLeft(*this);
285 if (RHSComponentCache != Cache::No)288 if (RHSComponentCache != Cache::No)
286 printRight(OB);289 OB.printRight(*this);
287 }290 }
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
298 // Print an initializer list of this type. Returns true if we printed a custom292 // Print an initializer list of this type. Returns true if we printed a custom
299 // representation, false if nothing has been printed and the default293 // representation, false if nothing has been printed and the default
300 // representation should be used.294 // representation should be used.
...@@ -310,6 +304,24 @@ public:...@@ -310,6 +304,24 @@ public:
310#ifndef NDEBUG304#ifndef NDEBUG
311 DEMANGLE_DUMP_METHOD void dump() const;305 DEMANGLE_DUMP_METHOD void dump() const;
312#endif306#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 {}
313};325};
314326
315class NodeArray {327class NodeArray {
...@@ -458,11 +470,11 @@ public:...@@ -458,11 +470,11 @@ public:
458 }470 }
459471
460 void printLeft(OutputBuffer &OB) const override {472 void printLeft(OutputBuffer &OB) const override {
461 Child->printLeft(OB);473 OB.printLeft(*Child);
462 printQuals(OB);474 printQuals(OB);
463 }475 }
464476
465 void printRight(OutputBuffer &OB) const override { Child->printRight(OB); }477 void printRight(OutputBuffer &OB) const override { OB.printRight(*Child); }
466};478};
467479
468class ConversionOperatorType final : public Node {480class ConversionOperatorType final : public Node {
...@@ -491,7 +503,7 @@ public:...@@ -491,7 +503,7 @@ public:
491 template<typename Fn> void match(Fn F) const { F(Ty, Postfix); }503 template<typename Fn> void match(Fn F) const { F(Ty, Postfix); }
492504
493 void printLeft(OutputBuffer &OB) const override {505 void printLeft(OutputBuffer &OB) const override {
494 Ty->printLeft(OB);506 OB.printLeft(*Ty);
495 OB += Postfix;507 OB += Postfix;
496 }508 }
497};509};
...@@ -577,7 +589,7 @@ struct AbiTagAttr : Node {...@@ -577,7 +589,7 @@ struct AbiTagAttr : Node {
577 std::string_view getBaseName() const override { return Base->getBaseName(); }589 std::string_view getBaseName() const override { return Base->getBaseName(); }
578590
579 void printLeft(OutputBuffer &OB) const override {591 void printLeft(OutputBuffer &OB) const override {
580 Base->printLeft(OB);592 OB.printLeft(*Base);
581 OB += "[abi:";593 OB += "[abi:";
582 OB += Tag;594 OB += Tag;
583 OB += "]";595 OB += "]";
...@@ -603,8 +615,6 @@ class ObjCProtoName : public Node {...@@ -603,8 +615,6 @@ class ObjCProtoName : public Node {
603 const Node *Ty;615 const Node *Ty;
604 std::string_view Protocol;616 std::string_view Protocol;
605617
606 friend class PointerType;
607
608public:618public:
609 ObjCProtoName(const Node *Ty_, std::string_view Protocol_)619 ObjCProtoName(const Node *Ty_, std::string_view Protocol_)
610 : Node(KObjCProtoName), Ty(Ty_), Protocol(Protocol_) {}620 : Node(KObjCProtoName), Ty(Ty_), Protocol(Protocol_) {}
...@@ -616,6 +626,8 @@ public:...@@ -616,6 +626,8 @@ public:
616 static_cast<const NameType *>(Ty)->getName() == "objc_object";626 static_cast<const NameType *>(Ty)->getName() == "objc_object";
617 }627 }
618628
629 std::string_view getProtocol() const { return Protocol; }
630
619 void printLeft(OutputBuffer &OB) const override {631 void printLeft(OutputBuffer &OB) const override {
620 Ty->print(OB);632 Ty->print(OB);
621 OB += "<";633 OB += "<";
...@@ -644,7 +656,7 @@ public:...@@ -644,7 +656,7 @@ public:
644 // We rewrite objc_object<SomeProtocol>* into id<SomeProtocol>.656 // We rewrite objc_object<SomeProtocol>* into id<SomeProtocol>.
645 if (Pointee->getKind() != KObjCProtoName ||657 if (Pointee->getKind() != KObjCProtoName ||
646 !static_cast<const ObjCProtoName *>(Pointee)->isObjCObject()) {658 !static_cast<const ObjCProtoName *>(Pointee)->isObjCObject()) {
647 Pointee->printLeft(OB);659 OB.printLeft(*Pointee);
648 if (Pointee->hasArray(OB))660 if (Pointee->hasArray(OB))
649 OB += " ";661 OB += " ";
650 if (Pointee->hasArray(OB) || Pointee->hasFunction(OB))662 if (Pointee->hasArray(OB) || Pointee->hasFunction(OB))
...@@ -653,7 +665,7 @@ public:...@@ -653,7 +665,7 @@ public:
653 } else {665 } else {
654 const auto *objcProto = static_cast<const ObjCProtoName *>(Pointee);666 const auto *objcProto = static_cast<const ObjCProtoName *>(Pointee);
655 OB += "id<";667 OB += "id<";
656 OB += objcProto->Protocol;668 OB += objcProto->getProtocol();
657 OB += ">";669 OB += ">";
658 }670 }
659 }671 }
...@@ -663,7 +675,7 @@ public:...@@ -663,7 +675,7 @@ public:
663 !static_cast<const ObjCProtoName *>(Pointee)->isObjCObject()) {675 !static_cast<const ObjCProtoName *>(Pointee)->isObjCObject()) {
664 if (Pointee->hasArray(OB) || Pointee->hasFunction(OB))676 if (Pointee->hasArray(OB) || Pointee->hasFunction(OB))
665 OB += ")";677 OB += ")";
666 Pointee->printRight(OB);678 OB.printRight(*Pointee);
667 }679 }
668 }680 }
669};681};
...@@ -729,7 +741,7 @@ public:...@@ -729,7 +741,7 @@ public:
729 std::pair<ReferenceKind, const Node *> Collapsed = collapse(OB);741 std::pair<ReferenceKind, const Node *> Collapsed = collapse(OB);
730 if (!Collapsed.second)742 if (!Collapsed.second)
731 return;743 return;
732 Collapsed.second->printLeft(OB);744 OB.printLeft(*Collapsed.second);
733 if (Collapsed.second->hasArray(OB))745 if (Collapsed.second->hasArray(OB))
734 OB += " ";746 OB += " ";
735 if (Collapsed.second->hasArray(OB) || Collapsed.second->hasFunction(OB))747 if (Collapsed.second->hasArray(OB) || Collapsed.second->hasFunction(OB))
...@@ -746,7 +758,7 @@ public:...@@ -746,7 +758,7 @@ public:
746 return;758 return;
747 if (Collapsed.second->hasArray(OB) || Collapsed.second->hasFunction(OB))759 if (Collapsed.second->hasArray(OB) || Collapsed.second->hasFunction(OB))
748 OB += ")";760 OB += ")";
749 Collapsed.second->printRight(OB);761 OB.printRight(*Collapsed.second);
750 }762 }
751};763};
752764
...@@ -766,7 +778,7 @@ public:...@@ -766,7 +778,7 @@ public:
766 }778 }
767779
768 void printLeft(OutputBuffer &OB) const override {780 void printLeft(OutputBuffer &OB) const override {
769 MemberType->printLeft(OB);781 OB.printLeft(*MemberType);
770 if (MemberType->hasArray(OB) || MemberType->hasFunction(OB))782 if (MemberType->hasArray(OB) || MemberType->hasFunction(OB))
771 OB += "(";783 OB += "(";
772 else784 else
...@@ -778,7 +790,7 @@ public:...@@ -778,7 +790,7 @@ public:
778 void printRight(OutputBuffer &OB) const override {790 void printRight(OutputBuffer &OB) const override {
779 if (MemberType->hasArray(OB) || MemberType->hasFunction(OB))791 if (MemberType->hasArray(OB) || MemberType->hasFunction(OB))
780 OB += ")";792 OB += ")";
781 MemberType->printRight(OB);793 OB.printRight(*MemberType);
782 }794 }
783};795};
784796
...@@ -798,7 +810,7 @@ public:...@@ -798,7 +810,7 @@ public:
798 bool hasRHSComponentSlow(OutputBuffer &) const override { return true; }810 bool hasRHSComponentSlow(OutputBuffer &) const override { return true; }
799 bool hasArraySlow(OutputBuffer &) const override { return true; }811 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
803 void printRight(OutputBuffer &OB) const override {815 void printRight(OutputBuffer &OB) const override {
804 if (OB.back() != ']')816 if (OB.back() != ']')
...@@ -807,7 +819,7 @@ public:...@@ -807,7 +819,7 @@ public:
807 if (Dimension)819 if (Dimension)
808 Dimension->print(OB);820 Dimension->print(OB);
809 OB += "]";821 OB += "]";
810 Base->printRight(OB);822 OB.printRight(*Base);
811 }823 }
812824
813 bool printInitListAsType(OutputBuffer &OB,825 bool printInitListAsType(OutputBuffer &OB,
...@@ -851,7 +863,7 @@ public:...@@ -851,7 +863,7 @@ public:
851 // by printing out the return types's left, then print our parameters, then863 // by printing out the return types's left, then print our parameters, then
852 // finally print right of the return type.864 // finally print right of the return type.
853 void printLeft(OutputBuffer &OB) const override {865 void printLeft(OutputBuffer &OB) const override {
854 Ret->printLeft(OB);866 OB.printLeft(*Ret);
855 OB += " ";867 OB += " ";
856 }868 }
857869
...@@ -859,7 +871,7 @@ public:...@@ -859,7 +871,7 @@ public:
859 OB.printOpen();871 OB.printOpen();
860 Params.printWithComma(OB);872 Params.printWithComma(OB);
861 OB.printClose();873 OB.printClose();
862 Ret->printRight(OB);874 OB.printRight(*Ret);
863875
864 if (CVQuals & QualConst)876 if (CVQuals & QualConst)
865 OB += " const";877 OB += " const";
...@@ -964,6 +976,8 @@ public:...@@ -964,6 +976,8 @@ public:
964 FunctionRefQual getRefQual() const { return RefQual; }976 FunctionRefQual getRefQual() const { return RefQual; }
965 NodeArray getParams() const { return Params; }977 NodeArray getParams() const { return Params; }
966 const Node *getReturnType() const { return Ret; }978 const Node *getReturnType() const { return Ret; }
979 const Node *getAttrs() const { return Attrs; }
980 const Node *getRequires() const { return Requires; }
967981
968 bool hasRHSComponentSlow(OutputBuffer &) const override { return true; }982 bool hasRHSComponentSlow(OutputBuffer &) const override { return true; }
969 bool hasFunctionSlow(OutputBuffer &) const override { return true; }983 bool hasFunctionSlow(OutputBuffer &) const override { return true; }
...@@ -972,10 +986,11 @@ public:...@@ -972,10 +986,11 @@ public:
972986
973 void printLeft(OutputBuffer &OB) const override {987 void printLeft(OutputBuffer &OB) const override {
974 if (Ret) {988 if (Ret) {
975 Ret->printLeft(OB);989 OB.printLeft(*Ret);
976 if (!Ret->hasRHSComponent(OB))990 if (!Ret->hasRHSComponent(OB))
977 OB += " ";991 OB += " ";
978 }992 }
993
979 Name->print(OB);994 Name->print(OB);
980 }995 }
981996
...@@ -983,8 +998,9 @@ public:...@@ -983,8 +998,9 @@ public:
983 OB.printOpen();998 OB.printOpen();
984 Params.printWithComma(OB);999 Params.printWithComma(OB);
985 OB.printClose();1000 OB.printClose();
1001
986 if (Ret)1002 if (Ret)
987 Ret->printRight(OB);1003 OB.printRight(*Ret);
9881004
989 if (CVQuals & QualConst)1005 if (CVQuals & QualConst)
990 OB += " const";1006 OB += " const";
...@@ -1324,14 +1340,14 @@ public:...@@ -1324,14 +1340,14 @@ public:
1324 template<typename Fn> void match(Fn F) const { F(Name, Type); }1340 template<typename Fn> void match(Fn F) const { F(Name, Type); }
13251341
1326 void printLeft(OutputBuffer &OB) const override {1342 void printLeft(OutputBuffer &OB) const override {
1327 Type->printLeft(OB);1343 OB.printLeft(*Type);
1328 if (!Type->hasRHSComponent(OB))1344 if (!Type->hasRHSComponent(OB))
1329 OB += " ";1345 OB += " ";
1330 }1346 }
13311347
1332 void printRight(OutputBuffer &OB) const override {1348 void printRight(OutputBuffer &OB) const override {
1333 Name->print(OB);1349 Name->print(OB);
1334 Type->printRight(OB);1350 OB.printRight(*Type);
1335 }1351 }
1336};1352};
13371353
...@@ -1376,11 +1392,11 @@ public:...@@ -1376,11 +1392,11 @@ public:
1376 template<typename Fn> void match(Fn F) const { F(Param); }1392 template<typename Fn> void match(Fn F) const { F(Param); }
13771393
1378 void printLeft(OutputBuffer &OB) const override {1394 void printLeft(OutputBuffer &OB) const override {
1379 Param->printLeft(OB);1395 OB.printLeft(*Param);
1380 OB += "...";1396 OB += "...";
1381 }1397 }
13821398
1383 void printRight(OutputBuffer &OB) const override { Param->printRight(OB); }1399 void printRight(OutputBuffer &OB) const override { OB.printRight(*Param); }
1384};1400};
13851401
1386/// An unexpanded parameter pack (either in the expression or type context). If1402/// An unexpanded parameter pack (either in the expression or type context). If
...@@ -1445,13 +1461,13 @@ public:...@@ -1445,13 +1461,13 @@ public:
1445 initializePackExpansion(OB);1461 initializePackExpansion(OB);
1446 size_t Idx = OB.CurrentPackIndex;1462 size_t Idx = OB.CurrentPackIndex;
1447 if (Idx < Data.size())1463 if (Idx < Data.size())
1448 Data[Idx]->printLeft(OB);1464 OB.printLeft(*Data[Idx]);
1449 }1465 }
1450 void printRight(OutputBuffer &OB) const override {1466 void printRight(OutputBuffer &OB) const override {
1451 initializePackExpansion(OB);1467 initializePackExpansion(OB);
1452 size_t Idx = OB.CurrentPackIndex;1468 size_t Idx = OB.CurrentPackIndex;
1453 if (Idx < Data.size())1469 if (Idx < Data.size())
1454 Data[Idx]->printRight(OB);1470 OB.printRight(*Data[Idx]);
1455 }1471 }
1456};1472};
14571473
...@@ -1609,13 +1625,13 @@ struct ForwardTemplateReference : Node {...@@ -1609,13 +1625,13 @@ struct ForwardTemplateReference : Node {
1609 if (Printing)1625 if (Printing)
1610 return;1626 return;
1611 ScopedOverride<bool> SavePrinting(Printing, true);1627 ScopedOverride<bool> SavePrinting(Printing, true);
1612 Ref->printLeft(OB);1628 OB.printLeft(*Ref);
1613 }1629 }
1614 void printRight(OutputBuffer &OB) const override {1630 void printRight(OutputBuffer &OB) const override {
1615 if (Printing)1631 if (Printing)
1616 return;1632 return;
1617 ScopedOverride<bool> SavePrinting(Printing, true);1633 ScopedOverride<bool> SavePrinting(Printing, true);
1618 Ref->printRight(OB);1634 OB.printRight(*Ref);
1619 }1635 }
1620};1636};
16211637
...@@ -1767,7 +1783,7 @@ public:...@@ -1767,7 +1783,7 @@ public:
17671783
1768 void printLeft(OutputBuffer &OB) const override {1784 void printLeft(OutputBuffer &OB) const override {
1769 OB += "~";1785 OB += "~";
1770 Base->printLeft(OB);1786 OB.printLeft(*Base);
1771 }1787 }
1772};1788};
17731789
...@@ -2047,7 +2063,7 @@ public:...@@ -2047,7 +2063,7 @@ public:
2047 {2063 {
2048 ScopedOverride<unsigned> LT(OB.GtIsGt, 0);2064 ScopedOverride<unsigned> LT(OB.GtIsGt, 0);
2049 OB += "<";2065 OB += "<";
2050 To->printLeft(OB);2066 OB.printLeft(*To);
2051 OB += ">";2067 OB += ">";
2052 }2068 }
2053 OB.printOpen();2069 OB.printOpen();
...@@ -3406,7 +3422,7 @@ const typename AbstractManglingParser<...@@ -3406,7 +3422,7 @@ const typename AbstractManglingParser<
3406 {"or", OperatorInfo::Binary, false, Node::Prec::Ior, "operator|"},3422 {"or", OperatorInfo::Binary, false, Node::Prec::Ior, "operator|"},
3407 {"pL", OperatorInfo::Binary, false, Node::Prec::Assign, "operator+="},3423 {"pL", OperatorInfo::Binary, false, Node::Prec::Assign, "operator+="},
3408 {"pl", OperatorInfo::Binary, false, Node::Prec::Additive, "operator+"},3424 {"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,
3410 "operator->*"},3426 "operator->*"},
3411 {"pp", OperatorInfo::Postfix, false, Node::Prec::Postfix, "operator++"},3427 {"pp", OperatorInfo::Postfix, false, Node::Prec::Postfix, "operator++"},
3412 {"ps", OperatorInfo::Prefix, false, Node::Prec::Unary, "operator+"},3428 {"ps", OperatorInfo::Prefix, false, Node::Prec::Unary, "operator+"},
...@@ -4452,7 +4468,9 @@ Node *AbstractManglingParser<Derived, Alloc>::parseType() {...@@ -4452,7 +4468,9 @@ Node *AbstractManglingParser<Derived, Alloc>::parseType() {
4452 return nullptr;4468 return nullptr;
4453 if (!consumeIf('_'))4469 if (!consumeIf('_'))
4454 return nullptr;4470 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;
4456 }4474 }
4457 // ::= Di # char32_t4475 // ::= Di # char32_t
4458 case 'i':4476 case 'i':
...@@ -5739,14 +5757,16 @@ struct FloatData<double>...@@ -5739,14 +5757,16 @@ struct FloatData<double>
5739template <>5757template <>
5740struct FloatData<long double>5758struct FloatData<long double>
5741{5759{
5742#if defined(__mips__) && defined(__mips_n64) || defined(__aarch64__) || \5760#if __LDBL_MANT_DIG__ == 113 || __LDBL_MANT_DIG__ == 106
5743 defined(__wasm__) || defined(__riscv) || defined(__loongarch__) || \5761 static const size_t mangled_size = 32;
5744 defined(__ve__)5762#elif __LDBL_MANT_DIG__ == 53 || defined(_MSC_VER)
5745 static const size_t mangled_size = 32;5763 // MSVC doesn't define __LDBL_MANT_DIG__, but it has long double equal to
5746#elif defined(__arm__) || defined(__mips__) || defined(__hexagon__)5764 // regular double on all current architectures.
5747 static const size_t mangled_size = 16;5765 static const size_t mangled_size = 16;
5766#elif __LDBL_MANT_DIG__ == 64
5767 static const size_t mangled_size = 20;
5748#else5768#else
5749 static const size_t mangled_size = 20; // May need to be adjusted to 16 or 24 on other platforms5769#error Unknown size for __LDBL_MANT_DIG__
5750#endif5770#endif
5751 // `-0x1.ffffffffffffffffffffffffffffp+16383` + 'L' + '\0' == 42 bytes.5771 // `-0x1.ffffffffffffffffffffffffffffp+16383` + 'L' + '\0' == 42 bytes.
5752 // 28 'f's * 4 bits == 112 bits, which is the number of mantissa bits.5772 // 28 'f's * 4 bits == 112 bits, which is the number of mantissa bits.
...@@ -6176,6 +6196,10 @@ struct ManglingParser : AbstractManglingParser<ManglingParser<Alloc>, Alloc> {...@@ -6176,6 +6196,10 @@ struct ManglingParser : AbstractManglingParser<ManglingParser<Alloc>, Alloc> {
6176 Alloc>::AbstractManglingParser;6196 Alloc>::AbstractManglingParser;
6177};6197};
61786198
6199inline void OutputBuffer::printLeft(const Node &N) { N.printLeft(*this); }
6200
6201inline void OutputBuffer::printRight(const Node &N) { N.printRight(*this); }
6202
6179DEMANGLE_NAMESPACE_END6203DEMANGLE_NAMESPACE_END
61806204
6181#if defined(__clang__)6205#if defined(__clang__)
lib/libcxxabi/src/demangle/Utility.h+27-1
...@@ -27,6 +27,8 @@...@@ -27,6 +27,8 @@
2727
28DEMANGLE_NAMESPACE_BEGIN28DEMANGLE_NAMESPACE_BEGIN
2929
30class Node;
31
30// Stream that AST nodes write their string representation into after the AST32// Stream that AST nodes write their string representation into after the AST
31// has been parsed.33// has been parsed.
32class OutputBuffer {34class OutputBuffer {
...@@ -79,10 +81,24 @@ public:...@@ -79,10 +81,24 @@ public:
79 OutputBuffer(const OutputBuffer &) = delete;81 OutputBuffer(const OutputBuffer &) = delete;
80 OutputBuffer &operator=(const OutputBuffer &) = delete;82 OutputBuffer &operator=(const OutputBuffer &) = delete;
8183
84 virtual ~OutputBuffer() {}
85
82 operator std::string_view() const {86 operator std::string_view() const {
83 return std::string_view(Buffer, CurrentPosition);87 return std::string_view(Buffer, CurrentPosition);
84 }88 }
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
86 /// If a ParameterPackExpansion (or similar type) is encountered, the offset102 /// If a ParameterPackExpansion (or similar type) is encountered, the offset
87 /// into the pack that we're currently printing.103 /// into the pack that we're currently printing.
88 unsigned CurrentPackIndex = std::numeric_limits<unsigned>::max();104 unsigned CurrentPackIndex = std::numeric_limits<unsigned>::max();
...@@ -120,12 +136,16 @@ public:...@@ -120,12 +136,16 @@ public:
120136
121 OutputBuffer &prepend(std::string_view R) {137 OutputBuffer &prepend(std::string_view R) {
122 size_t Size = R.size();138 size_t Size = R.size();
139 if (!Size)
140 return *this;
123141
124 grow(Size);142 grow(Size);
125 std::memmove(Buffer + Size, Buffer, CurrentPosition);143 std::memmove(Buffer + Size, Buffer, CurrentPosition);
126 std::memcpy(Buffer, &*R.begin(), Size);144 std::memcpy(Buffer, &*R.begin(), Size);
127 CurrentPosition += Size;145 CurrentPosition += Size;
128146
147 notifyInsertion(/*Position=*/0, /*Count=*/Size);
148
129 return *this;149 return *this;
130 }150 }
131151
...@@ -161,14 +181,20 @@ public:...@@ -161,14 +181,20 @@ public:
161 DEMANGLE_ASSERT(Pos <= CurrentPosition, "");181 DEMANGLE_ASSERT(Pos <= CurrentPosition, "");
162 if (N == 0)182 if (N == 0)
163 return;183 return;
184
164 grow(N);185 grow(N);
165 std::memmove(Buffer + Pos + N, Buffer + Pos, CurrentPosition - Pos);186 std::memmove(Buffer + Pos + N, Buffer + Pos, CurrentPosition - Pos);
166 std::memcpy(Buffer + Pos, S, N);187 std::memcpy(Buffer + Pos, S, N);
167 CurrentPosition += N;188 CurrentPosition += N;
189
190 notifyInsertion(Pos, N);
168 }191 }
169192
170 size_t getCurrentPosition() const { return CurrentPosition; }193 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
173 char back() const {199 char back() const {
174 DEMANGLE_ASSERT(CurrentPosition, "");200 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) {...@@ -63,7 +63,7 @@ static void* operator_new_impl(std::size_t size) {
63 return p;63 return p;
64}64}
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 {
67 void* p = operator_new_impl(size);67 void* p = operator_new_impl(size);
68 if (p == nullptr)68 if (p == nullptr)
69 __throw_bad_alloc_shim();69 __throw_bad_alloc_shim();
...@@ -74,7 +74,7 @@ _LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept {...@@ -74,7 +74,7 @@ _LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept {
74#if !_LIBCPP_HAS_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 < void*(std::size_t), &operator new>()),
78 "libc++ was configured with exceptions disabled and `operator new(size_t)` has been overridden, "78 "libc++ was configured with exceptions disabled and `operator new(size_t)` has been overridden, "
79 "but `operator new(size_t, nothrow_t)` has not been overridden. This is problematic because "79 "but `operator new(size_t, nothrow_t)` has not been overridden. This is problematic because "
80 "`operator new(size_t, nothrow_t)` must call `operator new(size_t)`, which will terminate in case "80 "`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 {...@@ -94,15 +94,13 @@ _LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept {
94#endif94#endif
95}95}
9696
97_LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void* operator new[](size_t size) _THROW_BAD_ALLOC {97_LIBCPP_OVERRIDABLE_FUNCTION(void*, operator new[], (size_t size)) _THROW_BAD_ALLOC { return ::operator new(size); }
98 return ::operator new(size);
99}
10098
101_LIBCPP_WEAK void* operator new[](size_t size, const std::nothrow_t&) noexcept {99_LIBCPP_WEAK void* operator new[](size_t size, const std::nothrow_t&) noexcept {
102#if !_LIBCPP_HAS_EXCEPTIONS100#if !_LIBCPP_HAS_EXCEPTIONS
103# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION101# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION
104 _LIBCPP_ASSERT_SHIM(102 _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[]>()),
106 "libc++ was configured with exceptions disabled and `operator new[](size_t)` has been overridden, "104 "libc++ was configured with exceptions disabled and `operator new[](size_t)` has been overridden, "
107 "but `operator new[](size_t, nothrow_t)` has not been overridden. This is problematic because "105 "but `operator new[](size_t, nothrow_t)` has not been overridden. This is problematic because "
108 "`operator new[](size_t, nothrow_t)` must call `operator new[](size_t)`, which will terminate in case "106 "`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...@@ -156,8 +154,7 @@ static void* operator_new_aligned_impl(std::size_t size, std::align_val_t alignm
156 return p;154 return p;
157}155}
158156
159_LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void*157_LIBCPP_OVERRIDABLE_FUNCTION(void*, operator new, (std::size_t size, std::align_val_t alignment)) _THROW_BAD_ALLOC {
160operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC {
161 void* p = operator_new_aligned_impl(size, alignment);158 void* p = operator_new_aligned_impl(size, alignment);
162 if (p == nullptr)159 if (p == nullptr)
163 __throw_bad_alloc_shim();160 __throw_bad_alloc_shim();
...@@ -168,7 +165,7 @@ _LIBCPP_WEAK void* operator new(size_t size, std::align_val_t alignment, const s...@@ -168,7 +165,7 @@ _LIBCPP_WEAK void* operator new(size_t size, std::align_val_t alignment, const s
168# if !_LIBCPP_HAS_EXCEPTIONS165# if !_LIBCPP_HAS_EXCEPTIONS
169# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION166# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION
170 _LIBCPP_ASSERT_SHIM(167 _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>()),
172 "libc++ was configured with exceptions disabled and `operator new(size_t, align_val_t)` has been overridden, "169 "libc++ was configured with exceptions disabled and `operator new(size_t, align_val_t)` has been overridden, "
173 "but `operator new(size_t, align_val_t, nothrow_t)` has not been overridden. This is problematic because "170 "but `operator new(size_t, align_val_t, nothrow_t)` has not been overridden. This is problematic because "
174 "`operator new(size_t, align_val_t, nothrow_t)` must call `operator new(size_t, align_val_t)`, which will "171 "`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...@@ -188,8 +185,7 @@ _LIBCPP_WEAK void* operator new(size_t size, std::align_val_t alignment, const s
188# endif185# endif
189}186}
190187
191_LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void*188_LIBCPP_OVERRIDABLE_FUNCTION(void*, operator new[], (size_t size, std::align_val_t alignment)) _THROW_BAD_ALLOC {
192operator new[](size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC {
193 return ::operator new(size, alignment);189 return ::operator new(size, alignment);
194}190}
195191
...@@ -197,14 +193,13 @@ _LIBCPP_WEAK void* operator new[](size_t size, std::align_val_t alignment, const...@@ -197,14 +193,13 @@ _LIBCPP_WEAK void* operator new[](size_t size, std::align_val_t alignment, const
197# if !_LIBCPP_HAS_EXCEPTIONS193# if !_LIBCPP_HAS_EXCEPTIONS
198# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION194# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION
199 _LIBCPP_ASSERT_SHIM(195 _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[]>()),
201 "libc++ was configured with exceptions disabled and `operator new[](size_t, align_val_t)` has been overridden, "197 "libc++ was configured with exceptions disabled and `operator new[](size_t, align_val_t)` has been overridden, "
202 "but `operator new[](size_t, align_val_t, nothrow_t)` has not been overridden. This is problematic because "198 "but `operator new[](size_t, align_val_t, nothrow_t)` has not been overridden. This is problematic because "
203 "`operator new[](size_t, align_val_t, nothrow_t)` must call `operator new[](size_t, align_val_t)`, which will "199 "`operator new[](size_t, align_val_t, nothrow_t)` must call `operator new[](size_t, align_val_t)`, which will "
204 "terminate in case it fails to allocate, making it impossible for `operator new[](size_t, align_val_t, "200 "terminate in case it fails to allocate, making it impossible for `operator new[](size_t, align_val_t, "
205 "nothrow_t)` to fulfill its contract (since it should return nullptr upon failure). Please make sure you "201 "nothrow_t)` to fulfill its contract (since it should return nullptr upon failure). Please make sure you "
206 "override "202 "override `operator new[](size_t, align_val_t, nothrow_t)` as well.");
207 "`operator new[](size_t, align_val_t, nothrow_t)` as well.");
208# endif203# endif
209204
210 return operator_new_aligned_impl(size, alignment);205 return operator_new_aligned_impl(size, alignment);