@@ -104,9 +104,9 @@ class RemoteASTContextImpl {
104
104
getDeclForRemoteNominalTypeDescriptor (RemoteAddress descriptor) = 0 ;
105
105
virtual Result<RemoteAddress>
106
106
getHeapMetadataForObject (RemoteAddress object) = 0 ;
107
- virtual OpenedExistential
107
+ virtual Result< OpenedExistential>
108
108
getDynamicTypeAndAddressForError (RemoteAddress object) = 0 ;
109
- virtual OpenedExistential
109
+ virtual Result< OpenedExistential>
110
110
getDynamicTypeAndAddressForExistential (RemoteAddress object,
111
111
Type staticType) = 0 ;
112
112
@@ -478,89 +478,89 @@ class RemoteASTContextConcreteImpl final : public RemoteASTContextImpl {
478
478
return getFailure<RemoteAddress>();
479
479
}
480
480
481
- OpenedExistential
481
+ Result< OpenedExistential>
482
482
getDynamicTypeAndAddressClassExistential (RemoteAddress object) {
483
483
auto pointerval = Reader.readPointerValue (object.getAddressData ());
484
484
if (!pointerval)
485
- return getFailure<std::pair<Type, RemoteAddress> >();
485
+ return getFailure<OpenedExistential >();
486
486
auto result = Reader.readMetadataFromInstance (*pointerval);
487
487
if (!result)
488
- return getFailure<std::pair<Type, RemoteAddress> >();
488
+ return getFailure<OpenedExistential >();
489
489
auto typeResult = Reader.readTypeFromMetadata (result.getValue ());
490
490
if (!typeResult)
491
- return getFailure<std::pair<Type, RemoteAddress> >();
492
- return std::make_pair<Type, RemoteAddress> (std::move (typeResult),
493
- RemoteAddress (*pointerval));
491
+ return getFailure<OpenedExistential >();
492
+ return OpenedExistential (std::move (typeResult),
493
+ RemoteAddress (*pointerval));
494
494
}
495
495
496
- OpenedExistential
496
+ Result< OpenedExistential>
497
497
getDynamicTypeAndAddressErrorExistential (RemoteAddress object,
498
498
bool dereference=true ) {
499
499
if (dereference) {
500
500
auto pointerval = Reader.readPointerValue (object.getAddressData ());
501
501
if (!pointerval)
502
- return getFailure<std::pair<Type, RemoteAddress> >();
502
+ return getFailure<OpenedExistential >();
503
503
object = RemoteAddress (*pointerval);
504
504
}
505
505
506
506
auto result =
507
507
Reader.readMetadataAndValueErrorExistential (object);
508
508
if (!result)
509
- return getFailure<std::pair<Type, RemoteAddress>>();
510
-
511
- RemoteAddress metadataAddress = std::get<0 >(*result);
512
- RemoteAddress valueAddress = std::get<1 >(*result);
513
- bool isBridged = std::get<2 >(*result);
509
+ return getFailure<OpenedExistential>();
514
510
515
511
auto typeResult =
516
- Reader.readTypeFromMetadata (metadataAddress .getAddressData ());
512
+ Reader.readTypeFromMetadata (result-> MetadataAddress .getAddressData ());
517
513
if (!typeResult)
518
- return getFailure<std::pair<Type, RemoteAddress>>();
514
+ return getFailure<OpenedExistential>();
515
+
519
516
520
517
// When the existential wraps a class type, LLDB expects that the
521
518
// address returned is the class instance itself and not the address
522
519
// of the reference.
523
- if (!isBridged && typeResult->getClassOrBoundGenericClass ()) {
524
- auto pointerval = Reader.readPointerValue (valueAddress.getAddressData ());
520
+ auto payloadAddress = result->PayloadAddress ;
521
+ if (!result->IsBridgedError &&
522
+ typeResult->getClassOrBoundGenericClass ()) {
523
+ auto pointerval = Reader.readPointerValue (
524
+ payloadAddress.getAddressData ());
525
525
if (!pointerval)
526
- return getFailure<std::pair<Type, RemoteAddress> >();
526
+ return getFailure<OpenedExistential >();
527
527
528
- valueAddress = RemoteAddress (*pointerval);
528
+ payloadAddress = RemoteAddress (*pointerval);
529
529
}
530
530
531
- return std::make_pair<Type, RemoteAddress> (std::move (typeResult),
532
- std::move (valueAddress ));
531
+ return OpenedExistential (std::move (typeResult),
532
+ std::move (payloadAddress ));
533
533
}
534
534
535
- OpenedExistential
535
+ Result< OpenedExistential>
536
536
getDynamicTypeAndAddressOpaqueExistential (RemoteAddress object) {
537
537
auto result = Reader.readMetadataAndValueOpaqueExistential (object);
538
538
if (!result)
539
- return getFailure<std::pair<Type, RemoteAddress>>();
540
- RemoteAddress metadataAddress = result->first ;
541
- RemoteAddress valueAddress = result->second ;
539
+ return getFailure<OpenedExistential>();
542
540
543
541
auto typeResult =
544
- Reader.readTypeFromMetadata (metadataAddress .getAddressData ());
542
+ Reader.readTypeFromMetadata (result-> MetadataAddress .getAddressData ());
545
543
if (!typeResult)
546
- return getFailure<std::pair<Type, RemoteAddress> >();
544
+ return getFailure<OpenedExistential >();
547
545
548
546
// When the existential wraps a class type, LLDB expects that the
549
547
// address returned is the class instance itself and not the address
550
548
// of the reference.
549
+ auto payloadAddress = result->PayloadAddress ;
551
550
if (typeResult->getClassOrBoundGenericClass ()) {
552
- auto pointerval = Reader.readPointerValue (valueAddress.getAddressData ());
551
+ auto pointerval = Reader.readPointerValue (
552
+ payloadAddress.getAddressData ());
553
553
if (!pointerval)
554
- return getFailure<std::pair<Type, RemoteAddress> >();
554
+ return getFailure<OpenedExistential >();
555
555
556
- valueAddress = RemoteAddress (*pointerval);
556
+ payloadAddress = RemoteAddress (*pointerval);
557
557
}
558
558
559
- return std::make_pair<Type, RemoteAddress> (std::move (typeResult),
560
- std::move (valueAddress ));
559
+ return OpenedExistential (std::move (typeResult),
560
+ std::move (payloadAddress ));
561
561
}
562
562
563
- OpenedExistential
563
+ Result< OpenedExistential>
564
564
getDynamicTypeAndAddressExistentialMetatype (RemoteAddress object) {
565
565
// The value of the address is just the input address.
566
566
// The type is obtained through the following sequence of steps:
@@ -569,21 +569,21 @@ class RemoteASTContextConcreteImpl final : public RemoteASTContextImpl {
569
569
// 3) Wrapping the resolved type in an existential metatype.
570
570
auto pointerval = Reader.readPointerValue (object.getAddressData ());
571
571
if (!pointerval)
572
- return getFailure<std::pair<Type, RemoteAddress> >();
572
+ return getFailure<OpenedExistential >();
573
573
auto typeResult = Reader.readTypeFromMetadata (*pointerval);
574
574
if (!typeResult)
575
- return getFailure<std::pair<Type, RemoteAddress> >();
575
+ return getFailure<OpenedExistential >();
576
576
auto wrappedType = ExistentialMetatypeType::get (typeResult);
577
577
if (!wrappedType)
578
- return getFailure<std::pair<Type, RemoteAddress> >();
579
- return std::make_pair<Type, RemoteAddress> (std::move (wrappedType),
580
- std::move (object));
578
+ return getFailure<OpenedExistential >();
579
+ return OpenedExistential (std::move (wrappedType),
580
+ std::move (object));
581
581
}
582
582
583
583
// / Resolve the dynamic type and the value address of an error existential
584
584
// / object, Unlike getDynamicTypeAndAddressForExistential(), this function
585
585
// / takes the address of the instance and not the address of the reference.
586
- OpenedExistential
586
+ Result< OpenedExistential>
587
587
getDynamicTypeAndAddressForError (RemoteAddress object) override {
588
588
return getDynamicTypeAndAddressErrorExistential (object,
589
589
/* dereference=*/ false );
@@ -593,12 +593,12 @@ class RemoteASTContextConcreteImpl final : public RemoteASTContextImpl {
593
593
// / given its address and its static type. For class and error existentials,
594
594
// / this API takes a pointer to the instance reference rather than the
595
595
// / instance reference itself.
596
- OpenedExistential
596
+ Result< OpenedExistential>
597
597
getDynamicTypeAndAddressForExistential (RemoteAddress object,
598
598
Type staticType) override {
599
599
// If this is not an existential, give up.
600
600
if (!staticType->isAnyExistentialType ())
601
- return getFailure<std::pair<Type, RemoteAddress> >();
601
+ return getFailure<OpenedExistential >();
602
602
603
603
// Handle the case where this is an ExistentialMetatype.
604
604
if (!staticType->isExistentialType ())
@@ -674,13 +674,13 @@ RemoteASTContext::getHeapMetadataForObject(remote::RemoteAddress address) {
674
674
return asImpl (Impl)->getHeapMetadataForObject (address);
675
675
}
676
676
677
- OpenedExistential
677
+ Result< OpenedExistential>
678
678
RemoteASTContext::getDynamicTypeAndAddressForError (
679
679
remote::RemoteAddress address) {
680
680
return asImpl (Impl)->getDynamicTypeAndAddressForError (address);
681
681
}
682
682
683
- OpenedExistential
683
+ Result< OpenedExistential>
684
684
RemoteASTContext::getDynamicTypeAndAddressForExistential (
685
685
remote::RemoteAddress address, Type staticType) {
686
686
return asImpl (Impl)->getDynamicTypeAndAddressForExistential (address,
0 commit comments