From: Argyrios Kyrtzidis Date: Fri, 1 Jul 2011 23:01:46 +0000 (+0000) Subject: -Fix mistake in ASTContext::getInnerObjCOwnership noticed by Doug X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=28445f0b62f6aed851ff87ce64d9b19200d3211f;p=clang -Fix mistake in ASTContext::getInnerObjCOwnership noticed by Doug -Remove unnecessary 'return'. -Remove unnecessary 'if' check (llvm_unreachable make sure attrStr will be non-null) -Add a test of transferring ownership to a reference cast type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134285 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index aca011f9df..53fb7129fd 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -3523,7 +3523,7 @@ Qualifiers::ObjCLifetime ASTContext::getInnerObjCOwnership(QualType T) const { else if (const PointerType *PT = T->getAs()) T = PT->getPointeeType(); else if (const ReferenceType *RT = T->getAs()) - RT->getPointeeType(); + T = RT->getPointeeType(); else break; } diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index cd4a5b50d8..3f211daeac 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -2546,7 +2546,6 @@ static void transferARCOwnershipToDeclSpec(Sema &S, qs.addObjCLifetime(ownership); declSpecTy = S.Context.getQualifiedType(declSpecTy, qs); } - return; } static void transferARCOwnershipToDeclaratorChunk(TypeProcessingState &state, @@ -2570,8 +2569,6 @@ static void transferARCOwnershipToDeclaratorChunk(TypeProcessingState &state, case Qualifiers::OCL_Weak: attrStr = "weak"; break; case Qualifiers::OCL_Autoreleasing: attrStr = "autoreleasing"; break; } - if (!attrStr) - return; // If there wasn't one, add one (with an invalid source location // so that we don't make an AttributedType for it). diff --git a/test/SemaObjCXX/arc-type-conversion.mm b/test/SemaObjCXX/arc-type-conversion.mm index 5e7d5cc859..baf4b82082 100644 --- a/test/SemaObjCXX/arc-type-conversion.mm +++ b/test/SemaObjCXX/arc-type-conversion.mm @@ -203,6 +203,7 @@ typedef void (^Block_autoreleasing)() __autoreleasing; void ownership_transfer_in_cast(void *vp, Block *pblk) { __strong NSString **sip2 = static_cast(static_cast<__strong id *>(vp)); + __strong NSString **&si2pref = static_cast(sip2); __weak NSString **wip2 = static_cast(static_cast<__weak id *>(vp)); __autoreleasing id *aip2 = static_cast(static_cast<__autoreleasing id *>(vp)); __unsafe_unretained id *uip2 = static_cast(static_cast<__unsafe_unretained id *>(vp));