diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-08-21 05:42:49 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-08-21 05:42:49 +0000 |
commit | 88d2f678e70ab9360f09f3534d9223e6ec20f129 (patch) | |
tree | 2031f39e8dc48551adbf29138aad15c1be220f59 /lib/AST/ExprCXX.cpp | |
parent | 929bbfb0b69165b55da3c56abf22aa10e20dadc6 (diff) |
Fix alignment of array of VarDecl* following array of unsigned in LambdaExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162255 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ExprCXX.cpp')
-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, |