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