Skip to content

Commit a976288

Browse files
committed
improve handling of clang imported enums
1 parent 48fd6e6 commit a976288

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2856,14 +2856,20 @@ bool TypeSystemSwiftTypeRef::DumpTypeValue(
28562856
case Node::Kind::BoundGenericStructure:
28572857
return false;
28582858
case Node::Kind::Structure: {
2859-
// In rare instances, a Swift `Structure` wraps an ObjC enum. An example
2860-
// is `$sSo16ComparisonResultVD`. For now, use `SwiftASTContext` to handle
2861-
// these enum structs.
2859+
// In some instances, a swift `structure` wraps an objc enum. The enum
2860+
// case needs to be handled, but structs are no-ops.
28622861
auto resolved = ResolveTypeAlias(m_swift_ast_context, dem, node, true);
28632862
auto clang_type = std::get<CompilerType>(resolved);
2863+
if (!clang_type)
2864+
return false;
2865+
28642866
bool is_signed;
28652867
if (!clang_type.IsEnumerationType(is_signed))
2868+
// The type is a clang struct, not an enum.
28662869
return false;
2870+
2871+
// The type is an enum imported from clang. Try Swift type metadata first,
2872+
// and failing that fallback to the AST.
28672873
LLVM_FALLTHROUGH;
28682874
}
28692875
case Node::Kind::Enum:
@@ -2879,8 +2885,8 @@ bool TypeSystemSwiftTypeRef::DumpTypeValue(
28792885
return true;
28802886
}
28812887
}
2882-
s->PutCString("<unknown type>");
2883-
return false;
2888+
2889+
return {};
28842890
}
28852891
default:
28862892
assert(false && "Unhandled node kind");

0 commit comments

Comments
 (0)