Skip to content

Commit e3d871e

Browse files
Merge pull request #5768 from adrian-prantl/task_alloc
Add a test for dynamically allocated task variables.
2 parents 18bbb58 + 57fc2a3 commit e3d871e

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

lldb/test/API/lang/swift/async/frame/variable/TestSwiftAsyncFrameVar.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ def test(self):
2323
b = frame.FindVariable("b")
2424
self.assertTrue(b.IsValid())
2525
self.assertEqual(b.unsigned, 0)
26+
d = frame.FindVariable("d")
27+
lldbutil.check_variable(self, d, False, value='23')
2628

2729
# The first breakpoint resolves to multiple locations, but only the
2830
# first location is needed. Now that we've stopped, delete it to
@@ -42,3 +44,5 @@ def test(self):
4244
b = frame.FindVariable("b")
4345
self.assertTrue(b.IsValid())
4446
self.assertGreater(b.unsigned, 0)
47+
d = frame.FindVariable("d")
48+
lldbutil.check_variable(self, d, False, value='23')

lldb/test/API/lang/swift/async/frame/variable/main.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ func randInt(_ i: Int) async -> Int {
22
return Int.random(in: 1...i)
33
}
44

5-
func inner() async {
5+
func inner<T>(_ t: T) async {
6+
// d is dynamically allocated by swift_task_alloc() because its size
7+
// is unknown.
8+
let d = t
69
let a = await randInt(30)
710
let b = await randInt(a + 11) // break one
8-
use(a, b) // break two
11+
use(a, b)
12+
use(d) // break two
913
}
1014

1115
func use<T>(_ t: T...) {}
@@ -15,6 +19,6 @@ func use<T>(_ t: T...) {}
1519
// This call to `inner` is a indirection required to make this test work.
1620
// If its contents were inlined into `main` (as it was originally written),
1721
// the test would fail.
18-
await inner()
22+
await inner(23)
1923
}
2024
}

0 commit comments

Comments
 (0)