Skip to content

🍒[cxx-interop] Fix printing of namespaces declared in bridging headers #82420

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 24, 2025

Conversation

egorzhdan
Copy link
Contributor

  • Explanation: If a C++ namespace has redeclarations in a bridging header, printing AST for the namespace would crash the compiler. This is because such a redeclaration would not have an owning Clang module, and the AST printer did not account for that.
  • Scope: This change adds a null check in AST printer.
  • Issues: rdar://151715540
  • Original PRs: [cxx-interop] Fix printing of namespaces declared in bridging headers #82413
  • Risk: Low, this only changes a code path that would previously crash.
  • Testing: Added a compiler test.
  • Reviewers: @QuietMisdreavus @Xazax-hun @j-hui

If a C++ namespace has redeclarations in a bridging header, printing AST for the namespace would crash the compiler. This is because such a redeclaration would not have an owning Clang module, and the AST printer did not account for that.

This change fixes the crash.

rdar://151715540
(cherry picked from commit cc9c51d)
@egorzhdan egorzhdan requested a review from a team as a code owner June 23, 2025 18:03
@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Jun 23, 2025
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan
Copy link
Contributor Author

@swift-ci please test macOS

@egorzhdan egorzhdan merged commit a686f32 into release/6.2 Jun 24, 2025
5 checks passed
@egorzhdan egorzhdan deleted the egorzhdan/6.2-namespace-printer-null-crash branch June 24, 2025 21:35
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.

4 participants