diff options
author | Steve Naroff <snaroff@apple.com> | 2009-03-13 16:56:44 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2009-03-13 16:56:44 +0000 |
commit | e78b809bbcd92928a63da81f2cd843faad3e4dfd (patch) | |
tree | a49947086849b15be6f821750d3c6464a125ad3f /lib | |
parent | 6ae8a3600656c478d27f25639bed765f4fe71732 (diff) |
Fix <rdar://problem/6675489> BlockDecl should not use llvm::smallvector.
Also changed BlockDecl API to be more consistent (wrt FunctionDecl).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66904 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/Decl.cpp | 17 | ||||
-rw-r--r-- | lib/CodeGen/CGBlocks.cpp | 2 | ||||
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 3 |
3 files changed, 20 insertions, 2 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 5786c56210..bd16331c1b 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -514,3 +514,20 @@ void BlockDecl::Destroy(ASTContext& C) { Decl::Destroy(C); } + +void BlockDecl::setParams(ASTContext& C, ParmVarDecl **NewParamInfo, + unsigned NParms) { + assert(ParamInfo == 0 && "Already has param info!"); + + // Zero params -> null pointer. + if (NParms) { + NumParams = NParms; + void *Mem = C.Allocate(sizeof(ParmVarDecl*)*NumParams); + ParamInfo = new (Mem) ParmVarDecl*[NumParams]; + memcpy(ParamInfo, NewParamInfo, sizeof(ParmVarDecl*)*NumParams); + } +} + +unsigned BlockDecl::getNumParams() const { + return NumParams; +} diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp index 53e52ad478..f61d75b0f8 100644 --- a/lib/CodeGen/CGBlocks.cpp +++ b/lib/CodeGen/CGBlocks.cpp @@ -624,7 +624,7 @@ CodeGenFunction::GenerateBlockFunction(const BlockExpr *BExpr, Args.push_back(std::make_pair(SelfDecl, SelfDecl->getType())); BlockStructDecl = SelfDecl; - for (BlockDecl::param_iterator i = BD->param_begin(), + for (BlockDecl::param_const_iterator i = BD->param_begin(), e = BD->param_end(); i != e; ++i) Args.push_back(std::make_pair(*i, (*i)->getType())); diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 8324d8d472..4a314525bf 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -4595,7 +4595,8 @@ void Sema::ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope) { if (!RetTy->isDependentType()) CurBlock->ReturnType = RetTy; } - CurBlock->TheDecl->setArgs(&CurBlock->Params[0], CurBlock->Params.size()); + CurBlock->TheDecl->setParams(Context, &CurBlock->Params[0], + CurBlock->Params.size()); for (BlockDecl::param_iterator AI = CurBlock->TheDecl->param_begin(), E = CurBlock->TheDecl->param_end(); AI != E; ++AI) |