Don't allocate unused storage for captures/capture initializers in lambda expressions

llvm-svn: 150394
This commit is contained in:
Douglas Gregor 2012-02-13 15:51:35 +00:00
parent c8a734938b
commit 1db5f1f1a0
1 changed files with 3 additions and 6 deletions

View File

@ -781,13 +781,10 @@ LambdaExpr *LambdaExpr::Create(ASTContext &Context,
// Determine the type of the expression (i.e., the type of the
// function object we're creating).
QualType T = Context.getTypeDeclType(Class);
size_t Size = sizeof(LambdaExpr) + sizeof(Capture) * Captures.size()
+ sizeof(Stmt *) * (Captures.size() + 1);
void *Mem = Context.Allocate(Size, llvm::alignOf<LambdaExpr>());
return new (Mem) LambdaExpr(T, IntroducerRange, CaptureDefault,
Captures, ExplicitParams, CaptureInits,
ClosingBrace);
return new (Context) LambdaExpr(T, IntroducerRange, CaptureDefault,
Captures, ExplicitParams, CaptureInits,
ClosingBrace);
}
LambdaExpr::capture_iterator LambdaExpr::capture_begin() const {