Skip to content

Commit f48f772

Browse files
committed
Test for #78981
**Without #78981**: This test triggers "Reflection section too small to contain next record" errors, indicating that the field information is broken. **With #78981**: This test runs to completion without triggering the error message above.
1 parent 8c63134 commit f48f772

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: split-file %s %t
3+
// %target-clangxx -c %S/Inputs/Cxx/pimpl.cpp -I %S/Inputs/Cxx -o %t/pimpl.o
4+
// RUN: %target-build-swift -lswiftSwiftReflectionTest %t/reflect_Cxx.swift -I %t -cxx-interoperability-mode=default -o %t/reflect_Cxx
5+
// RUN: %target-codesign %t/reflect_Cxx
6+
7+
// RUN: %target-run %target-swift-reflection-test %t/reflect_Cxx | tee /dev/stderr | %FileCheck %s
8+
9+
// REQUIRES: reflection_test_support
10+
// REQUIRES: executable_test
11+
// UNSUPPORTED: use_os_stdlib
12+
// UNSUPPORTED: asan
13+
14+
//--- module.modulemap
15+
16+
module CxxStruct {
17+
header "CxxStruct.h"
18+
requires cplusplus
19+
export *
20+
}
21+
22+
//--- CxxStruct.h
23+
24+
struct CxxStructA {
25+
private:
26+
int i;
27+
};
28+
29+
inline CxxStructA createCxxStructA() {
30+
return CxxStructA();
31+
}
32+
33+
//--- reflect_Cxx.swift
34+
35+
import SwiftReflectionTest
36+
import CxxStruct
37+
38+
// Trigger type metadata to be emitted by conforming C++ types to a Swift protocol.
39+
protocol MyProto {}
40+
extension CxxStructA : MyProto {}
41+
42+
let a = createCxxStructA()
43+
reflect(any: a)
44+
45+
// CHECK: Reflecting an existential.
46+
// CHECK-NEXT: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
47+
// CHECK-NEXT: Type reference:
48+
// CHECK-NEXT: (struct __C.CxxStructA)
49+
50+
// CHECK: Type info:
51+
// CHECK-NEXT: (builtin size=4 alignment=4 stride=4 num_extra_inhabitants=0 bitwise_takable=1)
52+
// CHECK-NEXT: Mangled name: $sSo10CxxStructAV
53+
// CHECK-NEXT: Demangled name: __C.CxxStructA
54+
55+
// CHECK: Start of instance data: 0x{{[0-9a-fA-F]+}}
56+
57+
doneReflecting()
58+
59+
// CHECK: Done.

0 commit comments

Comments
 (0)