[Lldb-commits] [lldb] r275459 - Add support for Objective-C class properties.
Greg Clayton via lldb-commits
lldb-commits at lists.llvm.org
Thu Jul 14 12:31:18 PDT 2016
Author: gclayton
Date: Thu Jul 14 14:31:18 2016
New Revision: 275459
URL: http://llvm.org/viewvc/llvm-project?rev=275459&view=rev
Log:
Add support for Objective-C class properties.
Added test cases to exiting tests to cover the new functionality.
<rdar://problem/24311282>
Modified:
lldb/trunk/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py
lldb/trunk/packages/Python/lldbsuite/test/lang/objc/objc-property/main.m
lldb/trunk/source/Symbol/ClangASTContext.cpp
Modified: lldb/trunk/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py?rev=275459&r1=275458&r2=275459&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py Thu Jul 14 14:31:18 2016
@@ -113,3 +113,17 @@ class ObjCPropertyTestCase(TestBase):
idWithProtocol_error = idWithProtocol_value.GetError()
self.assertTrue (idWithProtocol_error.Success())
self.assertTrue (idWithProtocol_value.GetTypeName() == "id")
+
+ # Make sure that class property getter works as expected
+ value = frame.EvaluateExpression("BaseClass.classInt", False)
+ self.assertTrue (value.GetError().Success())
+ self.assertTrue (value.GetValueAsUnsigned (11111) == 123)
+
+ # Make sure that class property setter works as expected
+ value = frame.EvaluateExpression("BaseClass.classInt = 234", False)
+ self.assertTrue (value.GetError().Success())
+
+ # Verify that setter above actually worked
+ value = frame.EvaluateExpression("BaseClass.classInt", False)
+ self.assertTrue (value.GetError().Success())
+ self.assertTrue (value.GetValueAsUnsigned (11111) == 234)
Modified: lldb/trunk/packages/Python/lldbsuite/test/lang/objc/objc-property/main.m
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/objc/objc-property/main.m?rev=275459&r1=275458&r2=275459&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lang/objc/objc-property/main.m (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/objc/objc-property/main.m Thu Jul 14 14:31:18 2016
@@ -6,6 +6,8 @@
@end
+static int _class_int = 123;
+
@interface BaseClass : NSObject
{
int _backedInt;
@@ -25,6 +27,7 @@
@property(getter=myGetUnbackedInt,setter=mySetUnbackedInt:) int unbackedInt;
@property int backedInt;
@property (nonatomic, assign) id <MyProtocol> idWithProtocol;
+ at property(class) int classInt;
@end
@implementation BaseClass
@@ -68,6 +71,16 @@
_access_count++;
}
++ (int) classInt
+{
+ return _class_int;
+}
+
++ (void) setClassInt:(int) n
+{
+ _class_int = n;
+}
+
- (int) getAccessCount
{
return _access_count;
Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=275459&r1=275458&r2=275459&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Thu Jul 14 14:31:18 2016
@@ -8264,10 +8264,19 @@ ClangASTContext::AddObjCClassProperty (c
property_decl->setPropertyAttributes (clang::ObjCPropertyDecl::OBJC_PR_copy);
if (property_attributes & DW_APPLE_PROPERTY_nonatomic)
property_decl->setPropertyAttributes (clang::ObjCPropertyDecl::OBJC_PR_nonatomic);
-
- if (!getter_sel.isNull() && !class_interface_decl->lookupInstanceMethod(getter_sel))
+ if (property_attributes & clang::ObjCPropertyDecl::OBJC_PR_nullability)
+ property_decl->setPropertyAttributes(clang::ObjCPropertyDecl::OBJC_PR_nullability);
+ if (property_attributes & clang::ObjCPropertyDecl::OBJC_PR_null_resettable)
+ property_decl->setPropertyAttributes(clang::ObjCPropertyDecl::OBJC_PR_null_resettable);
+ if (property_attributes & clang::ObjCPropertyDecl::OBJC_PR_class)
+ property_decl->setPropertyAttributes(clang::ObjCPropertyDecl::OBJC_PR_class);
+
+ const bool isInstance = (property_attributes & clang::ObjCPropertyDecl::OBJC_PR_class) == 0;
+
+ if (!getter_sel.isNull() &&
+ !(isInstance ? class_interface_decl->lookupInstanceMethod(getter_sel)
+ : class_interface_decl->lookupClassMethod(getter_sel)))
{
- const bool isInstance = true;
const bool isVariadic = false;
const bool isSynthesized = false;
const bool isImplicitlyDeclared = true;
@@ -8291,12 +8300,12 @@ ClangASTContext::AddObjCClassProperty (c
class_interface_decl->addDecl(getter);
}
}
-
- if (!setter_sel.isNull() && !class_interface_decl->lookupInstanceMethod(setter_sel))
+
+ if (!setter_sel.isNull() &&
+ !(isInstance ? class_interface_decl->lookupInstanceMethod(setter_sel)
+ : class_interface_decl->lookupClassMethod(setter_sel)))
{
clang::QualType result_type = clang_ast->VoidTy;
-
- const bool isInstance = true;
const bool isVariadic = false;
const bool isSynthesized = false;
const bool isImplicitlyDeclared = true;
More information about the lldb-commits
mailing list