From d331dd7fa43f547197efcd757e4a7b477c29fd6e Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Tue, 5 May 2009 00:21:59 +0000 Subject: [PATCH] Rename ownership attributes: 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 | 10 +++---- lib/Parse/AttributeList.cpp | 21 +++++---------- lib/Sema/SemaDeclAttr.cpp | 36 +++++++++++++------------- test/Analysis/retain-release-gc-only.m | 10 +++---- test/Analysis/retain-release.m | 17 ++++++------ 5 files changed, 43 insertions(+), 51 deletions(-) diff --git a/include/clang/Parse/AttributeList.h b/include/clang/Parse/AttributeList.h index 7693d02ff7..3666542d67 100644 --- a/include/clang/Parse/AttributeList.h +++ b/include/clang/Parse/AttributeList.h @@ -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, diff --git a/lib/Parse/AttributeList.cpp b/lib/Parse/AttributeList.cpp index d989d1de6e..1cc9a51ec6 100644 --- a/lib/Parse/AttributeList.cpp +++ b/lib/Parse/AttributeList.cpp @@ -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; diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 29a0c6b977..033be2c962 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -1552,7 +1552,7 @@ static void HandleNSOwnershipReturnsAttr(Decl *d, const AttributeList &Attr, if (!isa(d) && !isa(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; diff --git a/test/Analysis/retain-release-gc-only.m b/test/Analysis/retain-release-gc-only.m index 8e261399e4..74d2c94797 100644 --- a/test/Analysis/retain-release-gc-only.m +++ b/test/Analysis/retain-release-gc-only.m @@ -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) { diff --git a/test/Analysis/retain-release.m b/test/Analysis/retain-release.m index 393a99bfae..a25c0e2625 100644 --- a/test/Analysis/retain-release.m +++ b/test/Analysis/retain-release.m @@ -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 -- 2.40.0