Skip to content

Commit 2285c51

Browse files
authored
Merge pull request #58428 from apple/egorzhdan/cxx-sil-deserialization
[cxx-interop] Fix SIL deserialization error
2 parents f652a9d + 8c58a77 commit 2285c51

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2629,6 +2629,10 @@ bool importer::shouldSuppressDeclImport(const clang::Decl *decl) {
26292629
return false;
26302630
}
26312631

2632+
if (isa<clang::BuiltinTemplateDecl>(decl)) {
2633+
return true;
2634+
}
2635+
26322636
return false;
26332637
}
26342638

lib/ClangImporter/SwiftLookupTable.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1925,13 +1925,29 @@ void importer::addEntryToLookupTable(SwiftLookupTable &table,
19251925
// Walk the members of any context that can have nested members.
19261926
if (isa<clang::TagDecl>(named) || isa<clang::ObjCInterfaceDecl>(named) ||
19271927
isa<clang::ObjCProtocolDecl>(named) ||
1928-
isa<clang::ObjCCategoryDecl>(named) || isa<clang::NamespaceDecl>(named)) {
1928+
isa<clang::ObjCCategoryDecl>(named)) {
19291929
clang::DeclContext *dc = cast<clang::DeclContext>(named);
19301930
for (auto member : dc->decls()) {
19311931
if (auto namedMember = dyn_cast<clang::NamedDecl>(member))
19321932
addEntryToLookupTable(table, namedMember, nameImporter);
19331933
}
19341934
}
1935+
if (isa<clang::NamespaceDecl>(named)) {
1936+
llvm::SmallPtrSet<clang::Decl *, 8> alreadyAdded;
1937+
alreadyAdded.insert(named->getCanonicalDecl());
1938+
1939+
for (auto redecl : named->redecls()) {
1940+
auto dc = cast<clang::DeclContext>(redecl);
1941+
for (auto member : dc->decls()) {
1942+
auto canonicalMember = member->getCanonicalDecl();
1943+
if (!alreadyAdded.insert(canonicalMember).second)
1944+
continue;
1945+
1946+
if (auto namedMember = dyn_cast<clang::NamedDecl>(canonicalMember))
1947+
addEntryToLookupTable(table, namedMember, nameImporter);
1948+
}
1949+
}
1950+
}
19351951
}
19361952

19371953
/// Returns the nearest parent of \p module that is marked \c explicit in its

test/Interop/Cxx/class/nested-records-module-interface.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
// CHECK: struct ForwardDeclaredFriend {
8383
// CHECK: init()
8484
// CHECK: }
85-
// CHECK: static func takesFriend(_ b: NestedDeclIsAFirstForwardDeclaration.ForwardDeclaredFriend)
85+
// CHECK: static func takesFriend(_ f: NestedDeclIsAFirstForwardDeclaration.ForwardDeclaredFriend)
8686
// CHECK: struct HasNestedForwardDeclaration {
8787
// CHECK: init()
8888
// CHECK: struct IsNestedForwardDeclaration {

test/Interop/Cxx/namespace/templates-module-interface.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@
4747
// CHECK-NEXT: }
4848
// CHECK-NEXT: typealias ForwardDeclaredClassTemplateOutOfLineChar = TemplatesNS1.TemplatesNS2.__CxxTemplateInstN12TemplatesNS112TemplatesNS237ForwardDeclaredClassTemplateOutOfLineIcEE
4949
// CHECK-NEXT: enum TemplatesNS4 {
50-
// CHECK-NEXT: struct __CxxTemplateInstN12TemplatesNS417HasSpecializationIiEE {
50+
// CHECK-NEXT: struct __CxxTemplateInstN12TemplatesNS417HasSpecializationIcEE {
5151
// CHECK-NEXT: init()
5252
// CHECK-NEXT: }
53-
// CHECK-NEXT: struct __CxxTemplateInstN12TemplatesNS417HasSpecializationIcEE {
53+
// CHECK-NEXT: struct __CxxTemplateInstN12TemplatesNS417HasSpecializationIiEE {
5454
// CHECK-NEXT: init()
5555
// CHECK-NEXT: }
5656
// CHECK-NEXT: struct HasSpecialization<> {

0 commit comments

Comments
 (0)