diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2014-05-13 14:55:01 +0000 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2014-05-13 14:55:01 +0000 |
commit | f3d9b09dea165440377967d64dcb87cbff6ed469 (patch) | |
tree | 7c93eddf74e60fc83046a19ddbde68cccb4a1af7 /clang/lib | |
parent | b9bd76b85dc4c0039c2d1daaef3208f086fac140 (diff) | |
download | bcm5719-llvm-f3d9b09dea165440377967d64dcb87cbff6ed469.tar.gz bcm5719-llvm-f3d9b09dea165440377967d64dcb87cbff6ed469.zip |
No longer triggering a checked iterator assert on Windows when using std::copy while deserializing attributed statements with more than one attribute.
llvm-svn: 208702
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/Stmt.cpp | 7 | ||||
-rw-r--r-- | clang/lib/Serialization/ASTReaderStmt.cpp | 2 |
2 files changed, 4 insertions, 5 deletions
diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp index e6468f760a5..8588dda363c 100644 --- a/clang/lib/AST/Stmt.cpp +++ b/clang/lib/AST/Stmt.cpp @@ -285,8 +285,8 @@ const char *LabelStmt::getName() const { AttributedStmt *AttributedStmt::Create(const ASTContext &C, SourceLocation Loc, ArrayRef<const Attr*> Attrs, Stmt *SubStmt) { - void *Mem = C.Allocate(sizeof(AttributedStmt) + - sizeof(Attr*) * (Attrs.size() - 1), + assert(!Attrs.empty() && "Attrs should not be empty"); + void *Mem = C.Allocate(sizeof(AttributedStmt) + sizeof(Attr *) * Attrs.size(), llvm::alignOf<AttributedStmt>()); return new (Mem) AttributedStmt(Loc, Attrs, SubStmt); } @@ -294,8 +294,7 @@ AttributedStmt *AttributedStmt::Create(const ASTContext &C, SourceLocation Loc, AttributedStmt *AttributedStmt::CreateEmpty(const ASTContext &C, unsigned NumAttrs) { assert(NumAttrs > 0 && "NumAttrs should be greater than zero"); - void *Mem = C.Allocate(sizeof(AttributedStmt) + - sizeof(Attr*) * (NumAttrs - 1), + void *Mem = C.Allocate(sizeof(AttributedStmt) + sizeof(Attr *) * NumAttrs, llvm::alignOf<AttributedStmt>()); return new (Mem) AttributedStmt(EmptyShell(), NumAttrs); } diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp index ce44fea84a1..3501817916e 100644 --- a/clang/lib/Serialization/ASTReaderStmt.cpp +++ b/clang/lib/Serialization/ASTReaderStmt.cpp @@ -176,7 +176,7 @@ void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) { (void)NumAttrs; assert(NumAttrs == S->NumAttrs); assert(NumAttrs == Attrs.size()); - std::copy(Attrs.begin(), Attrs.end(), S->Attrs); + std::copy(Attrs.begin(), Attrs.end(), S->getAttrArrayPtr()); S->SubStmt = Reader.ReadSubStmt(); S->AttrLoc = ReadSourceLocation(Record, Idx); } |