Skip to content

Commit 1d96eca

Browse files
authored
Merge pull request #82738 from artemcm/62_DepScanFixCycleDetection
[6.2 🍒][Dependency Scanning] On cycle via overlay, fix Clang dependency path reconstruction
2 parents 43d8b13 + 2f07a98 commit 1d96eca

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

lib/DependencyScan/ScanDependencies.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ findClangDepPath(const ModuleDependencyID &from, const ModuleDependencyID &to,
11101110
}
11111111

11121112
// Otherwise, visit each child node.
1113-
for (const auto &succID : cache.getAllDependencies(moduleID)) {
1113+
for (const auto &succID : cache.getImportedClangDependencies(moduleID)) {
11141114
stack.push(succID);
11151115
visit(succID);
11161116
stack.pop();
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// REQUIRES: objc_interop
2+
// RUN: %empty-directory(%t)
3+
// RUN: %empty-directory(%t/module-cache)
4+
// RUN: %empty-directory(%t/inputs)
5+
// RUN: split-file %s %t
6+
// RUN: not %target-swift-frontend -scan-dependencies -module-cache-path %t/module-cache %t/test.swift -o %t/deps.json -I %t/inputs -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import -module-name CycleKit &> %t/out.txt
7+
// RUN: %FileCheck %s < %t/out.txt
8+
9+
// CHECK: error: module dependency cycle: 'CycleKit (Source Target) -> A.swiftinterface -> CycleKit.swiftinterface'
10+
// CHECK: note: Swift Overlay dependency of 'A' on 'CycleKit' via Clang module dependency: 'A.swiftinterface -> A.pcm -> B.pcm -> CycleKit.pcm'
11+
12+
//--- test.swift
13+
import A
14+
15+
//--- inputs/CycleKit.swiftinterface
16+
// swift-interface-format-version: 1.0
17+
// swift-module-flags: -module-name CycleKit -enable-library-evolution
18+
19+
public func CycleKitFunc() {}
20+
21+
//--- inputs/A.swiftinterface
22+
// swift-interface-format-version: 1.0
23+
// swift-module-flags: -module-name A -enable-library-evolution
24+
@_exported import A
25+
public func AFunc() {}
26+
27+
//--- inputs/A.h
28+
#import <B.h>
29+
void funcA(void);
30+
31+
//--- inputs/B.h
32+
#import <CycleKit.h>
33+
void funcA(void);
34+
35+
//--- inputs/CycleKit.h
36+
void funcCycleKit(void);
37+
38+
//--- inputs/module.modulemap
39+
module A {
40+
header "A.h"
41+
export *
42+
}
43+
44+
module B {
45+
header "B.h"
46+
export *
47+
}
48+
49+
module CycleKit {
50+
header "CycleKit.h"
51+
export *
52+
}

0 commit comments

Comments
 (0)