diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2012-11-04 18:19:40 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2012-11-04 18:19:40 +0000 |
commit | c441cd347014bd3fe1915333c992a9a68bd725f9 (patch) | |
tree | a32d086c209e99a9697b1b4def5df280c534374c /lib/CodeGen | |
parent | 3f320aa93253cc69d03579b37fd0724055883a6e (diff) |
Fixes liftime of captured block variables in mrr mode, per John's feedback, as
well as couple of tests which were not being excercised because of TYPOs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167374 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/CGObjCMac.cpp | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index 514f550ad4..acf4f2a021 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -942,7 +942,7 @@ protected: unsigned int BytePos, bool ForStrongLayout, bool &HasUnion); - Qualifiers::ObjCLifetime GetObjCLifeTime(QualType QT); + Qualifiers::ObjCLifetime getBlockCaptureLifetime(QualType QT); void UpdateRunSkipBlockVars(bool IsByref, Qualifiers::ObjCLifetime LifeTime, @@ -1964,21 +1964,16 @@ llvm::Constant *CGObjCCommonMac::BuildGCBlockLayout(CodeGenModule &CGM, return C; } -Qualifiers::ObjCLifetime CGObjCCommonMac::GetObjCLifeTime(QualType FQT) { +/// getBlockCaptureLifetime - This routine returns life time of the captured +/// block variable for the purpose of block layout meta-data generation. FQT is +/// the type of the variable captured in the block. +Qualifiers::ObjCLifetime CGObjCCommonMac::getBlockCaptureLifetime(QualType FQT) { if (CGM.getLangOpts().ObjCAutoRefCount) return FQT.getObjCLifetime(); - // MRR, is more ad hoc. - if (FQT.isObjCGCStrong()) - return Qualifiers::OCL_Strong; - if (FQT.isObjCGCWeak()) - return Qualifiers::OCL_Weak; - + // MRR. if (FQT->isObjCObjectPointerType() || FQT->isBlockPointerType()) - return Qualifiers::OCL_Strong; - - if (const PointerType *PT = FQT->getAs<PointerType>()) - return (GetObjCLifeTime(PT->getPointeeType())); + return Qualifiers::OCL_ExplicitNone; return Qualifiers::OCL_None; } @@ -2095,7 +2090,7 @@ void CGObjCCommonMac::BuildRCRecordLayout(const llvm::StructLayout *RecLayout, } } else { UpdateRunSkipBlockVars(false, - GetObjCLifeTime(FQT), + getBlockCaptureLifetime(FQT), BytePos + FieldOffset, FieldSize); } @@ -2110,7 +2105,7 @@ void CGObjCCommonMac::BuildRCRecordLayout(const llvm::StructLayout *RecLayout, ((BitFieldSize % ByteSizeInBits) != 0); Size += LastBitfieldOrUnnamedOffset; UpdateRunSkipBlockVars(false, - GetObjCLifeTime(LastFieldBitfieldOrUnnamed->getType()), + getBlockCaptureLifetime(LastFieldBitfieldOrUnnamed->getType()), BytePos + LastBitfieldOrUnnamedOffset, Size*ByteSizeInBits); } else { @@ -2119,7 +2114,7 @@ void CGObjCCommonMac::BuildRCRecordLayout(const llvm::StructLayout *RecLayout, unsigned FieldSize = CGM.getContext().getTypeSize(LastFieldBitfieldOrUnnamed->getType()); UpdateRunSkipBlockVars(false, - GetObjCLifeTime(LastFieldBitfieldOrUnnamed->getType()), + getBlockCaptureLifetime(LastFieldBitfieldOrUnnamed->getType()), BytePos + LastBitfieldOrUnnamedOffset, FieldSize); } @@ -2127,7 +2122,7 @@ void CGObjCCommonMac::BuildRCRecordLayout(const llvm::StructLayout *RecLayout, if (MaxField) UpdateRunSkipBlockVars(false, - GetObjCLifeTime(MaxField->getType()), + getBlockCaptureLifetime(MaxField->getType()), BytePos + MaxFieldOffset, MaxUnionSize); } @@ -2295,7 +2290,7 @@ llvm::Constant *CGObjCCommonMac::BuildRCBlockLayout(CodeGenModule &CGM, } unsigned fieldSize = ci->isByRef() ? WordSizeInBits : CGM.getContext().getTypeSize(type); - UpdateRunSkipBlockVars(ci->isByRef(), GetObjCLifeTime(type), + UpdateRunSkipBlockVars(ci->isByRef(), getBlockCaptureLifetime(type), fieldOffset, fieldSize); } |