Skip to content

Commit e8914cf

Browse files
authored
Merge pull request #3778 from hborla/5.6-lldb-swift-existential-type
[5.6][lldb] Teach LLDB about ExistentialType in the Swift AST.
2 parents 962fe56 + 8d8ea5c commit e8914cf

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5719,6 +5719,7 @@ SwiftASTContext::GetTypeInfo(opaque_compiler_type_t type,
57195719

57205720
case swift::TypeKind::Protocol:
57215721
case swift::TypeKind::ProtocolComposition:
5722+
case swift::TypeKind::Existential:
57225723
swift_flags |= eTypeHasChildren | eTypeIsStructUnion | eTypeIsProtocol;
57235724
break;
57245725
case swift::TypeKind::ExistentialMetatype:
@@ -5800,6 +5801,7 @@ lldb::TypeClass SwiftASTContext::GetTypeClass(opaque_compiler_type_t type) {
58005801
case swift::TypeKind::DependentMember:
58015802
case swift::TypeKind::Protocol:
58025803
case swift::TypeKind::ProtocolComposition:
5804+
case swift::TypeKind::Existential:
58035805
case swift::TypeKind::Metatype:
58045806
case swift::TypeKind::Module:
58055807
case swift::TypeKind::PrimaryArchetype:
@@ -6301,6 +6303,7 @@ lldb::Encoding SwiftASTContext::GetEncoding(opaque_compiler_type_t type,
63016303
case swift::TypeKind::Struct:
63026304
case swift::TypeKind::Protocol:
63036305
case swift::TypeKind::ProtocolComposition:
6306+
case swift::TypeKind::Existential:
63046307
break;
63056308
case swift::TypeKind::LValue:
63066309
return lldb::eEncodingUint;
@@ -6389,7 +6392,8 @@ uint32_t SwiftASTContext::GetNumChildren(opaque_compiler_type_t type,
63896392
}
63906393

63916394
case swift::TypeKind::Protocol:
6392-
case swift::TypeKind::ProtocolComposition: {
6395+
case swift::TypeKind::ProtocolComposition:
6396+
case swift::TypeKind::Existential: {
63936397
ProtocolInfo protocol_info;
63946398
if (!GetProtocolTypeInfo(ToCompilerType(GetSwiftType(type)), protocol_info))
63956399
break;
@@ -6528,6 +6532,7 @@ uint32_t SwiftASTContext::GetNumFields(opaque_compiler_type_t type,
65286532

65296533
case swift::TypeKind::Protocol:
65306534
case swift::TypeKind::ProtocolComposition:
6535+
case swift::TypeKind::Existential:
65316536
return GetNumChildren(type, /*omit_empty_base_classes=*/false, nullptr);
65326537

65336538
case swift::TypeKind::ExistentialMetatype:
@@ -6800,7 +6805,8 @@ CompilerType SwiftASTContext::GetFieldAtIndex(opaque_compiler_type_t type,
68006805
}
68016806

68026807
case swift::TypeKind::Protocol:
6803-
case swift::TypeKind::ProtocolComposition: {
6808+
case swift::TypeKind::ProtocolComposition:
6809+
case swift::TypeKind::Existential: {
68046810
ProtocolInfo protocol_info;
68056811
if (!GetProtocolTypeInfo(ToCompilerType(GetSwiftType(type)), protocol_info))
68066812
break;
@@ -6912,6 +6918,7 @@ uint32_t SwiftASTContext::GetNumPointeeChildren(opaque_compiler_type_t type) {
69126918
case swift::TypeKind::Function:
69136919
case swift::TypeKind::GenericFunction:
69146920
case swift::TypeKind::ProtocolComposition:
6921+
case swift::TypeKind::Existential:
69156922
return 0;
69166923
case swift::TypeKind::LValue:
69176924
return 1;
@@ -7230,7 +7237,8 @@ CompilerType SwiftASTContext::GetChildCompilerTypeAtIndex(
72307237
}
72317238

72327239
case swift::TypeKind::Protocol:
7233-
case swift::TypeKind::ProtocolComposition: {
7240+
case swift::TypeKind::ProtocolComposition:
7241+
case swift::TypeKind::Existential: {
72347242
ProtocolInfo protocol_info;
72357243
if (!GetProtocolTypeInfo(ToCompilerType(GetSwiftType(type)), protocol_info))
72367244
break;
@@ -7468,7 +7476,8 @@ size_t SwiftASTContext::GetIndexOfChildMemberWithName(
74687476
} break;
74697477

74707478
case swift::TypeKind::Protocol:
7471-
case swift::TypeKind::ProtocolComposition: {
7479+
case swift::TypeKind::ProtocolComposition:
7480+
case swift::TypeKind::Existential: {
74727481
ProtocolInfo protocol_info;
74737482
if (!GetProtocolTypeInfo(ToCompilerType(GetSwiftType(type)),
74747483
protocol_info))
@@ -7864,6 +7873,7 @@ bool SwiftASTContext::DumpTypeValue(
78647873
} break;
78657874

78667875
case swift::TypeKind::ProtocolComposition:
7876+
case swift::TypeKind::Existential:
78677877
case swift::TypeKind::UnboundGeneric:
78687878
case swift::TypeKind::BoundGenericStruct:
78697879
case swift::TypeKind::DynamicSelf:
@@ -8151,6 +8161,21 @@ void SwiftASTContext::DumpTypeDescription(opaque_compiler_type_t type,
81518161
s->Printf("%s\n", buffer.c_str());
81528162
break;
81538163
}
8164+
case swift::TypeKind::Existential: {
8165+
swift::ExistentialType *existential_type =
8166+
swift_can_type->castTo<swift::ExistentialType>();
8167+
std::string buffer;
8168+
llvm::raw_string_ostream ostream(buffer);
8169+
const swift::PrintOptions &print_options(
8170+
SwiftASTContext::GetUserVisibleTypePrintingOptions(
8171+
print_help_if_available));
8172+
8173+
existential_type->print(ostream, print_options);
8174+
ostream.flush();
8175+
if (buffer.empty() == false)
8176+
s->Printf("%s\n", buffer.c_str());
8177+
break;
8178+
}
81548179
default: {
81558180
swift::NominalType *nominal_type =
81568181
llvm::dyn_cast_or_null<swift::NominalType>(

0 commit comments

Comments
 (0)