Skip to content

[cxx-interop] fix a clang assertion when synthesizing instance to sta… #76235

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

Closed
wants to merge 1 commit into from

Conversation

hyp
Copy link
Contributor

@hyp hyp commented Sep 4, 2024

…tic member call for operator ()

A specific static operator () in MSVC's STL triggers this assertion in clang when buidling CxxStdlib: Assertion failed: isInstance() && "No 'this' for static methods!", file S:\SourceCache\llvm-project\clang\lib\AST\DeclCXX.cpp, line 2544 When the return statement is being constructed using clang sema in Swift's function synthesis code.

This change avoids using member call expression for a call to static operator (), and instead performs a direct call, which closer matches what Clang's semas typechecker expects, and the default Clang's parsing behavior as well.

This fixes the windows toolchain build with MSVC.

@hyp
Copy link
Contributor Author

hyp commented Sep 4, 2024

@swift-ci please test

…tic member call for operator ()

A specific static operator () in MSVC's STL triggers this assertion in clang when buidling CxxStdlib:
Assertion failed: isInstance() && "No 'this' for static methods!", file S:\SourceCache\llvm-project\clang\lib\AST\DeclCXX.cpp, line 2544
When the return statement is being constructed using clang sema in
Swift's function synthesis code.

This change avoids using member call expression for a call to static
operator (), and instead performs a direct call, which closer matches
what Clang's semas typechecker expects, and the default Clang's parsing
behavior as well.

This fixes the windows toolchain build with MSVC.
@hyp hyp force-pushed the eng/fix-operator-call-synt branch from a6451ed to 16b0c2a Compare September 4, 2024 01:04
@hyp
Copy link
Contributor Author

hyp commented Sep 4, 2024

@swift-ci please test

@compnerd compnerd enabled auto-merge September 4, 2024 05:22
@egorzhdan egorzhdan disabled auto-merge September 4, 2024 11:39
@egorzhdan
Copy link
Contributor

Hmm, I haven't seen this on the main branch before. Is this the same issue as something we've seen on rebranch: #75907?

@egorzhdan egorzhdan requested a review from Xazax-hun September 4, 2024 12:07
@compnerd
Copy link
Member

compnerd commented Sep 4, 2024

@swift-ci please test Windows platform

@compnerd
Copy link
Member

compnerd commented Sep 4, 2024

@egorzhdan hmm, I think it is - and I do like your patch better. Could we cherry-pick that to main?

@egorzhdan
Copy link
Contributor

Sure! I'll put up a PR within an hour

@compnerd
Copy link
Member

compnerd commented Sep 4, 2024

@egorzhdan - could you please include the test case from this and ensure that still passes with your change? The one thing that I noticed is that you explicitly special cased static operator ().

egorzhdan added a commit that referenced this pull request Sep 4, 2024
Extracted from #76235.

Co-authored-by: Alex Lorenz <[email protected]>
@egorzhdan
Copy link
Contributor

I just put up a PR: #76252

@hyp
Copy link
Contributor Author

hyp commented Sep 4, 2024

Thanks!

@hyp
Copy link
Contributor Author

hyp commented Sep 4, 2024

Closing in favor of #76252

@hyp hyp closed this Sep 4, 2024
compnerd pushed a commit to compnerd/apple-swift that referenced this pull request Sep 17, 2024
compnerd pushed a commit to compnerd/apple-swift that referenced this pull request Sep 17, 2024
compnerd pushed a commit to compnerd/apple-swift that referenced this pull request Sep 20, 2024
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.

3 participants