Skip to content

Commit 8d8ea5c

Browse files
committed
[lldb] Teach LLDB about ExistentialType in the Swift AST.
1 parent 143f138 commit 8d8ea5c

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
@@ -5737,6 +5737,7 @@ SwiftASTContext::GetTypeInfo(opaque_compiler_type_t type,
57375737

57385738
case swift::TypeKind::Protocol:
57395739
case swift::TypeKind::ProtocolComposition:
5740+
case swift::TypeKind::Existential:
57405741
swift_flags |= eTypeHasChildren | eTypeIsStructUnion | eTypeIsProtocol;
57415742
break;
57425743
case swift::TypeKind::ExistentialMetatype:
@@ -5818,6 +5819,7 @@ lldb::TypeClass SwiftASTContext::GetTypeClass(opaque_compiler_type_t type) {
58185819
case swift::TypeKind::DependentMember:
58195820
case swift::TypeKind::Protocol:
58205821
case swift::TypeKind::ProtocolComposition:
5822+
case swift::TypeKind::Existential:
58215823
case swift::TypeKind::Metatype:
58225824
case swift::TypeKind::Module:
58235825
case swift::TypeKind::PrimaryArchetype:
@@ -6319,6 +6321,7 @@ lldb::Encoding SwiftASTContext::GetEncoding(opaque_compiler_type_t type,
63196321
case swift::TypeKind::Struct:
63206322
case swift::TypeKind::Protocol:
63216323
case swift::TypeKind::ProtocolComposition:
6324+
case swift::TypeKind::Existential:
63226325
break;
63236326
case swift::TypeKind::LValue:
63246327
return lldb::eEncodingUint;
@@ -6407,7 +6410,8 @@ uint32_t SwiftASTContext::GetNumChildren(opaque_compiler_type_t type,
64076410
}
64086411

64096412
case swift::TypeKind::Protocol:
6410-
case swift::TypeKind::ProtocolComposition: {
6413+
case swift::TypeKind::ProtocolComposition:
6414+
case swift::TypeKind::Existential: {
64116415
ProtocolInfo protocol_info;
64126416
if (!GetProtocolTypeInfo(ToCompilerType(GetSwiftType(type)), protocol_info))
64136417
break;
@@ -6546,6 +6550,7 @@ uint32_t SwiftASTContext::GetNumFields(opaque_compiler_type_t type,
65466550

65476551
case swift::TypeKind::Protocol:
65486552
case swift::TypeKind::ProtocolComposition:
6553+
case swift::TypeKind::Existential:
65496554
return GetNumChildren(type, /*omit_empty_base_classes=*/false, nullptr);
65506555

65516556
case swift::TypeKind::ExistentialMetatype:
@@ -6818,7 +6823,8 @@ CompilerType SwiftASTContext::GetFieldAtIndex(opaque_compiler_type_t type,
68186823
}
68196824

68206825
case swift::TypeKind::Protocol:
6821-
case swift::TypeKind::ProtocolComposition: {
6826+
case swift::TypeKind::ProtocolComposition:
6827+
case swift::TypeKind::Existential: {
68226828
ProtocolInfo protocol_info;
68236829
if (!GetProtocolTypeInfo(ToCompilerType(GetSwiftType(type)), protocol_info))
68246830
break;
@@ -6930,6 +6936,7 @@ uint32_t SwiftASTContext::GetNumPointeeChildren(opaque_compiler_type_t type) {
69306936
case swift::TypeKind::Function:
69316937
case swift::TypeKind::GenericFunction:
69326938
case swift::TypeKind::ProtocolComposition:
6939+
case swift::TypeKind::Existential:
69336940
return 0;
69346941
case swift::TypeKind::LValue:
69356942
return 1;
@@ -7248,7 +7255,8 @@ CompilerType SwiftASTContext::GetChildCompilerTypeAtIndex(
72487255
}
72497256

72507257
case swift::TypeKind::Protocol:
7251-
case swift::TypeKind::ProtocolComposition: {
7258+
case swift::TypeKind::ProtocolComposition:
7259+
case swift::TypeKind::Existential: {
72527260
ProtocolInfo protocol_info;
72537261
if (!GetProtocolTypeInfo(ToCompilerType(GetSwiftType(type)), protocol_info))
72547262
break;
@@ -7486,7 +7494,8 @@ size_t SwiftASTContext::GetIndexOfChildMemberWithName(
74867494
} break;
74877495

74887496
case swift::TypeKind::Protocol:
7489-
case swift::TypeKind::ProtocolComposition: {
7497+
case swift::TypeKind::ProtocolComposition:
7498+
case swift::TypeKind::Existential: {
74907499
ProtocolInfo protocol_info;
74917500
if (!GetProtocolTypeInfo(ToCompilerType(GetSwiftType(type)),
74927501
protocol_info))
@@ -7882,6 +7891,7 @@ bool SwiftASTContext::DumpTypeValue(
78827891
} break;
78837892

78847893
case swift::TypeKind::ProtocolComposition:
7894+
case swift::TypeKind::Existential:
78857895
case swift::TypeKind::UnboundGeneric:
78867896
case swift::TypeKind::BoundGenericStruct:
78877897
case swift::TypeKind::DynamicSelf:
@@ -8169,6 +8179,21 @@ void SwiftASTContext::DumpTypeDescription(opaque_compiler_type_t type,
81698179
s->Printf("%s\n", buffer.c_str());
81708180
break;
81718181
}
8182+
case swift::TypeKind::Existential: {
8183+
swift::ExistentialType *existential_type =
8184+
swift_can_type->castTo<swift::ExistentialType>();
8185+
std::string buffer;
8186+
llvm::raw_string_ostream ostream(buffer);
8187+
const swift::PrintOptions &print_options(
8188+
SwiftASTContext::GetUserVisibleTypePrintingOptions(
8189+
print_help_if_available));
8190+
8191+
existential_type->print(ostream, print_options);
8192+
ostream.flush();
8193+
if (buffer.empty() == false)
8194+
s->Printf("%s\n", buffer.c_str());
8195+
break;
8196+
}
81728197
default: {
81738198
swift::NominalType *nominal_type =
81748199
llvm::dyn_cast_or_null<swift::NominalType>(

0 commit comments

Comments
 (0)