[cfe-commits] r167331 - in /cfe/trunk: lib/CodeGen/CGObjCMac.cpp test/CodeGenObjC/mrr-captured-block-var-inlined-layout.m
John McCall
rjmccall at apple.com
Fri Nov 2 17:35:00 PDT 2012
On Nov 2, 2012, at 3:51 PM, Fariborz Jahanian wrote:
> Author: fjahanian
> Date: Fri Nov 2 17:51:18 2012
> New Revision: 167331
>
> URL: http://llvm.org/viewvc/llvm-project?rev=167331&view=rev
> Log:
> objective-C mrr block. Block variable layout metadata in
> mrr mode.
>
> Added:
> cfe/trunk/test/CodeGenObjC/mrr-captured-block-var-inlined-layout.m
> Modified:
> cfe/trunk/lib/CodeGen/CGObjCMac.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=167331&r1=167330&r2=167331&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Fri Nov 2 17:51:18 2012
> @@ -942,6 +942,8 @@
> unsigned int BytePos, bool ForStrongLayout,
> bool &HasUnion);
>
> + Qualifiers::ObjCLifetime GetObjCLifeTime(QualType QT);
> +
> void UpdateRunSkipBlockVars(bool IsByref,
> Qualifiers::ObjCLifetime LifeTime,
> unsigned FieldOffset,
> @@ -1962,6 +1964,25 @@
> return C;
> }
>
> +Qualifiers::ObjCLifetime CGObjCCommonMac::GetObjCLifeTime(QualType FQT) {
For consistency, please call this getObjCLifetime, or better yet, something
like getBlockCaptureLifetime. Also, please add a comment explaining its
purpose.
> + 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;
I don't think these qualifiers can ever be present in an MRC build,
and we should never be emitting this layout in a GC build.
> + if (FQT->isObjCObjectPointerType() || FQT->isBlockPointerType())
> + return Qualifiers::OCL_Strong;
This is true of direct captures, but an MRR __block variable of a id/block
actually uses __unsafe_unretained semantics.
> + if (const PointerType *PT = FQT->getAs<PointerType>())
> + return (GetObjCLifeTime(PT->getPointeeType()));
This seems wrong. There's no difference between an id* and a char*
for the purposes of this layout — it's just opaque data. An id* is
definitely not a strong capture.
John.
More information about the cfe-commits
mailing list