Skip to content

Conversation

@adrian-prantl
Copy link

This is done by defering to the Objective-C runtime. This functionality is implemented in the visitor because ObjC object typerefs are fully valid reference types in the Swift reflection descriptors already and only LLDB wants to look inside them.

rdar://154450536

@adrian-prantl
Copy link
Author

@swift-ci test

@adrian-prantl
Copy link
Author

Updated the test, the previous one didn't actually exercise the new code m-(

@adrian-prantl
Copy link
Author

@swift-ci test

@adrian-prantl adrian-prantl changed the title [LLDB] Add ObjC object typeref support to SwiftRuntimeTypeVisitor [DRAFT] [LLDB] Add ObjC object typeref support to SwiftRuntimeTypeVisitor Dec 4, 2025
@adrian-prantl adrian-prantl changed the title [DRAFT] [LLDB] Add ObjC object typeref support to SwiftRuntimeTypeVisitor [LLDB] Add ObjC object typeref support to SwiftRuntimeTypeVisitor Dec 8, 2025
@adrian-prantl
Copy link
Author

@swift-ci test


if (!ts)
return llvm::createStringError("no clang type system");
clang::EnumDecl *enum_decl = ts->GetAsEnumDecl(clang_type);

Choose a reason for hiding this comment

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

Is it possible to refactor this in a way where we don't directly manipulate the clang decls in swift language runtime?

Choose a reason for hiding this comment

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

Ideally we'd be able to move a lot of this function to the clang type system, since this is a clang type after all.

Copy link
Author

Choose a reason for hiding this comment

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

Maybe, I think it's reasonable for the parts that deal with Clang interoperability to rely on Clang-specific details.

if (!n_or_err)
return n_or_err.takeError();
unsigned n = *n_or_err;
bool is_signed, is_enum = clang_type.IsEnumerationType(is_signed);

Choose a reason for hiding this comment

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

Is the usage of is_signed here correct? You're both declaring it and passing it to IsEnumerationType.

Copy link
Author

Choose a reason for hiding this comment

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

this is equivalent to

 bool is_signed;
bool is_enum = clang_type.IsEnumerationType(is_signed);

return bit_size.takeError();
ChildInfo child;
child.byte_size = *bit_size / 8;
child.byte_offset = 0;

Choose a reason for hiding this comment

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

Is byte_offset = 0 really correct here? If this is a struct with an objc field won't this cause problems?

Copy link
Author

Choose a reason for hiding this comment

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

This is the is_enum case.

@adrian-prantl adrian-prantl force-pushed the 154450536 branch 3 times, most recently from 89ea55b to d1706f5 Compare December 9, 2025 19:33
This patch moves the disjunct implementations for
TypeSystemTypeRef::GetNumFields and GetIndexOfChildMemberWithName into
the TypeRef visitor, so they behave consistently.

rdar://154450536
@adrian-prantl
Copy link
Author

@swift-ci test

1 similar comment
@adrian-prantl
Copy link
Author

@swift-ci test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants