Skip to content

Conversation

@felipepiovezan
Copy link

@felipepiovezan felipepiovezan commented Jun 27, 2025

There are two possible variants of constructors: allocating (Kind::Allocator)
and initializing (Kind::Constructor). When mangling a closure, the "context"
is arbitrarily chosen to be the initializing variant.
As such, we need to check both when looking for the parent of a closure.
If both exist, `Kind::Constructor` is the one containing user code, so
it is always checked first.

rdar://154309468

@felipepiovezan felipepiovezan requested a review from a team as a code owner June 27, 2025 21:04
@felipepiovezan
Copy link
Author

@swift-ci test please

Choose a reason for hiding this comment

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

Suggested change
// There are two possible variants of constructors: allocating (Kind::Allocator)
/// There are two possible variants of constructors: allocating (Kind::Allocator)

Choose a reason for hiding this comment

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

We already do so many demangle operations when resolving types that I would rather demangle again here rather than hardcode details of the mangling scheme.

Copy link
Author

@felipepiovezan felipepiovezan Jun 27, 2025

Choose a reason for hiding this comment

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

It's not so much about demangling again, it's about reconstructing the entire demangle tree.
There is no "node.setKind", we are forced to rebuild everything, and I don't think there are any APIs today to do this

Copy link
Author

Choose a reason for hiding this comment

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

I think I found a way to do it.

Choose a reason for hiding this comment

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

I would write this as

print("break_ctor_enum")
return $0 

for more breakpoint stability

Copy link
Author

Choose a reason for hiding this comment

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

I'll update it, but note that this will be different from all other entries in this file.

There are two possible variants of constructors: allocating (Kind::Allocator)
and initializing (Kind::Constructor). When mangling a closure, the "context"
is arbitrarily chosen to be the initializing variant.
As such, we need to check both when looking for the parent of a closure.
If both exist, `Kind::Constructor` is the one containing user code, so
it is always checked first.

rdar://154309468
@felipepiovezan felipepiovezan force-pushed the felipe/fix_diagnostic_2 branch from bc68c1e to b42c7f0 Compare June 30, 2025 15:32
@felipepiovezan
Copy link
Author

@swift-ci test

@adrian-prantl adrian-prantl merged commit c7c1565 into swiftlang:swift/release/6.2 Jun 30, 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