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 | c7520bf7858df3b14f26471d2cc822ef0738bb5e (patch) | |
tree | b521efc26a07628bc6fa132e87e2254d10cd0c6f /clang/lib/AST | |
parent | f1249929c8a5d995a29f47221fee792e480b7ca5 (diff) | |
download | bcm5719-llvm-c7520bf7858df3b14f26471d2cc822ef0738bb5e.tar.gz bcm5719-llvm-c7520bf7858df3b14f26471d2cc822ef0738bb5e.zip |
Fix alignment of array of VarDecl* following array of unsigned in LambdaExpr.
llvm-svn: 162255
Diffstat (limited to 'clang/lib/AST')
-rw-r--r-- | clang/lib/AST/ExprCXX.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp index 3fa49e0e18b..97814afa18b 100644 --- a/clang/lib/AST/ExprCXX.cpp +++ b/clang/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, |