]> granicus.if.org Git - clang/commitdiff
-Fix mistake in ASTContext::getInnerObjCOwnership noticed by Doug
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 1 Jul 2011 23:01:46 +0000 (23:01 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 1 Jul 2011 23:01:46 +0000 (23:01 +0000)
-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

lib/AST/ASTContext.cpp
lib/Sema/SemaType.cpp
test/SemaObjCXX/arc-type-conversion.mm

index aca011f9df99fdde14e88de787485a97aedd0d5e..53fb7129fdf8733ad30a6f540fb39a7a9144517c 100644 (file)
@@ -3523,7 +3523,7 @@ Qualifiers::ObjCLifetime ASTContext::getInnerObjCOwnership(QualType T) const {
     else if (const PointerType *PT = T->getAs<PointerType>())
       T = PT->getPointeeType();
     else if (const ReferenceType *RT = T->getAs<ReferenceType>())
-      RT->getPointeeType();
+      T = RT->getPointeeType();
     else
       break;
   }
index cd4a5b50d8b76a48b8be44345d0cf4eaaf65f034..3f211daeac9d0be5cba388b6e165a4a7d2408871 100644 (file)
@@ -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).
index 5e7d5cc859513a0e56ae906485d7c2139f237c4f..baf4b8208270ffe4f64f11ef817e40cd48b8743d 100644 (file)
@@ -203,6 +203,7 @@ typedef void (^Block_autoreleasing)() __autoreleasing;
 
 void ownership_transfer_in_cast(void *vp, Block *pblk) {
   __strong NSString **sip2 = static_cast<NSString **>(static_cast<__strong id *>(vp));
+  __strong NSString **&si2pref = static_cast<NSString **&>(sip2);
   __weak NSString **wip2 = static_cast<NSString **>(static_cast<__weak id *>(vp));
   __autoreleasing id *aip2 = static_cast<id *>(static_cast<__autoreleasing id *>(vp));
   __unsafe_unretained id *uip2 = static_cast<id *>(static_cast<__unsafe_unretained id *>(vp));