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