Skip to content

Commit 46f6b72

Browse files
skip implicit clang decls in the duplicate-decl assertion
SR-15801 rdar://88299954
1 parent 2d75d7f commit 46f6b72

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/AST/Module.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,14 @@ void ModuleDecl::getDisplayDecls(SmallVectorImpl<Decl*> &Results) const {
963963
#ifndef NDEBUG
964964
llvm::DenseSet<Decl *> visited;
965965
for (auto *D : Results) {
966+
// decls synthesized from implicit clang decls may appear multiple times;
967+
// e.g. if multiple modules with underlying clang modules are re-exported.
968+
// including duplicates of these is harmless, so skip them when counting
969+
// this assertion
970+
if (const auto *CD = D->getClangDecl()) {
971+
if (CD->isImplicit()) continue;
972+
}
973+
966974
auto inserted = visited.insert(D).second;
967975
assert(inserted && "there should be no duplicate decls");
968976
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -I %S/Inputs/Submodules -emit-module-path %t/Submodules.swiftmodule -enable-objc-interop -module-name Submodules %s -emit-symbol-graph -emit-symbol-graph-dir %t
2+
// RUN: cp -r %S/Inputs/EmitWhileBuilding/EmitWhileBuilding.framework %t
3+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-objc-interop -emit-module-path %t/EmitWhileBuilding.framework/Modules/EmitWhileBuilding.swiftmodule/%target-swiftmodule-name -import-underlying-module -F %t -module-name EmitWhileBuilding -disable-objc-attr-requires-foundation-module %S/EmitWhileBuilding.swift
4+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -I %S/Inputs/Submodules -emit-module-path %t/Submodules.swiftmodule -enable-objc-interop -module-name Submodules -F %t %s -emit-symbol-graph -emit-symbol-graph-dir %t
35

46
// REQUIRES: objc_interop
57

@@ -8,4 +10,6 @@
810
@_exported import Mixed
911
@_exported import Mixed.Submodule
1012

13+
@_exported import EmitWhileBuilding
14+
1115
public func someFunc() {}

0 commit comments

Comments
 (0)