r191016 - Refinement to my previous patch for

Fariborz Jahanian fjahanian at apple.com
Thu Sep 19 10:18:55 PDT 2013


Author: fjahanian
Date: Thu Sep 19 12:18:55 2013
New Revision: 191016

URL: http://llvm.org/viewvc/llvm-project?rev=191016&view=rev
Log:
Refinement to my previous patch for
objc_returns_inner_pointer on properties. // rdar://14990439

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

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=191016&r1=191015&r2=191016&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Thu Sep 19 12:18:55 2013
@@ -571,7 +571,7 @@ def ObjCPreciseLifetime : InheritableAtt
 
 def ObjCReturnsInnerPointer : InheritableAttr {
   let Spellings = [GNU<"objc_returns_inner_pointer">];
-  let Subjects = [ObjCMethod];
+  let Subjects = [ObjCMethod, ObjCProperty];
 }
 
 def ObjCRequiresSuper : InheritableAttr {

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=191016&r1=191015&r2=191016&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Sep 19 12:18:55 2013
@@ -4145,6 +4145,11 @@ static void handleNSReturnsRetainedAttr(
 
 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 handleObjCReturnsInnerPointe
       (!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;

Modified: cfe/trunk/test/SemaObjC/arc-property-lifetime.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-property-lifetime.m?rev=191016&r1=191015&r2=191016&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/arc-property-lifetime.m (original)
+++ cfe/trunk/test/SemaObjC/arc-property-lifetime.m Thu Sep 19 12:18:55 2013
@@ -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}}
 }
+ at 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
 





More information about the cfe-commits mailing list