[Lldb-commits] [clang] [lldb] [clang][DebugInfo][test] Convert Objective-C property test to check LLVM IR (PR #165286)

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Mon Oct 27 10:34:56 PDT 2025


https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/165286

There's a couple of tests like this.

This patch series renames these to something more descriptive and adjusts the tests to check IR. Currently the tests check raw assembly output (not even dwarfdump). Which most likely hid some bugs around property debug-info.

>From 22ea13c6a55a4da3bf42d2d11e5c69011f5115e2 Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Mon, 27 Oct 2025 09:39:25 +0000
Subject: [PATCH 1/2] [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.
---
 .../synthesized-property-accessor/Makefile    |  4 +++
 .../TestSynthesizedPropertyAccessor.py        | 30 +++++++++++++++++++
 .../objc/synthesized-property-accessor/main.m | 14 +++++++++
 3 files changed, 48 insertions(+)
 create mode 100644 lldb/test/API/lang/objc/synthesized-property-accessor/Makefile
 create mode 100644 lldb/test/API/lang/objc/synthesized-property-accessor/TestSynthesizedPropertyAccessor.py
 create mode 100644 lldb/test/API/lang/objc/synthesized-property-accessor/main.m

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..7686ab48e1189
--- /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 (id)")
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>
+
+ at interface Foo : NSObject
+ at property(readwrite) int fooProp;
+ at end
+
+ at implementation Foo
+ at end
+
+int main() {
+  Foo *f = [Foo new];
+  [f setFooProp:10];
+  return f.fooProp;
+}

>From 169a8ee176fb90c097742f2ed0e16b0090edef85 Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Mon, 27 Oct 2025 17:30:21 +0000
Subject: [PATCH 2/2] [clang][DebugInfo][test] Convert Objective-C property
 test to check LLVM IR

There's a couple of tests like this.

This patch series renames these to something more descriptive and adjusts the tests to check IR. Currently the tests check raw assembly output (not even dwarfdump). Which most likely hid some bugs around property debug-info.
---
 clang/test/DebugInfo/ObjC/property-basic.m | 20 ++++++++++++++++++++
 clang/test/DebugInfo/ObjC/property.m       | 15 ---------------
 2 files changed, 20 insertions(+), 15 deletions(-)
 create mode 100644 clang/test/DebugInfo/ObjC/property-basic.m
 delete mode 100644 clang/test/DebugInfo/ObjC/property.m

diff --git a/clang/test/DebugInfo/ObjC/property-basic.m b/clang/test/DebugInfo/ObjC/property-basic.m
new file mode 100644
index 0000000000000..65e1d7a6a9b1f
--- /dev/null
+++ b/clang/test/DebugInfo/ObjC/property-basic.m
@@ -0,0 +1,20 @@
+// Checks basic debug-info generation for property. Makes sure we
+// create a DIObjCProperty for the synthesized property.
+
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
+
+// CHECK: !DIObjCProperty(name: "p1"
+// CHECK-SAME:            attributes: 2316
+// CHECK-SAME:            type: ![[P1_TYPE:[0-9]+]]
+//
+// CHECK: ![[P1_TYPE]] = !DIBasicType(name: "int"
+
+ at interface I1 {
+int p1;
+}
+ at property int p1;
+ at end
+
+ at implementation I1
+ at synthesize p1;
+ at end
diff --git a/clang/test/DebugInfo/ObjC/property.m b/clang/test/DebugInfo/ObjC/property.m
deleted file mode 100644
index ca013b24be421..0000000000000
--- a/clang/test/DebugInfo/ObjC/property.m
+++ /dev/null
@@ -1,15 +0,0 @@
-// FIXME: Check IR rather than asm, then triple is not needed.
-// RUN: %clang_cc1 -triple %itanium_abi_triple -S -debug-info-kind=limited %s -o - | FileCheck %s
-
-// CHECK: AT_APPLE_property_name
-// CHECK: AT_APPLE_property_attribute
-// CHECK: AT_APPLE_property
- at interface I1 {
-int p1;
-}
- at property int p1;
- at end
-
- at implementation I1
- at synthesize p1;
- at end



More information about the lldb-commits mailing list