Skip to content

Commit 4662e28

Browse files
authored
Merge pull request #6433 from augusto2112/test-cxx-as-existential
[lldb] Test that a C++ class as a Swift existential is printed correctly
2 parents c97b798 + 9f22659 commit 4662e28

File tree

5 files changed

+54
-0
lines changed

5 files changed

+54
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
SWIFT_SOURCES := main.swift
2+
SWIFT_CXX_INTEROP := 1
3+
SWIFTFLAGS_EXTRAS = -Xcc -I$(SRCDIR)
4+
include Makefile.rules
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
"""
3+
Test that a C++ class as an existential is visible in Swift.
4+
"""
5+
from lldbsuite.test.lldbtest import *
6+
from lldbsuite.test.decorators import *
7+
8+
9+
class TestClass(TestBase):
10+
11+
@swiftTest
12+
def test(self):
13+
self.build()
14+
self.runCmd('setting set target.experimental.swift-enable-cxx-interop true')
15+
_, _, _, _= lldbutil.run_to_source_breakpoint(
16+
self, 'Set breakpoint here', lldb.SBFileSpec('main.swift'))
17+
18+
self.expect('v x', substrs=['CxxClass', 'a1 = 10', 'a2 = 20', 'a3 = 30'])
19+
self.expect('expr x', substrs=['CxxClass', 'a1 = 10', 'a2 = 20', 'a3 = 30'])
20+
21+
self.expect('v y', substrs=['InheritedCxxClass', 'a1 = 10', 'a2 = 20', 'a3 = 30', 'a4 = 40'])
22+
self.expect('expr y', substrs=['InheritedCxxClass', 'a1 = 10', 'a2 = 20', 'a3 = 30', 'a4 = 40'])
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import ReturnsClass
2+
3+
protocol P {}
4+
5+
extension CxxClass: P{}
6+
7+
extension InheritedCxxClass: P{}
8+
9+
func main() {
10+
let x: P = CxxClass()
11+
let y:P = InheritedCxxClass()
12+
print(1) // Set breakpoint here
13+
}
14+
main()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module ReturnsClass {
2+
header "returns-class.h"
3+
requires cplusplus
4+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
struct CxxClass {
3+
long long a1 = 10;
4+
long long a2 = 20;
5+
long long a3 = 30;
6+
};
7+
8+
struct InheritedCxxClass: CxxClass {
9+
long long a4 = 40;
10+
};

0 commit comments

Comments
 (0)