Skip to content

Commit 6c80c68

Browse files
authored
[ClangImporter] Do not import function decl if already imported via type signature (#85480)
This is a small incremental patch that is designed to address the issue discovered by 9aa3c5d, which is that we are importing various Decls multiple times. rdar://164616956
1 parent d468b5f commit 6c80c68

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3853,8 +3853,8 @@ namespace {
38533853
if (!dc)
38543854
return nullptr;
38553855

3856-
// We may have already imported this function decl before we imported the
3857-
// parent record. In such a case it's important we don't re-import.
3856+
// We may have already imported this function decl while importing its
3857+
// decl context. Check decl cache to make sure we don't import twice.
38583858
auto known = Impl.ImportedDecls.find({decl, getVersion()});
38593859
if (known != Impl.ImportedDecls.end()) {
38603860
return known->second;
@@ -3994,6 +3994,13 @@ namespace {
39943994
return nullptr;
39953995
}
39963996

3997+
// We may have already imported this function decl while importing its
3998+
// type signature. Check decl cache to make sure we don't import twice.
3999+
auto known2 = Impl.ImportedDecls.find({decl, getVersion()});
4000+
if (known2 != Impl.ImportedDecls.end()) {
4001+
return known2->second;
4002+
}
4003+
39974004
if (name && name.isSimpleName()) {
39984005
assert(importedName.hasCustomName() &&
39994006
"imported function with simple name?");

0 commit comments

Comments
 (0)