Skip to content

skip implicit clang decls in the duplicate-decl assertion #41115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/AST/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,14 @@ void ModuleDecl::getDisplayDecls(SmallVectorImpl<Decl*> &Results) const {
#ifndef NDEBUG
llvm::DenseSet<Decl *> visited;
for (auto *D : Results) {
// decls synthesized from implicit clang decls may appear multiple times;
// e.g. if multiple modules with underlying clang modules are re-exported.
// including duplicates of these is harmless, so skip them when counting
// this assertion
if (const auto *CD = D->getClangDecl()) {
if (CD->isImplicit()) continue;
}

auto inserted = visited.insert(D).second;
assert(inserted && "there should be no duplicate decls");
}
Expand Down
6 changes: 5 additions & 1 deletion test/SymbolGraph/ClangImporter/Submodules.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// RUN: %empty-directory(%t)
// 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
// RUN: cp -r %S/Inputs/EmitWhileBuilding/EmitWhileBuilding.framework %t
// 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
// 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

// REQUIRES: objc_interop

Expand All @@ -8,4 +10,6 @@
@_exported import Mixed
@_exported import Mixed.Submodule

@_exported import EmitWhileBuilding

public func someFunc() {}