aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGBlocks.cpp
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2009-10-20 02:12:22 +0000
committerMike Stump <mrs@apple.com>2009-10-20 02:12:22 +0000
commitadaaad3715c9c26cdcfdfe3401a13d7b4423ddcf (patch)
treead2ec2fa2dd2e020251449a3537edd506bfed18d /lib/CodeGen/CGBlocks.cpp
parent9a2c8bb599a2460807e341182655a68515574124 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84590 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGBlocks.cpp')
-rw-r--r--lib/CodeGen/CGBlocks.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp
index 736425e012..5998493986 100644
--- a/lib/CodeGen/CGBlocks.cpp
+++ b/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);