From 75494ffb4ed3964fa22fb9ab15fddecedbc9fe10 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Mon, 4 May 2009 19:10:19 +0000 Subject: [PATCH] Rename attributes 'objc_ownership...' to 'ns_ownership...'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70897 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/Attr.h | 16 ++++----- include/clang/Parse/AttributeList.h | 8 ++--- lib/Analysis/CFRefCount.cpp | 14 ++++---- lib/Frontend/PCHReaderDecl.cpp | 8 ++--- lib/Frontend/PCHWriter.cpp | 8 ++--- lib/Parse/AttributeList.cpp | 20 +++++------ lib/Sema/SemaDeclAttr.cpp | 46 +++++++++++++------------- test/Analysis/retain-release-gc-only.m | 8 ++--- test/Analysis/retain-release.m | 12 +++---- 9 files changed, 69 insertions(+), 71 deletions(-) diff --git a/include/clang/AST/Attr.h b/include/clang/AST/Attr.h index 6d913de0a1..41ea065447 100644 --- a/include/clang/AST/Attr.h +++ b/include/clang/AST/Attr.h @@ -61,10 +61,10 @@ public: ObjCNSObject, CFOwnershipRelease, // Clang/Checker-specific. CFOwnershipRetain, // Clang/Checker-specific. - ObjCOwnershipMakeCollectable, // Clang/Checker-specific. - ObjCOwnershipRelease, // Clang/Checker-specific. - ObjCOwnershipRetain, // Clang/Checker-specific. - ObjCOwnershipReturns, // Clang/Checker-specific. + NSOwnershipMakeCollectable, // Clang/Checker-specific. + NSOwnershipRelease, // Clang/Checker-specific. + NSOwnershipRetain, // Clang/Checker-specific. + NSOwnershipReturns, // Clang/Checker-specific. Overloadable, // Clang-specific Packed, Pure, @@ -467,11 +467,11 @@ public: // Checker-specific attributes. DEF_SIMPLE_ATTR(CFOwnershipRelease); -DEF_SIMPLE_ATTR(ObjCOwnershipRelease); +DEF_SIMPLE_ATTR(NSOwnershipRelease); DEF_SIMPLE_ATTR(CFOwnershipRetain); -DEF_SIMPLE_ATTR(ObjCOwnershipRetain); -DEF_SIMPLE_ATTR(ObjCOwnershipMakeCollectable); -DEF_SIMPLE_ATTR(ObjCOwnershipReturns); +DEF_SIMPLE_ATTR(NSOwnershipRetain); +DEF_SIMPLE_ATTR(NSOwnershipMakeCollectable); +DEF_SIMPLE_ATTR(NSOwnershipReturns); #undef DEF_SIMPLE_ATTR diff --git a/include/clang/Parse/AttributeList.h b/include/clang/Parse/AttributeList.h index 5901fbd601..84a180b5e3 100644 --- a/include/clang/Parse/AttributeList.h +++ b/include/clang/Parse/AttributeList.h @@ -78,10 +78,10 @@ public: AT_objc_exception, AT_cf_ownership_release, // Clang-specific. AT_cf_ownership_retain, // Clang-specific. - AT_objc_ownership_make_collectable, // Clang-specific. - AT_objc_ownership_release, // Clang-specific. - AT_objc_ownership_retain, // Clang-specific. - AT_objc_ownership_returns, // Clang-specific. + AT_ns_ownership_make_collectable, // Clang-specific. + AT_ns_ownership_release, // Clang-specific. + AT_ns_ownership_retain, // Clang-specific. + AT_ns_ownership_returns, // Clang-specific. AT_objc_gc, AT_overloadable, // Clang-specific. AT_packed, diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp index f4b4b11853..54843d534a 100644 --- a/lib/Analysis/CFRefCount.cpp +++ b/lib/Analysis/CFRefCount.cpp @@ -1105,15 +1105,15 @@ void RetainSummaryManager::updateSummaryArgEffFromAnnotations(RetainSummary &Summ, unsigned i, const ParmVarDecl *PD){ - if (PD->getAttr()) + if (PD->getAttr()) Summ.setArgEffect(AF, i, IncRefMsg); else if (PD->getAttr()) Summ.setArgEffect(AF, i, IncRef); - else if (PD->getAttr()) + else if (PD->getAttr()) Summ.setArgEffect(AF, i, DecRefMsg); else if (PD->getAttr()) Summ.setArgEffect(AF, i, DecRef); - else if (PD->getAttr()) + else if (PD->getAttr()) Summ.setArgEffect(AF, i, MakeCollectable); } @@ -1125,7 +1125,7 @@ RetainSummaryManager::updateSummaryFromAnnotations(RetainSummary &Summ, // Determine if there is a special return effect for this method. if (isTrackedObjCObjectType(FD->getResultType())) { - if (FD->getAttr()) { + if (FD->getAttr()) { Summ.setRetEffect(isGCEnabled() ? RetEffect::MakeGCNotOwned() : RetEffect::MakeOwned(RetEffect::ObjC, true)); @@ -1147,7 +1147,7 @@ RetainSummaryManager::updateSummaryFromAnnotations(RetainSummary &Summ, // Determine if there is a special return effect for this method. if (isTrackedObjCObjectType(MD->getResultType())) { - if (MD->getAttr()) { + if (MD->getAttr()) { Summ.setRetEffect(isGCEnabled() ? RetEffect::MakeGCNotOwned() : RetEffect::MakeOwned(RetEffect::ObjC, true)); @@ -1161,9 +1161,9 @@ RetainSummaryManager::updateSummaryFromAnnotations(RetainSummary &Summ, updateSummaryArgEffFromAnnotations(Summ, i, *I); // Determine any effects on the receiver. - if (MD->getAttr()) + if (MD->getAttr()) Summ.setReceiverEffect(IncRefMsg); - else if (MD->getAttr()) + else if (MD->getAttr()) Summ.setReceiverEffect(DecRefMsg); } diff --git a/lib/Frontend/PCHReaderDecl.cpp b/lib/Frontend/PCHReaderDecl.cpp index 29da2ab41d..bed010d7da 100644 --- a/lib/Frontend/PCHReaderDecl.cpp +++ b/lib/Frontend/PCHReaderDecl.cpp @@ -477,10 +477,10 @@ Attr *PCHReader::ReadAttributes() { SIMPLE_ATTR(ObjCNSObject); SIMPLE_ATTR(CFOwnershipRelease); SIMPLE_ATTR(CFOwnershipRetain); - SIMPLE_ATTR(ObjCOwnershipMakeCollectable); - SIMPLE_ATTR(ObjCOwnershipRelease); - SIMPLE_ATTR(ObjCOwnershipRetain); - SIMPLE_ATTR(ObjCOwnershipReturns); + SIMPLE_ATTR(NSOwnershipMakeCollectable); + SIMPLE_ATTR(NSOwnershipRelease); + SIMPLE_ATTR(NSOwnershipRetain); + SIMPLE_ATTR(NSOwnershipReturns); SIMPLE_ATTR(Overloadable); UNSIGNED_ATTR(Packed); SIMPLE_ATTR(Pure); diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp index 2bec9d4239..2d4d8e4447 100644 --- a/lib/Frontend/PCHWriter.cpp +++ b/lib/Frontend/PCHWriter.cpp @@ -1551,10 +1551,10 @@ void PCHWriter::WriteAttributeRecord(const Attr *Attr) { case Attr::ObjCNSObject: case Attr::CFOwnershipRelease: case Attr::CFOwnershipRetain: - case Attr::ObjCOwnershipMakeCollectable: - case Attr::ObjCOwnershipRelease: - case Attr::ObjCOwnershipRetain: - case Attr::ObjCOwnershipReturns: + case Attr::NSOwnershipMakeCollectable: + case Attr::NSOwnershipRelease: + case Attr::NSOwnershipRetain: + case Attr::NSOwnershipReturns: case Attr::Overloadable: break; diff --git a/lib/Parse/AttributeList.cpp b/lib/Parse/AttributeList.cpp index a869601b47..c68a5b735b 100644 --- a/lib/Parse/AttributeList.cpp +++ b/lib/Parse/AttributeList.cpp @@ -136,26 +136,24 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) { 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; - break; - case 21: - if (!memcmp(Str, "objc_ownership_retain", 21)) - return AT_objc_ownership_retain; + if (!memcmp(Str, "ns_ownership_release", 20)) + return AT_ns_ownership_release; + if (!memcmp(Str, "ns_ownership_returns", 20)) + return AT_ns_ownership_returns; break; case 22: - if (!memcmp(Str, "objc_ownership_returns", 22)) - return AT_objc_ownership_returns; - if (!memcmp(Str, "objc_ownership_release", 22)) - return AT_objc_ownership_release; if (!memcmp(Str, "no_instrument_function", 22)) return AT_no_instrument_function; break; - case 31: - if (!memcmp(Str, "objc_ownership_make_collectable", 31)) - return AT_objc_ownership_make_collectable; + case 29: + if (!memcmp(Str, "ns_ownership_make_collectable", 29)) + return AT_ns_ownership_make_collectable; break; } return UnknownAttribute; diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 9a26c913fb..8aec8c8e07 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -1547,19 +1547,19 @@ static void HandleRegparmAttr(Decl *d, const AttributeList &Attr, Sema &S) { // Checker-specific attribute handlers. //===----------------------------------------------------------------------===// -static void HandleObjCOwnershipReturnsAttr(Decl *d, const AttributeList &Attr, +static void HandleNSOwnershipReturnsAttr(Decl *d, const AttributeList &Attr, Sema &S) { if (!isa(d) && !isa(d)) { S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) << - "objc_ownership_returns" << 3 /* function or method */; + "ns_ownership_returns" << 3 /* function or method */; return; } - d->addAttr(::new (S.Context) ObjCOwnershipReturnsAttr()); + d->addAttr(::new (S.Context) NSOwnershipReturnsAttr()); } -static void HandleObjCOwnershipAttr(Decl *d, const AttributeList &Attr, +static void HandleNSOwnershipAttr(Decl *d, const AttributeList &Attr, Sema &S, bool attachToMethodDecl = false) { if (!isa(d) && (!attachToMethodDecl || !isa(d))){ @@ -1573,12 +1573,12 @@ static void HandleObjCOwnershipAttr(Decl *d, const AttributeList &Attr, name = "cf_ownership_release"; break; case AttributeList::AT_cf_ownership_retain: name = "cf_ownership_retain"; break; - case AttributeList::AT_objc_ownership_make_collectable: - name = "objc_ownership_make_collectable"; break; - case AttributeList::AT_objc_ownership_release: - name = "objc_ownership_release"; break; - case AttributeList::AT_objc_ownership_retain: - name = "objc_ownership_retain"; break; + case AttributeList::AT_ns_ownership_make_collectable: + name = "ns_ownership_make_collectable"; break; + case AttributeList::AT_ns_ownership_release: + name = "ns_ownership_release"; break; + case AttributeList::AT_ns_ownership_retain: + name = "ns_ownership_retain"; break; }; S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) << name @@ -1595,12 +1595,12 @@ static void HandleObjCOwnershipAttr(Decl *d, const AttributeList &Attr, d->addAttr(::new (S.Context) CFOwnershipReleaseAttr()); return; case AttributeList::AT_cf_ownership_retain: d->addAttr(::new (S.Context) CFOwnershipRetainAttr()); return; - case AttributeList::AT_objc_ownership_make_collectable: - d->addAttr(::new (S.Context) ObjCOwnershipMakeCollectableAttr()); return; - case AttributeList::AT_objc_ownership_release: - d->addAttr(::new (S.Context) ObjCOwnershipReleaseAttr()); return; - case AttributeList::AT_objc_ownership_retain: - d->addAttr(::new (S.Context) ObjCOwnershipRetainAttr()); return; + case AttributeList::AT_ns_ownership_make_collectable: + d->addAttr(::new (S.Context) NSOwnershipMakeCollectableAttr()); return; + case AttributeList::AT_ns_ownership_release: + d->addAttr(::new (S.Context) NSOwnershipReleaseAttr()); return; + case AttributeList::AT_ns_ownership_retain: + d->addAttr(::new (S.Context) NSOwnershipRetainAttr()); return; } } @@ -1644,13 +1644,13 @@ static void ProcessDeclAttribute(Decl *D, const AttributeList &Attr, Sema &S) { // Checker-specific. case AttributeList::AT_cf_ownership_release: case AttributeList::AT_cf_ownership_retain: - HandleObjCOwnershipAttr(D, Attr, S); break; - case AttributeList::AT_objc_ownership_make_collectable: - case AttributeList::AT_objc_ownership_release: - case AttributeList::AT_objc_ownership_retain: - HandleObjCOwnershipAttr(D, Attr, S, true); break; - case AttributeList::AT_objc_ownership_returns: - HandleObjCOwnershipReturnsAttr(D, Attr, S); break; + HandleNSOwnershipAttr(D, Attr, S); break; + case AttributeList::AT_ns_ownership_make_collectable: + case AttributeList::AT_ns_ownership_release: + case AttributeList::AT_ns_ownership_retain: + HandleNSOwnershipAttr(D, Attr, S, true); break; + case AttributeList::AT_ns_ownership_returns: + HandleNSOwnershipReturnsAttr(D, Attr, S); break; case AttributeList::AT_packed: HandlePackedAttr (D, Attr, S); break; case AttributeList::AT_section: HandleSectionAttr (D, Attr, S); break; diff --git a/test/Analysis/retain-release-gc-only.m b/test/Analysis/retain-release-gc-only.m index 3082b266c7..79f9f4c1e5 100644 --- a/test/Analysis/retain-release-gc-only.m +++ b/test/Analysis/retain-release-gc-only.m @@ -129,12 +129,12 @@ void f3() { //===----------------------------------------------------------------------===// @interface TestOwnershipAttr : NSObject -- (NSString*) returnsAnOwnedString __attribute__((objc_ownership_returns)); -- (void) myRetain:(id)__attribute__((objc_ownership_retain))obj; +- (NSString*) returnsAnOwnedString __attribute__((ns_ownership_returns)); +- (void) myRetain:(id)__attribute__((ns_ownership_retain))obj; - (void) myCFRetain:(id)__attribute__((cf_ownership_retain))obj; -- (void) myRelease:(id)__attribute__((objc_ownership_release))obj; +- (void) myRelease:(id)__attribute__((ns_ownership_release))obj; - (void) myCFRelease:(id)__attribute__((cf_ownership_release))obj; -- (void) makeCollectable:(id)__attribute__((objc_ownership_make_collectable))obj; +- (void) makeCollectable:(id)__attribute__((ns_ownership_make_collectable))obj; @end void test_attr_1(TestOwnershipAttr *X) { diff --git a/test/Analysis/retain-release.m b/test/Analysis/retain-release.m index c0de303d21..84225c7b09 100644 --- a/test/Analysis/retain-release.m +++ b/test/Analysis/retain-release.m @@ -431,19 +431,19 @@ void rdar6704930(unsigned char *s, unsigned int length) { //===----------------------------------------------------------------------===// @interface TestOwnershipAttr : NSObject -- (NSString*) returnsAnOwnedString __attribute__((objc_ownership_returns)); -- (void) myRetain:(id)__attribute__((objc_ownership_retain))obj; +- (NSString*) returnsAnOwnedString __attribute__((ns_ownership_returns)); +- (void) myRetain:(id)__attribute__((ns_ownership_retain))obj; - (void) myCFRetain:(id)__attribute__((cf_ownership_retain))obj; -- (void) myRelease:(id)__attribute__((objc_ownership_release))obj; +- (void) myRelease:(id)__attribute__((ns_ownership_release))obj; - (void) myCFRelease:(id)__attribute__((cf_ownership_release))obj; -- (void) myRetain __attribute__((objc_ownership_retain)); -- (void) myRelease __attribute__((objc_ownership_release)); +- (void) myRetain __attribute__((ns_ownership_retain)); +- (void) myRelease __attribute__((ns_ownership_release)); @end @interface TestAttrHelper : NSObject - (NSString*) createString:(TestOwnershipAttr*)X; -- (NSString*) createStringAttr:(TestOwnershipAttr*)X __attribute__((objc_ownership_returns)); +- (NSString*) createStringAttr:(TestOwnershipAttr*)X __attribute__((ns_ownership_returns)); @end @implementation TestAttrHelper -- 2.40.0