Skip to content

Commit 15b6595

Browse files
committed
[lldb] SwiftLanguageRuntime: Support Clang typedef-to-enums.
This also relaxes the check for the name of the member in GetIndexOfChildMemberWithName for Clang enums, since the result is always 1 anyway. rdar://147905814 (cherry picked from commit fba81d1)
1 parent 00bcdcc commit 15b6595

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeDynamicTypeResolution.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,15 @@ void LogUnimplementedTypeKind(const char *function, CompilerType type) {
695695
#endif
696696
}
697697

698+
CompilerType GetCanonicalClangType(CompilerType type) {
699+
for (unsigned i = 0; i < 32; ++i) {
700+
if (!type.IsTypedefType())
701+
return type;
702+
type = type.GetTypedefedType();
703+
}
704+
return type;
705+
}
706+
698707
} // namespace
699708

700709
llvm::Expected<uint32_t>
@@ -721,6 +730,7 @@ SwiftLanguageRuntime::GetNumChildren(CompilerType type,
721730
if (!clang_type)
722731
ts.IsImportedType(type.GetOpaqueQualType(), &clang_type);
723732
if (clang_type) {
733+
clang_type = GetCanonicalClangType(clang_type);
724734
bool is_signed;
725735
if (clang_type.IsEnumerationType(is_signed))
726736
return 1;
@@ -1150,11 +1160,12 @@ SwiftLanguageRuntime::GetIndexOfChildMemberWithName(
11501160
}
11511161
}
11521162
case TypeInfoKind::Builtin: {
1153-
// Clang enums have an artificial rawValue property.
11541163
CompilerType clang_type;
11551164
if (ts.IsImportedType(type.GetOpaqueQualType(), &clang_type)) {
1165+
clang_type = GetCanonicalClangType(clang_type);
11561166
bool is_signed;
1157-
if (clang_type.IsEnumerationType(is_signed) && name == "rawValue") {
1167+
if (clang_type.IsEnumerationType(is_signed)) {
1168+
// Clang enums have an artificial rawValue property.
11581169
child_indexes.push_back(0);
11591170
return {SwiftLanguageRuntime::eFound, {1}};
11601171
}

0 commit comments

Comments
 (0)