@@ -530,6 +530,8 @@ swift::_swift_buildDemanglingForMetadata(const Metadata *type,
530
530
// If there is a superclass constraint, we mangle it specially.
531
531
auto result = Dem.createNode (Node::Kind::ProtocolListWithClass);
532
532
auto superclassNode = _swift_buildDemanglingForMetadata (superclass, Dem);
533
+ if (!superclassNode)
534
+ return nullptr ;
533
535
534
536
result->addChild (proto_list, Dem);
535
537
result->addChild (superclassNode, Dem);
@@ -573,6 +575,8 @@ swift::_swift_buildDemanglingForMetadata(const Metadata *type,
573
575
auto metatype = static_cast <const ExistentialMetatypeMetadata *>(type);
574
576
auto instance = _swift_buildDemanglingForMetadata (metatype->InstanceType ,
575
577
Dem);
578
+ if (!instance)
579
+ return nullptr ;
576
580
auto node = Dem.createNode (Node::Kind::ExistentialMetatype);
577
581
node->addChild (instance, Dem);
578
582
return node;
@@ -605,6 +609,11 @@ swift::_swift_buildDemanglingForMetadata(const Metadata *type,
605
609
auto flags = func->getParameterFlags (i);
606
610
auto input = _swift_buildDemanglingForMetadata (param, Dem);
607
611
612
+ // If we failed to build the demangling for an input, we have to fail
613
+ // building the demangling for the function type too.
614
+ if (!input)
615
+ return nullptr ;
616
+
608
617
auto wrapInput = [&](Node::Kind kind) {
609
618
auto parent = Dem.createNode (kind);
610
619
parent->addChild (input, Dem);
@@ -691,13 +700,18 @@ swift::_swift_buildDemanglingForMetadata(const Metadata *type,
691
700
692
701
NodePointer resultTy = _swift_buildDemanglingForMetadata (func->ResultType ,
693
702
Dem);
703
+ if (!resultTy)
704
+ return nullptr ;
705
+
694
706
NodePointer result = Dem.createNode (Node::Kind::ReturnType);
695
707
result->addChild (resultTy, Dem);
696
708
697
709
auto funcNode = Dem.createNode (kind);
698
710
if (func->hasGlobalActor ()) {
699
711
auto globalActorTypeNode =
700
712
_swift_buildDemanglingForMetadata (func->getGlobalActor (), Dem);
713
+ if (!globalActorTypeNode)
714
+ return nullptr ;
701
715
NodePointer globalActorNode =
702
716
Dem.createNode (Node::Kind::GlobalActorFunctionType);
703
717
globalActorNode->addChild (globalActorTypeNode, Dem);
@@ -731,6 +745,8 @@ swift::_swift_buildDemanglingForMetadata(const Metadata *type,
731
745
if (auto thrownError = func->getThrownError ()) {
732
746
auto thrownErrorTypeNode =
733
747
_swift_buildDemanglingForMetadata (thrownError, Dem);
748
+ if (!thrownErrorTypeNode)
749
+ return nullptr ;
734
750
NodePointer thrownErrorNode =
735
751
Dem.createNode (Node::Kind::TypedThrowsAnnotation);
736
752
thrownErrorNode->addChild (thrownErrorTypeNode, Dem);
@@ -790,6 +806,8 @@ swift::_swift_buildDemanglingForMetadata(const Metadata *type,
790
806
// Add the element type child.
791
807
auto eltType =
792
808
_swift_buildDemanglingForMetadata (tuple->getElement (i).Type , Dem);
809
+ if (!eltType)
810
+ return nullptr ;
793
811
794
812
if (eltType->getKind () == Node::Kind::Type) {
795
813
elt->addChild (eltType, Dem);
0 commit comments