Skip to content

Commit 38d25e7

Browse files
committed
[lldb] Add actor test and Swift/C++ interop actor test
rdar://100284870
1 parent 11017a3 commit 38d25e7

File tree

8 files changed

+82
-1
lines changed

8 files changed

+82
-1
lines changed

lldb/packages/Python/lldbsuite/test/make/Makefile.rules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ $(SWIFT_CXX_HEADER): $(SWIFT_SOURCES) $(SWIFT_BRIDGING_PCH)
730730
@echo "### Building C++ header from Swift" $<
731731
$(SWIFT_FE) -typecheck $(VPATHSOURCES) \
732732
$(SWIFT_FEFLAGS) $(SWIFT_HFLAGS) -module-name $(MODULENAME) \
733-
-emit-clang-header-path $(SWIFT_CXX_HEADER)
733+
$(SWIFT_CXX_HEADER_FLAGS) -emit-clang-header-path $(SWIFT_CXX_HEADER)
734734
endif
735735

736736
else # USESWIFTDRIVER = 0
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
SWIFT_CXX_HEADER := swift-types.h
2+
SWIFT_SOURCES := swift-types.swift
3+
CXX_SOURCES := main.cpp
4+
SWIFT_CXX_INTEROP := 1
5+
SWIFTFLAGS_EXTRAS = -Xcc -I$(SRCDIR) -parse-as-library
6+
SWIFT_CXX_HEADER_FLAGS = -clang-header-expose-decls=has-expose-attr
7+
CFLAGS = -I. -g
8+
include Makefile.rules
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
"""
3+
Test that Swift types are displayed correctly in C++
4+
"""
5+
from lldbsuite.test.lldbtest import *
6+
from lldbsuite.test.decorators import *
7+
8+
9+
class TestFormatActors(TestBase):
10+
11+
@swiftTest
12+
def test_class(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.cpp'))
17+
18+
self.expect('v actor', substrs=['Actor', 'str = "Hello"'])
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include "swift-types.h"
2+
3+
int main() {
4+
using namespace a;
5+
auto actor = getActor();
6+
return 0; // Set breakpoint here.
7+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@_expose(Cxx)
2+
public final actor Actor {
3+
let str = "Hello"
4+
}
5+
6+
@_expose(Cxx)
7+
public func getActor() -> Actor {
8+
return Actor()
9+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SWIFT_SOURCES := main.swift
2+
3+
include Makefile.rules
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""
2+
Test swift Class types
3+
"""
4+
import lldb
5+
from lldbsuite.test.lldbtest import *
6+
from lldbsuite.test.decorators import *
7+
import lldbsuite.test.lldbutil as lldbutil
8+
import os
9+
import unittest2
10+
11+
12+
class TestSwiftActorTypes(TestBase):
13+
14+
mydir = TestBase.compute_mydir(__file__)
15+
16+
@swiftTest
17+
def test_swift_class_types(self):
18+
"""Test swift Actor types"""
19+
self.build()
20+
_, _, _, _= lldbutil.run_to_source_breakpoint(
21+
self, 'Set breakpoint here', lldb.SBFileSpec('main.swift'))
22+
23+
self.expect('v actor', substrs=['Actor', 'str = "Hello"'])
24+
self.expect('expr actor', substrs=['Actor', 'str = "Hello"'])
25+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
actor Actor {
2+
let str = "Hello"
3+
}
4+
5+
func main() -> Int
6+
{
7+
var actor = Actor()
8+
return 0 // Set breakpoint here
9+
}
10+
11+
main()

0 commit comments

Comments
 (0)