From 2409e339281959fa7fd26e44e80d985922558990 Mon Sep 17 00:00:00 2001 From: Egor Zhdan Date: Fri, 22 Aug 2025 17:51:38 +0100 Subject: [PATCH] [cxx-interop] Fix an assertion for `extern "C"` blocks rdar://158896622 / resolves https://github.com/swiftlang/swift/issues/83861 --- lib/AST/ASTMangler.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/AST/ASTMangler.cpp b/lib/AST/ASTMangler.cpp index b7f53971dcc8b..b3fc1430b35fd 100644 --- a/lib/AST/ASTMangler.cpp +++ b/lib/AST/ASTMangler.cpp @@ -2560,6 +2560,8 @@ ASTMangler::getSpecialManglingContext(const ValueDecl *decl, hasNameForLinkage = !clangDecl->getDeclName().isEmpty(); if (hasNameForLinkage) { auto *clangDC = clangDecl->getDeclContext(); + while (isa(clangDC)) + clangDC = clangDC->getParent(); // In C, "nested" structs, unions, enums, etc. will become siblings: // struct Foo { struct Bar { }; }; -> struct Foo { }; struct Bar { }; // Whereas in C++, nested records will actually be nested. So if this is