diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2010-08-06 16:28:55 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-08-06 16:28:55 +0000 |
commit | f95e3580041a0ef151f6262d7a7d92fb0a4346d5 (patch) | |
tree | aac28c20a2c17c0e22a21b3459a2f8318d41fc68 /clang/lib | |
parent | 027d5bcf898dd6e3edc83fd3a5ddac3e0e94c0af (diff) | |
download | bcm5719-llvm-f95e3580041a0ef151f6262d7a7d92fb0a4346d5.tar.gz bcm5719-llvm-f95e3580041a0ef151f6262d7a7d92fb0a4346d5.zip |
Finishing up block variable layout API by supporting
union type variables and their nesting inside other
aggregate types.
llvm-svn: 110448
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/CGObjCMac.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp index b3921a48165..d9d79e15875 100644 --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/lib/CodeGen/CGObjCMac.cpp @@ -1714,6 +1714,7 @@ llvm::Constant *CGObjCCommonMac::GCBlockLayout(CodeGen::CodeGenFunction &CGF, if ((CGM.getLangOptions().getGCMode() == LangOptions::NonGC) || DeclRefs.empty()) return NullPtr; + bool hasUnion = false; SkipIvars.clear(); IvarsInfo.clear(); unsigned WordSizeInBits = CGM.getContext().Target.getPointerWidth(0); @@ -1727,19 +1728,14 @@ llvm::Constant *CGObjCCommonMac::GCBlockLayout(CodeGen::CodeGenFunction &CGF, QualType Ty = VD->getType(); assert(!Ty->isArrayType() && "Array block variable should have been caught"); - if (Ty->isRecordType() && !BDRE->isByRef()) { - bool HasUnion = false; + if ((Ty->isRecordType() || Ty->isUnionType()) && !BDRE->isByRef()) { BuildAggrIvarRecordLayout(Ty->getAs<RecordType>(), FieldOffset, true, - HasUnion); + hasUnion); continue; } - // FIXME. Handle none __block Aggregate variables -#if 0 - if (Ty->isUnionType() && !BDRE->isByRef()) - assert(false && "union block variable layout NYI"); -#endif + Qualifiers::GC GCAttr = GetGCAttrTypeForType(CGM.getContext(), Ty); unsigned FieldSize = CGM.getContext().getTypeSize(Ty); // __block variables are passed by their descriptior address. So, size @@ -1756,6 +1752,12 @@ llvm::Constant *CGObjCCommonMac::GCBlockLayout(CodeGen::CodeGenFunction &CGF, if (IvarsInfo.empty()) return NullPtr; + // Sort on byte position in case we encounterred a union nested in + // block variable type's aggregate type. + if (hasUnion && !IvarsInfo.empty()) + std::sort(IvarsInfo.begin(), IvarsInfo.end()); + if (hasUnion && !SkipIvars.empty()) + std::sort(SkipIvars.begin(), SkipIvars.end()); std::string BitMap; llvm::Constant *C = BuildIvarLayoutBitmap(BitMap); |