Skip to content

Commit b3a7079

Browse files
committed
[lldb] Fix expression evaluation in static functions in actors
Instead of trying to discern if lldb is stopped in a static or class function, always generate the function as static in either of those cases, since static works for classes/actors/structs/enums and for expression evaluation purposes a static or class function will work exactly the same. rdar://152446035
1 parent 18ffb87 commit b3a7079

File tree

4 files changed

+56
-3
lines changed

4 files changed

+56
-3
lines changed

lldb/source/Plugins/ExpressionParser/Swift/SwiftExpressionSourceCode.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,6 @@ do {
430430
if (needs_object_ptr || static_method) {
431431
const char *func_decorator = "";
432432
if (static_method) {
433-
if (is_class)
434-
func_decorator = "final class";
435-
else
436433
func_decorator = "static";
437434
} else if (is_class && !weak_self) {
438435
func_decorator = "final";
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: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# TestSwiftExpressionsInClassFunctions.py
2+
#
3+
# This source file is part of the Swift.org open source project
4+
#
5+
# Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
6+
# Licensed under Apache License v2.0 with Runtime Library Exception
7+
#
8+
# See https://swift.org/LICENSE.txt for license information
9+
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
#
11+
# ------------------------------------------------------------------------------
12+
"""
13+
Test expressions in the context of class functions
14+
"""
15+
import lldb
16+
from lldbsuite.test.lldbtest import *
17+
from lldbsuite.test.decorators import *
18+
import lldbsuite.test.lldbutil as lldbutil
19+
import os
20+
21+
22+
class TestSwiftExpressionActor(TestBase):
23+
@swiftTest
24+
def test_static_func(self):
25+
self.build()
26+
lldbutil.run_to_source_breakpoint(
27+
self, "break here for static", lldb.SBFileSpec("main.swift")
28+
)
29+
30+
self.expect("expr self", substrs=["A.Type"])
31+
32+
@swiftTest
33+
def test_func(self):
34+
self.build()
35+
lldbutil.run_to_source_breakpoint(
36+
self, "break here for func", lldb.SBFileSpec("main.swift")
37+
)
38+
39+
self.expect("expr self", substrs=["(a.A)", "i = 42", 's = "Hello"'])
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
actor A {
2+
let i = 42
3+
let s = "Hello"
4+
static func foo() {
5+
print("break here for static")
6+
}
7+
8+
func bar() {
9+
print("break here for func")
10+
}
11+
}
12+
13+
A.foo()
14+
await A().bar()

0 commit comments

Comments
 (0)