Skip to content

[lldb] Implement TypeSystemSwiftTypeRef::ShouldPrintAsOneLiner #2231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2327,12 +2327,29 @@ CompilerType
TypeSystemSwiftTypeRef::GetTypeForFormatters(opaque_compiler_type_t type) {
return m_swift_ast_context->GetTypeForFormatters(ReconstructType(type));
}

LazyBool
TypeSystemSwiftTypeRef::ShouldPrintAsOneLiner(opaque_compiler_type_t type,
ValueObject *valobj) {
return m_swift_ast_context->ShouldPrintAsOneLiner(ReconstructType(type),
valobj);
auto impl = [&]() {
if (type) {
if (IsImportedType(type, nullptr))
return eLazyBoolNo;
}
if (valobj) {
if (valobj->IsBaseClass())
return eLazyBoolNo;
if ((valobj->GetLanguageFlags() & LanguageFlags::eIsIndirectEnumCase) ==
LanguageFlags::eIsIndirectEnumCase)
return eLazyBoolNo;
}

return eLazyBoolCalculate;
};
VALIDATE_AND_RETURN(impl, ShouldPrintAsOneLiner, type,
(ReconstructType(type), valobj));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks sufficiently generic that you could hoist it all the way into the TypeSystemSwift base class and delete the SwiftASTContext implementation.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's nothing TypeSystemSwiftTypeRef-specific.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That said, I'm also fine with landing it as is and doing that as an NFC refactor later.

}

bool TypeSystemSwiftTypeRef::IsMeaninglessWithoutDynamicResolution(
opaque_compiler_type_t type) {
auto impl = [&]() {
Expand Down