Skip to content

Commit 9f71f46

Browse files
committed
[Serialization] Test the output on a crash due to a broken XRef
1 parent c5c850c commit 9f71f46

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/// Test xref error description by removing a type from a module after building
2+
/// a client.
3+
// RUN: %empty-directory(%t)
4+
5+
/// Compile module A with a type and an empty module B.
6+
// RUN: %target-swift-frontend %s -emit-module-path %t/A.swiftmodule -module-name A -D LIB
7+
// RUN: %target-swift-frontend %s -emit-module-path %t/B.swiftmodule -module-name B
8+
#if LIB
9+
public struct SomeType {
10+
public init() {}
11+
}
12+
13+
/// Compile a client using the type from A.
14+
// RUN: %target-swift-frontend %s -emit-module-path %t/Client.swiftmodule -module-name Client -D CLIENT -I %t
15+
#elseif CLIENT
16+
import A
17+
import B
18+
19+
public func foo() -> A.SomeType { fatalError() }
20+
21+
/// Swap A and B around! A is now empty and B defines the type.
22+
// RUN: %target-swift-frontend %s -emit-module-path %t/A.swiftmodule -module-name A
23+
// RUN: %target-swift-frontend %s -emit-module-path %t/B.swiftmodule -module-name B -D LIB
24+
#endif // Empty
25+
26+
/// Read from the client to get an xref error to the type missing from A.
27+
// RUN: not --crash %target-swift-frontend -emit-sil %t/Client.swiftmodule -module-name Client -I %t -disable-deserialization-recovery 2> %t/stderr
28+
29+
// RUN: cat %t/stderr | %FileCheck %s
30+
// CHECK: *** DESERIALIZATION FAILURE (please include this section in any bug report) ***
31+
// CHECK-NEXT: Could not deserialize type for 'foo()'
32+
// CHECK-NEXT: Caused by: top-level value not found
33+
// CHECK-NEXT: Cross-reference to 'SomeType' in module 'A'
34+
// CHECK-NEXT: Notes:
35+
// CHECK-NEXT: * 'SomeType' was not found in module 'B', but there is one in module 'B'. If this is imported from clang, please make sure the header is part of a single clang module.

0 commit comments

Comments
 (0)