Skip to content

Test for #78981 #79038

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions validation-test/Reflection/reflect_Cxx.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,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.