Skip to content

[lldb] SwiftLanguageRuntime: Support Clang typedef-to-enums. #10392

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
merged 2 commits into from
Apr 1, 2025

Conversation

adrian-prantl
Copy link

@adrian-prantl adrian-prantl commented Apr 1, 2025

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

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
@adrian-prantl adrian-prantl requested a review from a team as a code owner April 1, 2025 00:17
@adrian-prantl adrian-prantl requested review from augusto2112 and kastiglione and removed request for a team April 1, 2025 00:17
@adrian-prantl
Copy link
Author

@swift-ci test

@@ -695,6 +695,15 @@ void LogUnimplementedTypeKind(const char *function, CompilerType type) {
#endif
}

CompilerType GetCanonicalClangType(CompilerType type) {
for (unsigned i = 0; i < 32; ++i) {

Choose a reason for hiding this comment

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

Why 32? Is this just an arbitrary limit? If so I'd raise it to 1024 or something like that...

Copy link
Author

Choose a reason for hiding this comment

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

It's an arbitrary limit to guard against cycles.
It's for chains of typedefs, so practically I wouldn't expect more than two to ever appear, but I'm fine with dialing up the limit a bit.

@@ -695,6 +695,15 @@ void LogUnimplementedTypeKind(const char *function, CompilerType type) {
#endif
}

CompilerType GetCanonicalClangType(CompilerType type) {

Choose a reason for hiding this comment

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

Why is this called CanonicalClangType? There doesn't seem to be anything specific about clang in this function.

Choose a reason for hiding this comment

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

I guess this would only be a canonical type if it's a clang type, since untypedefing wouldn't necessarily result in a canonical Swift type, right? Maybe add an assert or early return if this isn't a clang type?

Copy link
Author

Choose a reason for hiding this comment

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

You're right, the function itself is generic, but I wanted to differentiate it from TypeSystemSwiftTypeRef::GetCanonicalNode, which also resolves arbitrarily deep nested Swift type aliases.
I like the idea of asserting that it's a clang type.

@adrian-prantl
Copy link
Author

@swift-ci test macos

@adrian-prantl
Copy link
Author

I'll address the feedback in a follow-up commit.

@adrian-prantl adrian-prantl merged commit 9564f05 into swiftlang:stable/20240723 Apr 1, 2025
3 checks passed
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.

2 participants