@@ -28,8 +28,17 @@ namespace {
2828// /
2929// / This does a by-name comparison to consider a module's underlying Clang module to be equivalent
3030// / to the wrapping module of the same name.
31- bool areModulesEqual (const ModuleDecl *lhs, const ModuleDecl *rhs) {
32- return lhs->getNameStr () == rhs->getNameStr ();
31+ // /
32+ // / If the `isClangEqual` argument is set to `false`, the modules must also be from the same
33+ // / compiler, i.e. a Swift module and its underlying Clang module would be considered not equal.
34+ bool areModulesEqual (const ModuleDecl *lhs, const ModuleDecl *rhs, bool isClangEqual = true ) {
35+ if (lhs->getNameStr () != rhs->getNameStr ())
36+ return false ;
37+
38+ if (!isClangEqual && (lhs->isNonSwiftModule () != rhs->isNonSwiftModule ()))
39+ return false ;
40+
41+ return true ;
3342}
3443
3544} // anonymous namespace
@@ -303,9 +312,9 @@ bool SymbolGraphASTWalker::isConsideredExportedImported(const Decl *D) const {
303312 return false ;
304313}
305314
306- bool SymbolGraphASTWalker::isFromExportedImportedModule (const Decl* D) const {
315+ bool SymbolGraphASTWalker::isFromExportedImportedModule (const Decl* D, bool countUnderlyingClangModule ) const {
307316 auto *M = D->getModuleContext ();
308- return isQualifiedExportedImport (D) || isExportedImportedModule (M);
317+ return isQualifiedExportedImport (D) || isExportedImportedModule (M, countUnderlyingClangModule );
309318}
310319
311320bool SymbolGraphASTWalker::isQualifiedExportedImport (const Decl *D) const {
@@ -314,9 +323,9 @@ bool SymbolGraphASTWalker::isQualifiedExportedImport(const Decl *D) const {
314323 });
315324}
316325
317- bool SymbolGraphASTWalker::isExportedImportedModule (const ModuleDecl *M) const {
318- return llvm::any_of (ExportedImportedModules, [&M](const auto *MD) {
319- return areModulesEqual (M, MD->getModuleContext ());
326+ bool SymbolGraphASTWalker::isExportedImportedModule (const ModuleDecl *M, bool countUnderlyingClangModule ) const {
327+ return llvm::any_of (ExportedImportedModules, [&M, countUnderlyingClangModule ](const auto *MD) {
328+ return areModulesEqual (M, MD->getModuleContext (), /* isClangEqual */ countUnderlyingClangModule );
320329 });
321330}
322331
0 commit comments