Skip to content

Commit ded03e6

Browse files
committed
[lldb] Add test for swift generic parameterized by C++ types
rdar://100284870
1 parent c97b798 commit ded03e6

File tree

5 files changed

+56
-0
lines changed

5 files changed

+56
-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: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
"""
3+
Test that printing Swift generic types with C++ types parameters works
4+
"""
5+
from lldbsuite.test.lldbtest import *
6+
from lldbsuite.test.decorators import *
7+
8+
9+
class TestSwiftGenericWithCxxType(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 classWrapper', substrs=['Wrapper<CxxClass>', 't', 'a1 = 10',
19+
'a2 = 20', 'a3 = 30'])
20+
self.expect('expr classWrapper', substrs=['Wrapper<CxxClass>', 't', 'a1 = 10',
21+
'a2 = 20', 'a3 = 30'])
22+
23+
self.expect('v subclassWrapper', substrs=['Wrapper<CxxSubclass>', 't',
24+
'CxxClass = (a1 = 10, a2 = 20, a3 = 30)', 'a4 = 40'])
25+
self.expect('expr subclassWrapper', substrs=['Wrapper<CxxSubclass>', 't',
26+
'CxxClass = (a1 = 10, a2 = 20, a3 = 30)', 'a4 = 40'])
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import ReturnsClass
2+
3+
struct Wrapper<T> {
4+
let t: T
5+
}
6+
func main() {
7+
let classWrapper = Wrapper(t: CxxClass())
8+
let subclassWrapper = Wrapper(t: CxxSubclass())
9+
print(1) // Set breakpoint here
10+
}
11+
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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
struct CxxClass {
3+
long long a1 = 10;
4+
long long a2 = 20;
5+
long long a3 = 30;
6+
};
7+
8+
9+
struct CxxSubclass: CxxClass {
10+
long long a4 = 40;
11+
};

0 commit comments

Comments
 (0)