]> granicus.if.org Git - clang/commitdiff
Rename ownership attributes:
authorTed Kremenek <kremenek@apple.com>
Tue, 5 May 2009 00:21:59 +0000 (00:21 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 5 May 2009 00:21:59 +0000 (00:21 +0000)
 ns_ownership_returns -> ns_returns_owned
 ns_ownership_retain -> ns_retains
 ns_ownership_release -> ns_releases
 cf_ownership_retain ->  cf_retains
 cf_ownership_release -> cf_releases

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

include/clang/Parse/AttributeList.h
lib/Parse/AttributeList.cpp
lib/Sema/SemaDeclAttr.cpp
test/Analysis/retain-release-gc-only.m
test/Analysis/retain-release.m

index 7693d02ff79ad764991cc43e8edcb386c22185ca..3666542d67116abd393f65ff49e0772cba4a71fe 100644 (file)
@@ -76,11 +76,11 @@ public:
     AT_nothrow,
     AT_nsobject,
     AT_objc_exception,
-    AT_cf_ownership_release,        // Clang-specific.
-    AT_cf_ownership_retain,         // Clang-specific.
-    AT_ns_ownership_release,          // Clang-specific.
-    AT_ns_ownership_retain,           // Clang-specific.
-    AT_ns_returns_ownership,          // Clang-specific.
+    AT_cf_releases,        // Clang-specific.
+    AT_cf_retains,         // Clang-specific.
+    AT_ns_releases,          // Clang-specific.
+    AT_ns_retains,           // Clang-specific.
+    AT_ns_returns_owned,          // Clang-specific.
     AT_objc_gc,
     AT_overloadable,            // Clang-specific.
     AT_packed,
index d989d1de6ef682cf10e8ca95f642d9653cfdb085..1cc9a51ec6f76eb6cc14b9080d573e022317fb89 100644 (file)
@@ -106,12 +106,16 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) {
     if (!memcmp(Str, "format_arg", 10))
       return IgnoredAttribute; // FIXME: printf format string checking.
     if (!memcmp(Str, "gnu_inline", 10)) return AT_gnu_inline;
+    if (!memcmp(Str, "cf_retains", 10)) return AT_cf_retains;
+    if (!memcmp(Str, "ns_retains", 10)) return AT_ns_retains;      
     break;
   case 11:
     if (!memcmp(Str, "weak_import", 11)) return AT_weak_import;
     if (!memcmp(Str, "vector_size", 11)) return AT_vector_size;
     if (!memcmp(Str, "constructor", 11)) return AT_constructor;
     if (!memcmp(Str, "unavailable", 11)) return AT_unavailable;
+    if (!memcmp(Str, "cf_releases", 11)) return AT_cf_releases;
+    if (!memcmp(Str, "ns_releases", 11)) return AT_ns_releases;      
     break;
   case 12:
     if (!memcmp(Str, "overloadable", 12)) return AT_overloadable;
@@ -126,6 +130,9 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) {
   case 15:
     if (!memcmp(Str, "ext_vector_type", 15)) return AT_ext_vector_type;
     break;
+  case 16:
+    if (!memcmp(Str, "ns_returns_owned", 16)) return AT_ns_returns_owned;
+    break;      
   case 17:
     if (!memcmp(Str, "transparent_union", 17)) return AT_transparent_union;
     if (!memcmp(Str, "analyzer_noreturn", 17)) return AT_analyzer_noreturn;
@@ -133,20 +140,6 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) {
   case 18:
     if (!memcmp(Str, "warn_unused_result", 18)) return AT_warn_unused_result;
     break;
-  case 19:
-    if (!memcmp(Str, "cf_ownership_retain", 19))
-      return AT_cf_ownership_retain;
-    if (!memcmp(Str, "ns_ownership_retain", 19))
-      return AT_ns_ownership_retain;      
-    break;      
-  case 20:
-    if (!memcmp(Str, "cf_ownership_release", 20))
-      return AT_cf_ownership_release;
-    if (!memcmp(Str, "ns_ownership_release", 20))
-      return AT_ns_ownership_release;
-    if (!memcmp(Str, "ns_returns_ownership", 20))
-      return AT_ns_returns_ownership;
-    break;
   case 22:
     if (!memcmp(Str, "no_instrument_function", 22))
       return AT_no_instrument_function;
index 29a0c6b977d3fd1409eafa5d283a9b578ec86d62..033be2c9622757b5d0a2e6065f295fc082df7294 100644 (file)
@@ -1552,7 +1552,7 @@ static void HandleNSOwnershipReturnsAttr(Decl *d, const AttributeList &Attr,
 
   if (!isa<ObjCMethodDecl>(d) && !isa<FunctionDecl>(d)) {
     S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) <<
-      "ns_returns_ownership" << 3 /* function or method */;
+      "ns_returns_owned" << 3 /* function or method */;
     return;
   }
   
@@ -1569,14 +1569,14 @@ static void HandleNSOwnershipAttr(Decl *d, const AttributeList &Attr,
       default:
         assert(0 && "invalid ownership attribute");
         return;
-      case AttributeList::AT_cf_ownership_release:
-        name = "cf_ownership_release"; break;
-      case AttributeList::AT_cf_ownership_retain:
-        name = "cf_ownership_retain"; break;
-      case AttributeList::AT_ns_ownership_release:
-        name = "ns_ownership_release"; break;
-      case AttributeList::AT_ns_ownership_retain:
-        name = "ns_ownership_retain"; break;
+      case AttributeList::AT_cf_releases:
+        name = "cf_releases"; break;
+      case AttributeList::AT_cf_retains:
+        name = "cf_retains"; break;
+      case AttributeList::AT_ns_releases:
+        name = "ns_releases"; break;
+      case AttributeList::AT_ns_retains:
+        name = "ns_retains"; break;
     };
 
     S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) << name
@@ -1589,13 +1589,13 @@ static void HandleNSOwnershipAttr(Decl *d, const AttributeList &Attr,
     default:
       assert(0 && "invalid ownership attribute");
       return;
-    case AttributeList::AT_cf_ownership_release:
+    case AttributeList::AT_cf_releases:
       d->addAttr(::new (S.Context) CFOwnershipReleaseAttr()); return;      
-    case AttributeList::AT_cf_ownership_retain:
+    case AttributeList::AT_cf_retains:
       d->addAttr(::new (S.Context) CFOwnershipRetainAttr()); return;
-    case AttributeList::AT_ns_ownership_release:
+    case AttributeList::AT_ns_releases:
       d->addAttr(::new (S.Context) NSOwnershipReleaseAttr());   return;
-    case AttributeList::AT_ns_ownership_retain:
+    case AttributeList::AT_ns_retains:
       d->addAttr(::new (S.Context) NSOwnershipRetainAttr());   return;
   }
 }
@@ -1638,13 +1638,13 @@ static void ProcessDeclAttribute(Decl *D, const AttributeList &Attr, Sema &S) {
   case AttributeList::AT_nothrow:     HandleNothrowAttr   (D, Attr, S); break;
 
   // Checker-specific.
-  case AttributeList::AT_cf_ownership_release:     
-  case AttributeList::AT_cf_ownership_retain:
+  case AttributeList::AT_cf_releases:     
+  case AttributeList::AT_cf_retains:
       HandleNSOwnershipAttr(D, Attr, S); break;
-  case AttributeList::AT_ns_ownership_release:
-  case AttributeList::AT_ns_ownership_retain:
+  case AttributeList::AT_ns_releases:
+  case AttributeList::AT_ns_retains:
       HandleNSOwnershipAttr(D, Attr, S, true); break;
-  case AttributeList::AT_ns_returns_ownership:
+  case AttributeList::AT_ns_returns_owned:
     HandleNSOwnershipReturnsAttr(D, Attr, S); break;
 
   case AttributeList::AT_packed:      HandlePackedAttr    (D, Attr, S); break;
index 8e261399e4aabed67eb221f8100d427ee803df6c..74d2c9479763e497520b2ee144caf8b4acb32ddf 100644 (file)
@@ -129,11 +129,11 @@ void f3() {
 //===----------------------------------------------------------------------===//
 
 @interface TestOwnershipAttr : NSObject
-- (NSString*) returnsAnOwnedString __attribute__((ns_returns_ownership));
-- (void) myRetain:(id)__attribute__((ns_ownership_retain))obj;
-- (void) myCFRetain:(id)__attribute__((cf_ownership_retain))obj;
-- (void) myRelease:(id)__attribute__((ns_ownership_release))obj;
-- (void) myCFRelease:(id)__attribute__((cf_ownership_release))obj;
+- (NSString*) returnsAnOwnedString __attribute__((ns_returns_owned));
+- (void) myRetain:(id)__attribute__((ns_retains))obj;
+- (void) myCFRetain:(id)__attribute__((cf_retains))obj;
+- (void) myRelease:(id)__attribute__((ns_releases))obj;
+- (void) myCFRelease:(id)__attribute__((cf_releases))obj;
 @end
 
 void test_attr_1(TestOwnershipAttr *X) {
index 393a99bfaeb9758deda9b2fa884e3402add380c4..a25c0e262547fa3ab7d4564ce1130a25d6de6226 100644 (file)
@@ -431,19 +431,18 @@ void rdar6704930(unsigned char *s, unsigned int length) {
 //===----------------------------------------------------------------------===//
 
 @interface TestOwnershipAttr : NSObject
-- (NSString*) returnsAnOwnedString  __attribute__((ns_returns_ownership));
-- (void) myRetain:(id)__attribute__((ns_ownership_retain))obj;
-- (void) myCFRetain:(id)__attribute__((cf_ownership_retain))obj;
-- (void) myRelease:(id)__attribute__((ns_ownership_release))obj;
-- (void) myCFRelease:(id)__attribute__((cf_ownership_release))obj;
-
-- (void) myRetain __attribute__((ns_ownership_retain));
-- (void) myRelease __attribute__((ns_ownership_release));
+- (NSString*) returnsAnOwnedString  __attribute__((ns_returns_owned));
+- (void) myRetain:(id)__attribute__((ns_retains))obj;
+- (void) myCFRetain:(id)__attribute__((cf_retains))obj;
+- (void) myRelease:(id)__attribute__((ns_releases))obj;
+- (void) myCFRelease:(id)__attribute__((cf_releases))obj;
+- (void) myRetain __attribute__((ns_retains));
+- (void) myRelease __attribute__((ns_releases));
 @end
 
 @interface TestAttrHelper : NSObject
 - (NSString*) createString:(TestOwnershipAttr*)X;
-- (NSString*) createStringAttr:(TestOwnershipAttr*)X __attribute__((ns_returns_ownership));
+- (NSString*) createStringAttr:(TestOwnershipAttr*)X __attribute__((ns_returns_owned));
 @end
 
 @implementation TestAttrHelper