Skip to content

Commit c2c36d0

Browse files
committed
[Serialization] Fix reporting a dependency cycle with a missing clang module
rdar://problem/57364033
1 parent 8b45b5a commit c2c36d0

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

lib/Serialization/SerializedModuleLoader.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,8 @@ void swift::serialization::diagnoseSerializedASTLoadFailure(
747747
auto circularDependencyIter =
748748
llvm::find_if(loadedModuleFile->getDependencies(),
749749
[](const ModuleFile::Dependency &next) {
750-
return !next.Import.second->hasResolvedImports();
750+
return next.isLoaded() &&
751+
!next.Import.second->hasResolvedImports();
751752
});
752753
assert(circularDependencyIter !=
753754
loadedModuleFile->getDependencies().end() &&
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//// Report dependency cycles involving missing clang modules without crashing
2+
//// rdar://problem/57364033
3+
4+
// RUN: %empty-directory(%t)
5+
// RUN: cp -r %S/Inputs/custom-modules %t/
6+
7+
// RUN: %target-swift-frontend -emit-module -DLIB_A %s -module-name A -emit-module-path %t/A.swiftmodule
8+
// RUN: %target-swift-frontend -emit-module -DLIB_B %s -module-name B -emit-module-path %t/B.swiftmodule -I %t -I %t/custom-modules
9+
// RUN: %target-swift-frontend -emit-module -DLIB_C %s -module-name C -emit-module-path %t/C.swiftmodule -I %t
10+
11+
//// Delete the clang module
12+
// RUN: rm -r %t/custom-modules/
13+
14+
// RUN: not %target-swift-frontend -emit-module -DLIB_D %s -module-name A -emit-module-path %t/D.swiftmodule -I %t 2>&1 | %FileCheck %s
15+
16+
#if LIB_A
17+
18+
#elseif LIB_B
19+
20+
import IndirectImport // From custom-modules
21+
import A
22+
23+
#elseif LIB_C
24+
25+
import B
26+
27+
#elseif LIB_D
28+
29+
import C
30+
// CHECK: <unknown>:0: error: circular dependency between modules 'A' and 'B'
31+
32+
#endif

0 commit comments

Comments
 (0)