diff options
author | Mike Stump <mrs@apple.com> | 2009-10-20 02:12:22 +0000 |
---|---|---|
committer | Mike Stump <mrs@apple.com> | 2009-10-20 02:12:22 +0000 |
commit | d015328f1503d47bf7ff6021135c78f5d78e5407 (patch) | |
tree | e800d86a96f31e482959e314abe5a5a7f245e6fd /clang/lib/CodeGen/CGBlocks.cpp | |
parent | b9e71d9fd1951e097f208b534ea716ba0b6c715d (diff) | |
download | bcm5719-llvm-d015328f1503d47bf7ff6021135c78f5d78e5407.tar.gz bcm5719-llvm-d015328f1503d47bf7ff6021135c78f5d78e5407.zip |
Refine the type of the first parameter to block invoke functions.
WIP. I have yet to find the magic incantation to get the structure
type to be defined. If someone has a pointer, love to hear it.
llvm-svn: 84590
Diffstat (limited to 'clang/lib/CodeGen/CGBlocks.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGBlocks.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index 736425e0127..59984939861 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -632,11 +632,15 @@ CodeGenFunction::GenerateBlockFunction(const BlockExpr *BExpr, const BlockDecl *BD = BExpr->getBlockDecl(); + IdentifierInfo *II + = &CGM.getContext().Idents.get(".block_descriptor"); + + QualType ParmTy = getContext().getBlockParmType(); // FIXME: This leaks ImplicitParamDecl *SelfDecl = ImplicitParamDecl::Create(getContext(), 0, - SourceLocation(), 0, - getContext().getPointerType(getContext().VoidTy)); + SourceLocation(), II, + ParmTy); Args.push_back(std::make_pair(SelfDecl, SelfDecl->getType())); BlockStructDecl = SelfDecl; @@ -701,6 +705,22 @@ CodeGenFunction::GenerateBlockFunction(const BlockExpr *BExpr, FinishFunction(cast<CompoundStmt>(BExpr->getBody())->getRBracLoc()); + // And now finish off the type for the parameter, since now we know + // BlockDeclRefDecls is complete. + getContext().completeBlockParmType(ParmTy, BlockDeclRefDecls); + +#define REV2 +#ifdef REV2 + TagDecl *TD = ParmTy->getPointeeType()->getAs<RecordType>()->getDecl(); + CGM.UpdateCompletedType(TD); +#else + TagDecl *TD = ParmTy->getPointeeType()->getAs<RecordType>()->getDecl(); + TagDecl::redecl_iterator rdi = TD->redecls_begin(); + ++rdi; + TD = *rdi; + CGM.UpdateCompletedType(TD); +#endif + // The runtime needs a minimum alignment of a void *. uint64_t MinAlign = getContext().getTypeAlign(getContext().VoidPtrTy) / 8; BlockOffset = llvm::RoundUpToAlignment(BlockOffset, MinAlign); |