Author: Michael Buch Date: 2025-10-27T10:01:07Z New Revision: 313b95f3a8d7efaf8970484c169f1a106bc12f68
URL: https://github.com/llvm/llvm-project/commit/313b95f3a8d7efaf8970484c169f1a106bc12f68 DIFF: https://github.com/llvm/llvm-project/commit/313b95f3a8d7efaf8970484c169f1a106bc12f68.diff LOG: [lldb][test] Add test for parsing Objective-C synthesized properties Prior to https://github.com/llvm/llvm-project/pull/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 (https://github.com/llvm/llvm-project/pull/100355) landed. This patch adds a test that explicitly checks that the type of the setter is sensible. This test fails without https://github.com/llvm/llvm-project/pull/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. Added: lldb/test/API/lang/objc/synthesized-property-accessor/Makefile lldb/test/API/lang/objc/synthesized-property-accessor/TestSynthesizedPropertyAccessor.py lldb/test/API/lang/objc/synthesized-property-accessor/main.m Modified: Removed: ################################################################################ diff --git a/lldb/test/API/lang/objc/synthesized-property-accessor/Makefile b/lldb/test/API/lang/objc/synthesized-property-accessor/Makefile new file mode 100644 index 0000000000000..89e6e796b1970 --- /dev/null +++ b/lldb/test/API/lang/objc/synthesized-property-accessor/Makefile @@ -0,0 +1,4 @@ +OBJC_SOURCES := main.m +LDFLAGS := -lobjc + +include Makefile.rules diff --git a/lldb/test/API/lang/objc/synthesized-property-accessor/TestSynthesizedPropertyAccessor.py b/lldb/test/API/lang/objc/synthesized-property-accessor/TestSynthesizedPropertyAccessor.py new file mode 100644 index 0000000000000..0a171e983593a --- /dev/null +++ b/lldb/test/API/lang/objc/synthesized-property-accessor/TestSynthesizedPropertyAccessor.py @@ -0,0 +1,30 @@ +""" +Test debug-info parsing of synthesized Objective-C properties. +""" + +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestSynthesizedPropertyAccessor(TestBase): + def test(self): + self.build() + + (target, _, _, _) = lldbutil.run_to_source_breakpoint( + self, "return f.fooProp", lldb.SBFileSpec("main.m") + ) + + getters = target.FindFunctions("-[Foo fooProp]", lldb.eFunctionNameTypeSelector) + self.assertEqual(len(getters), 1) + getter = getters[0].function.GetType() + self.assertTrue(getter) + self.assertEqual(getter.GetDisplayTypeName(), "int ()") + + setters = target.FindFunctions( + "-[Foo setFooProp:]", lldb.eFunctionNameTypeSelector + ) + self.assertEqual(len(setters), 1) + setter = setters[0].function.GetType() + self.assertTrue(setter) + self.assertEqual(setter.GetDisplayTypeName(), "void (int)") diff --git a/lldb/test/API/lang/objc/synthesized-property-accessor/main.m b/lldb/test/API/lang/objc/synthesized-property-accessor/main.m new file mode 100644 index 0000000000000..418616267f9ae --- /dev/null +++ b/lldb/test/API/lang/objc/synthesized-property-accessor/main.m @@ -0,0 +1,14 @@ +#import <Foundation/Foundation.h> + +@interface Foo : NSObject +@property(readwrite) int fooProp; +@end + +@implementation Foo +@end + +int main() { + Foo *f = [Foo new]; + [f setFooProp:10]; + return f.fooProp; +} _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
