Skip to content

Commit 36fc1b5

Browse files
authored
Merge pull request #3805 from apple/jdevlieghere/cherrypick-8d8ea5c13b49b5617b62e1b8aeb22a5b1257cb03
[lldb] Teach LLDB about ExistentialType in the Swift AST.
2 parents b97743b + 4887eab commit 36fc1b5

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

57415741
case swift::TypeKind::Protocol:
57425742
case swift::TypeKind::ProtocolComposition:
5743+
case swift::TypeKind::Existential:
57435744
swift_flags |= eTypeHasChildren | eTypeIsStructUnion | eTypeIsProtocol;
57445745
break;
57455746
case swift::TypeKind::ExistentialMetatype:
@@ -5821,6 +5822,7 @@ lldb::TypeClass SwiftASTContext::GetTypeClass(opaque_compiler_type_t type) {
58215822
case swift::TypeKind::DependentMember:
58225823
case swift::TypeKind::Protocol:
58235824
case swift::TypeKind::ProtocolComposition:
5825+
case swift::TypeKind::Existential:
58245826
case swift::TypeKind::Metatype:
58255827
case swift::TypeKind::Module:
58265828
case swift::TypeKind::PrimaryArchetype:
@@ -6320,6 +6322,7 @@ lldb::Encoding SwiftASTContext::GetEncoding(opaque_compiler_type_t type,
63206322
case swift::TypeKind::Struct:
63216323
case swift::TypeKind::Protocol:
63226324
case swift::TypeKind::ProtocolComposition:
6325+
case swift::TypeKind::Existential:
63236326
break;
63246327
case swift::TypeKind::LValue:
63256328
return lldb::eEncodingUint;
@@ -6408,7 +6411,8 @@ uint32_t SwiftASTContext::GetNumChildren(opaque_compiler_type_t type,
64086411
}
64096412

64106413
case swift::TypeKind::Protocol:
6411-
case swift::TypeKind::ProtocolComposition: {
6414+
case swift::TypeKind::ProtocolComposition:
6415+
case swift::TypeKind::Existential: {
64126416
ProtocolInfo protocol_info;
64136417
if (!GetProtocolTypeInfo(ToCompilerType(GetSwiftType(type)), protocol_info))
64146418
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:
@@ -6817,7 +6822,8 @@ CompilerType SwiftASTContext::GetFieldAtIndex(opaque_compiler_type_t type,
68176822
}
68186823

68196824
case swift::TypeKind::Protocol:
6820-
case swift::TypeKind::ProtocolComposition: {
6825+
case swift::TypeKind::ProtocolComposition:
6826+
case swift::TypeKind::Existential: {
68216827
ProtocolInfo protocol_info;
68226828
if (!GetProtocolTypeInfo(ToCompilerType(GetSwiftType(type)), protocol_info))
68236829
break;
@@ -6927,6 +6933,7 @@ uint32_t SwiftASTContext::GetNumPointeeChildren(opaque_compiler_type_t type) {
69276933
case swift::TypeKind::Function:
69286934
case swift::TypeKind::GenericFunction:
69296935
case swift::TypeKind::ProtocolComposition:
6936+
case swift::TypeKind::Existential:
69306937
return 0;
69316938
case swift::TypeKind::LValue:
69326939
return 1;
@@ -7245,7 +7252,8 @@ CompilerType SwiftASTContext::GetChildCompilerTypeAtIndex(
72457252
}
72467253

72477254
case swift::TypeKind::Protocol:
7248-
case swift::TypeKind::ProtocolComposition: {
7255+
case swift::TypeKind::ProtocolComposition:
7256+
case swift::TypeKind::Existential: {
72497257
ProtocolInfo protocol_info;
72507258
if (!GetProtocolTypeInfo(ToCompilerType(GetSwiftType(type)), protocol_info))
72517259
break;
@@ -7482,7 +7490,8 @@ size_t SwiftASTContext::GetIndexOfChildMemberWithName(
74827490
} break;
74837491

74847492
case swift::TypeKind::Protocol:
7485-
case swift::TypeKind::ProtocolComposition: {
7493+
case swift::TypeKind::ProtocolComposition:
7494+
case swift::TypeKind::Existential: {
74867495
ProtocolInfo protocol_info;
74877496
if (!GetProtocolTypeInfo(ToCompilerType(GetSwiftType(type)),
74887497
protocol_info))
@@ -7876,6 +7885,7 @@ bool SwiftASTContext::DumpTypeValue(
78767885
} break;
78777886

78787887
case swift::TypeKind::ProtocolComposition:
7888+
case swift::TypeKind::Existential:
78797889
case swift::TypeKind::UnboundGeneric:
78807890
case swift::TypeKind::BoundGenericStruct:
78817891
case swift::TypeKind::DynamicSelf:
@@ -8167,6 +8177,21 @@ void SwiftASTContext::DumpTypeDescription(opaque_compiler_type_t type,
81678177
s->Printf("%s\n", buffer.c_str());
81688178
break;
81698179
}
8180+
case swift::TypeKind::Existential: {
8181+
swift::ExistentialType *existential_type =
8182+
swift_can_type->castTo<swift::ExistentialType>();
8183+
std::string buffer;
8184+
llvm::raw_string_ostream ostream(buffer);
8185+
const swift::PrintOptions &print_options(
8186+
SwiftASTContext::GetUserVisibleTypePrintingOptions(
8187+
print_help_if_available));
8188+
8189+
existential_type->print(ostream, print_options);
8190+
ostream.flush();
8191+
if (buffer.empty() == false)
8192+
s->Printf("%s\n", buffer.c_str());
8193+
break;
8194+
}
81708195
default: {
81718196
swift::NominalType *nominal_type =
81728197
llvm::dyn_cast_or_null<swift::NominalType>(

0 commit comments

Comments
 (0)