diff options
author | Greg Clayton <gclayton@apple.com> | 2016-07-14 19:31:18 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2016-07-14 19:31:18 +0000 |
commit | 7853dd5decf27f2e09c61d42d537a868a748ce27 (patch) | |
tree | 5eb8c7478c60e32eff2903305f1a55a5a0b1695e | |
parent | ecea07c50ecc85f6e474d8f4831e566f97ac2be2 (diff) | |
download | bcm5719-llvm-7853dd5decf27f2e09c61d42d537a868a748ce27.tar.gz bcm5719-llvm-7853dd5decf27f2e09c61d42d537a868a748ce27.zip |
Add support for Objective-C class properties.
Added test cases to exiting tests to cover the new functionality.
<rdar://problem/24311282>
llvm-svn: 275459
3 files changed, 43 insertions, 7 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py index 9943d5f4b6a..22fe3136a51 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py @@ -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) diff --git a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/main.m b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/main.m index 2ef142be9b0..8d14759fb38 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/main.m +++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/main.m @@ -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; +@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; diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index 39042f98883..02882ef2ef4 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -8264,10 +8264,19 @@ ClangASTContext::AddObjCClassProperty (const CompilerType& type, 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 (const CompilerType& type, 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; |