[Lldb-commits] [lldb] 6919c58 - [lldb] Add a test for Obj-C properties with conflicting names

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Tue Mar 30 02:08:35 PDT 2021


Author: Raphael Isemann
Date: 2021-03-30T11:08:16+02:00
New Revision: 6919c58262b0bab682ab48903e714d70a489418b

URL: https://github.com/llvm/llvm-project/commit/6919c58262b0bab682ab48903e714d70a489418b
DIFF: https://github.com/llvm/llvm-project/commit/6919c58262b0bab682ab48903e714d70a489418b.diff

LOG: [lldb] Add a test for Obj-C properties with conflicting names

This is apparently allowed in Objective-C so we should test this in LLDB.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D99513

Added: 
    

Modified: 
    lldb/test/API/lang/objc/objc-property/TestObjCProperty.py
    lldb/test/API/lang/objc/objc-property/main.m

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/lang/objc/objc-property/TestObjCProperty.py b/lldb/test/API/lang/objc/objc-property/TestObjCProperty.py
index 5693a77547cc..25158a58a786 100644
--- a/lldb/test/API/lang/objc/objc-property/TestObjCProperty.py
+++ b/lldb/test/API/lang/objc/objc-property/TestObjCProperty.py
@@ -137,3 +137,8 @@ def test_objc_properties(self):
         value = frame.EvaluateExpression("BaseClass.classInt", False)
         self.assertTrue(value.GetError().Success())
         self.assertEquals(value.GetValueAsUnsigned(11111), 234)
+
+        # Test that accessing two distinct class and instance properties that
+        # share the same name works.
+        self.expect_expr("mine.propConflict", result_value="4")
+        self.expect_expr("BaseClass.propConflict", result_value="6")

diff  --git a/lldb/test/API/lang/objc/objc-property/main.m b/lldb/test/API/lang/objc/objc-property/main.m
index 8c84440adc43..94e5af43f415 100644
--- a/lldb/test/API/lang/objc/objc-property/main.m
+++ b/lldb/test/API/lang/objc/objc-property/main.m
@@ -22,12 +22,16 @@ - (void) mySetUnbackedInt: (int) in_int;
 
 - (int) getAccessCount;
 
++ (int) propConflict;
+
 +(BaseClass *) baseClassWithBackedInt: (int) inInt andUnbackedInt: (int) inOtherInt;
 
 @property(getter=myGetUnbackedInt,setter=mySetUnbackedInt:) int unbackedInt;
 @property int backedInt;
 @property (nonatomic, assign) id <MyProtocol> idWithProtocol;
 @property(class) int classInt;
+ at property(getter=propConflict,readonly) int propConflict;
+ at property(readonly,class) int propConflict;
 @end
 
 @implementation BaseClass
@@ -85,6 +89,15 @@ - (int) getAccessCount
 {
   return _access_count;
 }
+
+- (int) propConflict
+{
+  return 4;
+}
++ (int) propConflict
+{
+  return 6;
+}
 @end
 
 typedef BaseClass TypedefBaseClass;
@@ -94,6 +107,7 @@ - (int) getAccessCount
 {
   BaseClass *mine = [BaseClass baseClassWithBackedInt: 10 andUnbackedInt: 20];
   TypedefBaseClass *typedefd = mine;
+  int propConflict = mine.propConflict + BaseClass.propConflict;
   
   // Set a breakpoint here.
   int nonexistant = mine.nonexistantInt;


        


More information about the lldb-commits mailing list