Skip to content

[lldb] check for interop type aliases in tests#13086

Open
hnrklssn wants to merge 2 commits into
swiftlang:stable/21.xfrom
hnrklssn:lldb-use-c-types
Open

[lldb] check for interop type aliases in tests#13086
hnrklssn wants to merge 2 commits into
swiftlang:stable/21.xfrom
hnrklssn:lldb-use-c-types

Conversation

@hnrklssn

Copy link
Copy Markdown
Member

This updates two tests to align with the new behavior in swiftlang/swift#89531

This updates two tests to align with the new behavior in
swiftlang/swift#89531
Now that the Swift compiler no longer strips typedefs from the AST of
nodes imported from clang, we need to do this in LLDB instead.
Fixes assertion in
lang/swift/dwarfimporter/Objective-C/TestSwiftDWARFImporterObjC.py:
```
[2026-06-03T13:19:10.059Z] TypeSystemSwiftTypeRef diverges from SwiftASTContext: $ss4CIntaD != $ss5Int32VD
[2026-06-03T13:19:10.059Z] failing type was $ss4CIntaD
[2026-06-03T13:19:10.059Z] Assertion failed: (equivalent && "TypeSystemSwiftTypeRef diverges from SwiftASTContext"), function GetCanonicalType, file TypeSystemSwiftTypeRef.cpp, line 3950.
```

Assisted-by: Claude Opus 4.7
// without consulting DWARF or the runtime: these aliases come from the
// Swift stdlib and have stable per-target underlying types, so keying
// them off the triple is sufficient.
if (NodePointer resolved = ResolveStdlibCInteropAlias(dem, node, GetTriple()))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is my attempt to resolve this assertion failure in lang/swift/dwarfimporter/Objective-C/TestSwiftDWARFImporterObjC.py:

[2026-06-03T03:30:15.212Z] TypeSystemSwiftTypeRef diverges from SwiftASTContext: $ss4CIntaD != $ss5Int32VD
[2026-06-03T03:30:15.212Z] failing type was $ss4CIntaD
[2026-06-03T03:30:15.212Z] Assertion failed: (equivalent && "TypeSystemSwiftTypeRef diverges from SwiftASTContext"), function GetCanonicalType, file TypeSystemSwiftTypeRef.cpp, line 3949.

@adrian-prantl adrian-prantl left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It is not great to hardcode these aliases in LLDB, but I also don't see a good way of making them available reliably in -gast-types. TypeSystemSwiftTypeRef doesn't have access to the Swift swiftmodule and we don't generate DWARF for fields outside of embedded Swift. So I'm afraid this is the way to go.

Can you ask Claude to add an LLDB API test that exercises the complete list of types you add here?
I.e.: main.swift

func f() {
  let char : CChar = 1
  ...

and in the test you do lldbutil.check_variable() and verify we get the typename correct?

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