Skip to content

[lldb] Change the type alias resolution algorithm #10036

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 1 commit into from
Feb 17, 2025

Conversation

adrian-prantl
Copy link

from a post-oder to a pre-order traversal. This is necessary to resolve generic type aliases that bind other type aliases in one go, instead of first resolving the bound type aliases. Debug Info will have a record for SomeAlias<SomeOtherAlias> but not SomeAlias<WhatSomeOtherAliasResolvesTo> because it tries to preserve all sugar.

rdar://144884987

@adrian-prantl adrian-prantl requested a review from a team as a code owner February 15, 2025 01:14
@adrian-prantl adrian-prantl requested review from augusto2112 and kastiglione and removed request for a team February 15, 2025 01:14
@adrian-prantl
Copy link
Author

@swift-ci test

default:
break;
default: {
llvm::SmallVector<NodePointer, 2> children;

Choose a reason for hiding this comment

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

Is this code meant to both be here and in GetCanonicalNode?

@@ -514,12 +522,6 @@ class TypeSystemSwiftTypeRef : public TypeSystemSwift {
CompilerType LookupClangForwardType(llvm::StringRef name,
llvm::ArrayRef<CompilerContext> decl_context);

/// Recursively resolves all type aliases.
swift::Demangle::NodePointer

Choose a reason for hiding this comment

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

ResolveAllTypeAliases is gone from the header but not implementation?

Copy link
Author

Choose a reason for hiding this comment

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

It never existed!

return TypeSystemSwiftTypeRef::Transform(dem, node, [&](NodePointer node) {
return Canonicalize(dem, node, flavor);
});
NodePointer transformed = Canonicalize(dem, node, flavor);

Choose a reason for hiding this comment

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

Should this block of code be in a separate function called TransformPreOrder?

Copy link
Author

Choose a reason for hiding this comment

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

There is only a single use, and it has shortcut in that it won't traverse the children of a transformed node, which is something a generic preorder transform maybe shouldn't do, so I decided to punt on that until we have a second use-case.

/// Desugar to this node and if it is a type alias resolve it by
/// looking up its type in the debug info.
swift::Demangle::NodePointer
Canonicalize(swift::Demangle::Demangler &dem,

Choose a reason for hiding this comment

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

Why were these functions moved to be public? I don't see you using them anywhere outside TypeSystemSwiftTypeRef

Copy link
Author

Choose a reason for hiding this comment

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

Fixed.

from a post-oder to a pre-order traversal.  This is necessary to
resolve generic type aliases that bind other type aliases in one go,
instead of first resolving the bound type aliases.  Debug Info will
have a record for `SomeAlias<SomeOtherAlias>` but not
`SomeAlias<WhatSomeOtherAliasResolvesTo>` because it tries to preserve
all sugar.

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

@swift-ci test

@adrian-prantl
Copy link
Author

@swift-ci test

@adrian-prantl adrian-prantl merged commit 372857b into swiftlang:stable/20240723 Feb 17, 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