@@ -356,9 +356,7 @@ intptr_t swift_TupleMirror_count(HeapObject *owner,
356
356
const OpaqueValue *value,
357
357
const Metadata *type) {
358
358
auto Tuple = static_cast <const TupleTypeMetadata *>(type);
359
- #ifndef SWIFT_RUNTIME_ENABLE_GUARANTEED_NORMAL_ARGUMENTS
360
- swift_release (owner);
361
- #endif
359
+ SWIFT_CC_PLUSONE_GUARD (swift_release (owner));
362
360
return Tuple->NumElements ;
363
361
}
364
362
@@ -404,9 +402,9 @@ void swift_TupleMirror_subscript(String *outString,
404
402
auto bytes = reinterpret_cast <const char *>(value);
405
403
auto eltData = reinterpret_cast <const OpaqueValue *>(bytes + elt.Offset );
406
404
407
- # ifdef SWIFT_RUNTIME_ENABLE_GUARANTEED_NORMAL_ARGUMENTS
408
- swift_retain ( owner);
409
- # endif
405
+ // Since 'owner' is consumed, when we have a +0 convention, we must retain
406
+ // owner first.
407
+ SWIFT_CC_PLUSZERO_GUARD ( swift_retain (owner));
410
408
411
409
// 'owner' is consumed by this call.
412
410
new (outMirror) Mirror (reflect (owner, eltData, elt.Type ));
@@ -496,9 +494,7 @@ intptr_t swift_StructMirror_count(HeapObject *owner,
496
494
const OpaqueValue *value,
497
495
const Metadata *type) {
498
496
auto Struct = static_cast <const StructMetadata *>(type);
499
- #ifndef SWIFT_RUNTIME_ENABLE_GUARANTEED_NORMAL_ARGUMENTS
500
- swift_release (owner);
501
- #endif
497
+ SWIFT_CC_PLUSONE_GUARD (swift_release (owner));
502
498
return Struct->Description ->Struct .NumFields ;
503
499
}
504
500
@@ -524,6 +520,8 @@ void swift_StructMirror_subscript(String *outString,
524
520
new (outString) String (getFieldName (Struct->Description ->Struct .FieldNames , i));
525
521
526
522
// 'owner' is consumed by this call.
523
+ SWIFT_CC_PLUSZERO_GUARD (swift_unknownRetain (owner));
524
+
527
525
assert (!fieldType.isIndirect () && " indirect struct fields not implemented" );
528
526
529
527
if (loadSpecialReferenceStorage (owner, fieldData, fieldType, outMirror))
@@ -583,9 +581,7 @@ static void getEnumMirrorInfo(const OpaqueValue *value,
583
581
const OpaqueValue *value,
584
582
const Metadata *type) {
585
583
if (!isEnumReflectable (type)) {
586
- #ifndef SWIFT_RUNTIME_ENABLE_GUARANTEED_NORMAL_ARGUMENTS
587
- swift_release (owner);
588
- #endif
584
+ SWIFT_CC_PLUSONE_GUARD (swift_release (owner));
589
585
return nullptr ;
590
586
}
591
587
@@ -595,9 +591,7 @@ static void getEnumMirrorInfo(const OpaqueValue *value,
595
591
unsigned tag;
596
592
getEnumMirrorInfo (value, type, &tag, nullptr , nullptr );
597
593
598
- #ifndef SWIFT_RUNTIME_ENABLE_GUARANTEED_NORMAL_ARGUMENTS
599
- swift_release (owner);
600
- #endif
594
+ SWIFT_CC_PLUSONE_GUARD (swift_release (owner));
601
595
602
596
return getFieldName (Description.CaseNames , tag);
603
597
}
@@ -612,24 +606,18 @@ static void getEnumMirrorInfo(const OpaqueValue *value,
612
606
OpaqueValue *mirrorValue = const_cast <OpaqueValue*>(cMirrorValue);
613
607
Mirror mirror;
614
608
615
- bool take =
616
- #ifndef SWIFT_RUNTIME_ENABLE_GUARANTEED_NORMAL_ARGUMENTS
617
- mirrorValue == value;
618
- #else
619
- false ;
620
- #endif
609
+ bool take = false ;
610
+ SWIFT_CC_PLUSONE_GUARD (take = (mirrorValue == value));
621
611
622
612
::new (&mirror) MagicMirror (mirrorValue, mirrorType, take);
623
613
624
614
MagicMirror *theMirror = reinterpret_cast <MagicMirror *>(&mirror);
625
615
MagicMirrorData data = theMirror->Data ;
626
616
const char *result = swift_EnumMirror_caseName (data.Owner , data.Value , data.Type );
627
617
628
- #ifndef SWIFT_RUNTIME_ENABLE_GUARANTEED_NORMAL_ARGUMENTS
629
618
// Destroy the whole original value if we couldn't take it.
630
619
if (!take)
631
620
type->vw_destroy (value);
632
- #endif
633
621
634
622
return result;
635
623
}
@@ -639,17 +627,13 @@ intptr_t swift_EnumMirror_count(HeapObject *owner,
639
627
const OpaqueValue *value,
640
628
const Metadata *type) {
641
629
if (!isEnumReflectable (type)) {
642
- #ifndef SWIFT_RUNTIME_ENABLE_GUARANTEED_NORMAL_ARGUMENTS
643
- swift_release (owner);
644
- #endif
630
+ SWIFT_CC_PLUSONE_GUARD (swift_release (owner));
645
631
return 0 ;
646
632
}
647
633
648
634
const Metadata *payloadType;
649
635
getEnumMirrorInfo (value, type, nullptr , &payloadType, nullptr );
650
- #ifndef SWIFT_RUNTIME_ENABLE_GUARANTEED_NORMAL_ARGUMENTS
651
- swift_release (owner);
652
- #endif
636
+ SWIFT_CC_PLUSONE_GUARD (swift_release (owner));
653
637
return (payloadType != nullptr ) ? 1 : 0 ;
654
638
}
655
639
@@ -678,9 +662,7 @@ void swift_EnumMirror_subscript(String *outString,
678
662
type->vw_destructiveInjectEnumTag (const_cast <OpaqueValue *>(value),
679
663
(int ) (tag - Description.getNumPayloadCases ()));
680
664
681
- #ifndef SWIFT_RUNTIME_ENABLE_GUARANTEED_NORMAL_ARGUMENTS
682
- swift_release (owner);
683
- #endif
665
+ SWIFT_CC_PLUSONE_GUARD (swift_release (owner));
684
666
685
667
owner = pair.first ;
686
668
value = pair.second ;
@@ -708,9 +690,7 @@ intptr_t swift_ClassMirror_count(HeapObject *owner,
708
690
const OpaqueValue *value,
709
691
const Metadata *type) {
710
692
auto Clas = static_cast <const ClassMetadata*>(type);
711
- #ifndef SWIFT_RUNTIME_ENABLE_GUARANTEED_NORMAL_ARGUMENTS
712
- swift_release (owner);
713
- #endif
693
+ SWIFT_CC_PLUSONE_GUARD (swift_release (owner));
714
694
auto count = Clas->getDescription ()->Class .NumFields ;
715
695
716
696
// If the class has a superclass, the superclass instance is treated as the
@@ -953,9 +933,7 @@ static Mirror getMirrorForSuperclass(const ClassMetadata *sup,
953
933
Mirror resultBuf;
954
934
MagicMirror *result = ::new (&resultBuf) MagicMirror;
955
935
956
- #ifdef SWIFT_RUNTIME_ENABLE_GUARANTEED_NORMAL_ARGUMENTS
957
- swift_retain (owner);
958
- #endif
936
+ SWIFT_CC_PLUSZERO_GUARD (swift_retain (owner));
959
937
960
938
result->Self = ClassSuperMirrorMetadata ();
961
939
result->MirrorWitness = &ClassSuperMirrorWitnessTable;
@@ -976,9 +954,7 @@ static Mirror ObjC_getMirrorForSuperclass(Class sup,
976
954
Mirror resultBuf;
977
955
MagicMirror *result = ::new (&resultBuf) MagicMirror;
978
956
979
- #ifdef SWIFT_RUNTIME_ENABLE_GUARANTEED_NORMAL_ARGUMENTS
980
- swift_retain (owner);
981
- #endif
957
+ SWIFT_CC_PLUSZERO_GUARD (swift_retain (owner));
982
958
983
959
result->Self = ObjCSuperMirrorMetadata ();
984
960
result->MirrorWitness = &ObjCSuperMirrorWitnessTable;
0 commit comments