Skip to content

[lldb][NativePDB] Recognize bound generic pattern#12824

Open
speednoisemovement wants to merge 2 commits intoswiftlang:stable/21.xfrom
speednoisemovement:unnamed
Open

[lldb][NativePDB] Recognize bound generic pattern#12824
speednoisemovement wants to merge 2 commits intoswiftlang:stable/21.xfrom
speednoisemovement:unnamed

Conversation

@speednoisemovement
Copy link
Copy Markdown

Bound generic types are represented by nested structs arranged in a certain way (see swiftlang/swift#87093 for details).

Similar to DWARF, this change adds special handling to recognize this pattern and recover the mangled name of the actual type.

Bound generic types are represented by nested structs
arranged in a certain way (see swiftlang/swift#87093
for details).

Similar to DWARF, this change adds special handling to
recognize this pattern and recover the mangled name of the
actual type.
@speednoisemovement speednoisemovement requested a review from a team as a code owner April 22, 2026 22:44
@speednoisemovement
Copy link
Copy Markdown
Author

@swift-ci Please test

@@ -18,6 +18,15 @@ enum Direction {
case south
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Since this is a NativePDB test, is it running on macOS? Asking since the lldb swift tests are currently not enabled on Windows.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

As of #12610 yes, unless something changed (I know because I had to remove the XFAIL on this test to land it!)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Wait, I misread the question. It's not running on macOS (requires system-windows) is running on Windows last I checked.

// https://github.com/swiftlang/swift/issues/87093
// FIXME: This is more of a heuristic than a definitive check, but we would need to do a
// second field-list walk to be sure.
return cr.Name.ends_with("::<unnamed-tag>");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Given the example you gave here: swiftlang/swift#87093 (comment), could MSVC emit ::<unnamed-tag> for a C/C++ type?

If tha'ts the case, thisIsSwiftType would return true on a non Swift type.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If this is possible, we should:

  • Avoid false positives by checking that the outer type is a swift type.
  • Add a negative test in swift-frame-var.test.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yup, I can wire the field-list walk up twice. My thinking for not doing it was the perf gain and of not doing it is worth the edge case (no unique name, no name C/C++ type that nevertheless has something useful that TypeSystemClang can squeeze out of it) and cleaner code. I think probably both the perf hit is small and the edge case is not likely to matter though.

What would a good negative case look like?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I tried to build a C++ type that has ::<unnamed-tag> in its name and does not have a unique name but I could not manage to do it. That would have been a good negative test but it does not seem to be possible.

My concern was unfounded.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yep, AFAICT Clang can't produce it, but maybe another compiler can? I added the full check to IsSwiftType since the perf hit isn't that bad and the cognitive overhead is probably worth us being sure.

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