Skip to content

[cxx-interop] Fix generated declaration order #74384

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
Jun 13, 2024
Merged

Conversation

Xazax-hun
Copy link
Contributor

The generated thunks for functions can refer to some internal methods of their arguments. As a result, those generated thunks should always be after the definitions of the corresponding argument types. The printer ordered the declarations by name, and Swift had the convention starting types with upper case letters and functions with lower case letters. This naming convention together with the ordering resulted in the correct ordering in most of the cases. There were a couple of exceptions when people diverged from the naming conventions or wanted to export operators. This patch fixes this problem by always ordering type decls before function decls.

rdar://129276354

@Xazax-hun Xazax-hun added the c++ interop Feature: Interoperability with C++ label Jun 13, 2024
@Xazax-hun
Copy link
Contributor Author

@swift-ci please smoke test

The generated thunks for functions can refer to some internal methods of
their arguments. As a result, those generated thunks should always be
after the definitions of the corresponding argument types. The printer
ordered the declarations by name, and Swift had the convention starting
types with upper case letters and functions with lower case letters.
This naming convention together with the ordering resulted in the
correct ordering in most of the cases. There were a couple of exceptions
when people diverged from the naming conventions or wanted to export
operators. This patch fixes this problem by always ordering type decls
before function decls.

rdar://129276354
@Xazax-hun Xazax-hun force-pushed the gaborh/print-decl-order branch from bfdc2ba to dbdd983 Compare June 13, 2024 14:22
@Xazax-hun
Copy link
Contributor Author

@swift-ci please smoke test

Copy link
Contributor

@egorzhdan egorzhdan left a comment

Choose a reason for hiding this comment

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

LGTM!

@Xazax-hun Xazax-hun merged commit c0c28c4 into main Jun 13, 2024
3 checks passed
@Xazax-hun Xazax-hun deleted the gaborh/print-decl-order branch June 13, 2024 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants