diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/ExprCXX.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp index 3fa49e0e18..97814afa18 100644 --- a/lib/AST/ExprCXX.cpp +++ b/lib/AST/ExprCXX.cpp @@ -877,9 +877,13 @@ LambdaExpr *LambdaExpr::Create(ASTContext &Context, QualType T = Context.getTypeDeclType(Class); unsigned Size = sizeof(LambdaExpr) + sizeof(Stmt *) * (Captures.size() + 1); - if (!ArrayIndexVars.empty()) - Size += sizeof(VarDecl *) * ArrayIndexVars.size() - + sizeof(unsigned) * (Captures.size() + 1); + if (!ArrayIndexVars.empty()) { + Size += sizeof(unsigned) * (Captures.size() + 1); + // Realign for following VarDecl array. + unsigned Align = llvm::alignOf<VarDecl*>(); + Size = (Size + Align - 1) & ~(Align - 1); + Size += sizeof(VarDecl *) * ArrayIndexVars.size(); + } void *Mem = Context.Allocate(Size); return new (Mem) LambdaExpr(T, IntroducerRange, CaptureDefault, Captures, ExplicitParams, ExplicitResultType, |