Skip to content

Commit 313b95f

Browse files
committed
[lldb][test] Add test for parsing Objective-C synthesized properties
Prior to llvm#164998, recent LLDB versions would fail to parse synthesized property setters correctly. The only way this failure would manifest is an error to the console: ``` error: main.o [0x00000000000000cd]: invalid Objective-C method DW_TAG_subprogram (DW_TAG_subprogram), please file a bug and attach the file at the start of this error message ``` There weren't any Objective-C tests that failed when the original regression (llvm#100355) landed. This patch adds a test that explicitly checks that the type of the setter is sensible. This test fails without llvm#164998 and passes with it. I decided not to check for the absence of the console error because that kind of test would be fragile to the removal of (or any changes to) the error message.
1 parent 538c850 commit 313b95f

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
OBJC_SOURCES := main.m
2+
LDFLAGS := -lobjc
3+
4+
include Makefile.rules
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""
2+
Test debug-info parsing of synthesized Objective-C properties.
3+
"""
4+
5+
import lldb
6+
from lldbsuite.test.lldbtest import *
7+
from lldbsuite.test import lldbutil
8+
9+
10+
class TestSynthesizedPropertyAccessor(TestBase):
11+
def test(self):
12+
self.build()
13+
14+
(target, _, _, _) = lldbutil.run_to_source_breakpoint(
15+
self, "return f.fooProp", lldb.SBFileSpec("main.m")
16+
)
17+
18+
getters = target.FindFunctions("-[Foo fooProp]", lldb.eFunctionNameTypeSelector)
19+
self.assertEqual(len(getters), 1)
20+
getter = getters[0].function.GetType()
21+
self.assertTrue(getter)
22+
self.assertEqual(getter.GetDisplayTypeName(), "int ()")
23+
24+
setters = target.FindFunctions(
25+
"-[Foo setFooProp:]", lldb.eFunctionNameTypeSelector
26+
)
27+
self.assertEqual(len(setters), 1)
28+
setter = setters[0].function.GetType()
29+
self.assertTrue(setter)
30+
self.assertEqual(setter.GetDisplayTypeName(), "void (int)")
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#import <Foundation/Foundation.h>
2+
3+
@interface Foo : NSObject
4+
@property(readwrite) int fooProp;
5+
@end
6+
7+
@implementation Foo
8+
@end
9+
10+
int main() {
11+
Foo *f = [Foo new];
12+
[f setFooProp:10];
13+
return f.fooProp;
14+
}

0 commit comments

Comments
 (0)