Skip to content

[Macros] Don't visit auxiliary decls of class members twice. #64915

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

Conversation

DougGregor
Copy link
Member

To ensure that class vtables get laid out with the right ABI, visiting a class declaration visits all of its "ABI members", which includes visiting all of the auxiliary declarations. However, we also visit the auxiliary declarations of every declaration, which means some declarations get visited twice.

This led to another oddly-specific bug for macros, where we would visit declarations introduce by peer macros on class members twice. When combined with function-body-skipping (e.g., to emit a module file), this would result in spurious errors of the form:

Expected '{' in body of function declaration

Stop visiting the auxiliary declarations of class members twice, eliminating this error. This one has been annoying me off and on for a while :).

Fixes rdar://107429169.

To ensure that class vtables get laid out with the right ABI, visiting
a class declaration visits all of its "ABI members", which includes
visiting all of the auxiliary declarations. However, we also visit the
auxiliary declarations of every declaration, which means some
declarations get visited twice.

This led to another oddly-specific bug for macros, where we would
visit declarations introduce by peer macros on class members twice.
When combined with function-body-skipping (e.g., to emit a module
file), this would result in spurious errors of the form:

    Expected '{' in body of function declaration

Stop visiting the auxiliary declarations of class members twice,
eliminating this error. This one has been annoying me off and on for a
while :).

Fixes rdar://107429169.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor DougGregor merged commit 950c5bb into swiftlang:main Apr 4, 2023
@DougGregor DougGregor deleted the visit-aux-decls-of-class-members-twice branch April 4, 2023 22:41
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