]> granicus.if.org Git - clang/commitdiff
Refinement to my previous patch for
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 19 Sep 2013 17:18:55 +0000 (17:18 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 19 Sep 2013 17:18:55 +0000 (17:18 +0000)
objc_returns_inner_pointer on properties. // rdar://14990439

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191016 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/Attr.td
lib/Sema/SemaDeclAttr.cpp
test/SemaObjC/arc-property-lifetime.m

index 161e9c87d831d09a02f014c8539f22009b077ad4..5681dafc30d7341babd53b3e4ceaecc19a983c15 100644 (file)
@@ -571,7 +571,7 @@ def ObjCPreciseLifetime : InheritableAttr {
 
 def ObjCReturnsInnerPointer : InheritableAttr {
   let Spellings = [GNU<"objc_returns_inner_pointer">];
-  let Subjects = [ObjCMethod];
+  let Subjects = [ObjCMethod, ObjCProperty];
 }
 
 def ObjCRequiresSuper : InheritableAttr {
index d9e997244979b01432cfa7eda45c6159442fd90b..8a2d126dd6110e35b7cdc517874fd329bdfa0006 100644 (file)
@@ -4145,6 +4145,11 @@ static void handleNSReturnsRetainedAttr(Sema &S, Decl *D,
 
 static void handleObjCReturnsInnerPointerAttr(Sema &S, Decl *D,
                                               const AttributeList &attr) {
+  enum {
+    EP_ObjCMethod = 1,
+    EP_ObjCProperty
+  };
+  
   SourceLocation loc = attr.getLoc();
   QualType resultType;
   
@@ -4167,7 +4172,8 @@ static void handleObjCReturnsInnerPointerAttr(Sema &S, Decl *D,
       (!resultType->isPointerType() || resultType->isObjCRetainableType())) {
     S.Diag(D->getLocStart(), diag::warn_ns_attribute_wrong_return_type)
       << SourceRange(loc)
-    << attr.getName() << (method ? /*method*/ 1 : /*property*/ 2) << /*non-retainable pointer*/ 2;
+    << attr.getName() << (method ? EP_ObjCMethod : EP_ObjCProperty)
+    << /*non-retainable pointer*/ 2;
 
     // Drop the attribute.
     return;
index 766a6141be67a7dbb141ee2a79e6d4f499fd9983..962154438bdb4380f9be58537694a8975626597d 100644 (file)
@@ -174,6 +174,8 @@ void foo(Baz *f) {
 {
   const void * innerPointerIvar __attribute__((objc_returns_inner_pointer)); // expected-error {{'objc_returns_inner_pointer' attribute only applies to methods and properties}}
 }
+@property (readonly) Boom * NotInnerPointer __attribute__((objc_returns_inner_pointer)); // expected-warning {{'objc_returns_inner_pointer' attribute only applies to properties that return a non-retainable pointer}}
+- (Boom *) NotInnerPointerMethod __attribute__((objc_returns_inner_pointer)); // expected-warning {{'objc_returns_inner_pointer' attribute only applies to methods that return a non-retainable pointer}}
 @property (readonly) const void * innerPointer __attribute__((objc_returns_inner_pointer));
 @end