diff options
author | James Y Knight <jyknight@google.com> | 2015-12-30 02:27:28 +0000 |
---|---|---|
committer | James Y Knight <jyknight@google.com> | 2015-12-30 02:27:28 +0000 |
commit | 1d75c5eccf2846122776a9faafaa72aa57be9b3c (patch) | |
tree | ce338e3043baec18b0ae80665cdf6793d6a697cf /clang/lib/AST/ExprCXX.cpp | |
parent | 54894fdcc49cc27195d86333447c192f5be1f55e (diff) | |
download | bcm5719-llvm-1d75c5eccf2846122776a9faafaa72aa57be9b3c.tar.gz bcm5719-llvm-1d75c5eccf2846122776a9faafaa72aa57be9b3c.zip |
[TrailingObjects] Convert CastExpr and subclasses.
llvm-svn: 256608
Diffstat (limited to 'clang/lib/AST/ExprCXX.cpp')
-rw-r--r-- | clang/lib/AST/ExprCXX.cpp | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp index c0aafd42ad5..4bb4b5073c4 100644 --- a/clang/lib/AST/ExprCXX.cpp +++ b/clang/lib/AST/ExprCXX.cpp @@ -589,19 +589,19 @@ CXXStaticCastExpr *CXXStaticCastExpr::Create(const ASTContext &C, QualType T, SourceLocation RParenLoc, SourceRange AngleBrackets) { unsigned PathSize = (BasePath ? BasePath->size() : 0); - void *Buffer = C.Allocate(sizeof(CXXStaticCastExpr) - + PathSize * sizeof(CXXBaseSpecifier*)); + void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize)); CXXStaticCastExpr *E = new (Buffer) CXXStaticCastExpr(T, VK, K, Op, PathSize, WrittenTy, L, RParenLoc, AngleBrackets); - if (PathSize) E->setCastPath(*BasePath); + if (PathSize) + std::uninitialized_copy_n(BasePath->data(), BasePath->size(), + E->getTrailingObjects<CXXBaseSpecifier *>()); return E; } CXXStaticCastExpr *CXXStaticCastExpr::CreateEmpty(const ASTContext &C, unsigned PathSize) { - void *Buffer = - C.Allocate(sizeof(CXXStaticCastExpr) + PathSize * sizeof(CXXBaseSpecifier*)); + void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize)); return new (Buffer) CXXStaticCastExpr(EmptyShell(), PathSize); } @@ -614,19 +614,19 @@ CXXDynamicCastExpr *CXXDynamicCastExpr::Create(const ASTContext &C, QualType T, SourceLocation RParenLoc, SourceRange AngleBrackets) { unsigned PathSize = (BasePath ? BasePath->size() : 0); - void *Buffer = C.Allocate(sizeof(CXXDynamicCastExpr) - + PathSize * sizeof(CXXBaseSpecifier*)); + void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize)); CXXDynamicCastExpr *E = new (Buffer) CXXDynamicCastExpr(T, VK, K, Op, PathSize, WrittenTy, L, RParenLoc, AngleBrackets); - if (PathSize) E->setCastPath(*BasePath); + if (PathSize) + std::uninitialized_copy_n(BasePath->data(), BasePath->size(), + E->getTrailingObjects<CXXBaseSpecifier *>()); return E; } CXXDynamicCastExpr *CXXDynamicCastExpr::CreateEmpty(const ASTContext &C, unsigned PathSize) { - void *Buffer = - C.Allocate(sizeof(CXXDynamicCastExpr) + PathSize * sizeof(CXXBaseSpecifier*)); + void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize)); return new (Buffer) CXXDynamicCastExpr(EmptyShell(), PathSize); } @@ -671,19 +671,19 @@ CXXReinterpretCastExpr::Create(const ASTContext &C, QualType T, SourceLocation RParenLoc, SourceRange AngleBrackets) { unsigned PathSize = (BasePath ? BasePath->size() : 0); - void *Buffer = - C.Allocate(sizeof(CXXReinterpretCastExpr) + PathSize * sizeof(CXXBaseSpecifier*)); + void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize)); CXXReinterpretCastExpr *E = new (Buffer) CXXReinterpretCastExpr(T, VK, K, Op, PathSize, WrittenTy, L, RParenLoc, AngleBrackets); - if (PathSize) E->setCastPath(*BasePath); + if (PathSize) + std::uninitialized_copy_n(BasePath->data(), BasePath->size(), + E->getTrailingObjects<CXXBaseSpecifier *>()); return E; } CXXReinterpretCastExpr * CXXReinterpretCastExpr::CreateEmpty(const ASTContext &C, unsigned PathSize) { - void *Buffer = C.Allocate(sizeof(CXXReinterpretCastExpr) - + PathSize * sizeof(CXXBaseSpecifier*)); + void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize)); return new (Buffer) CXXReinterpretCastExpr(EmptyShell(), PathSize); } @@ -706,18 +706,18 @@ CXXFunctionalCastExpr::Create(const ASTContext &C, QualType T, ExprValueKind VK, const CXXCastPath *BasePath, SourceLocation L, SourceLocation R) { unsigned PathSize = (BasePath ? BasePath->size() : 0); - void *Buffer = C.Allocate(sizeof(CXXFunctionalCastExpr) - + PathSize * sizeof(CXXBaseSpecifier*)); + void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize)); CXXFunctionalCastExpr *E = new (Buffer) CXXFunctionalCastExpr(T, VK, Written, K, Op, PathSize, L, R); - if (PathSize) E->setCastPath(*BasePath); + if (PathSize) + std::uninitialized_copy_n(BasePath->data(), BasePath->size(), + E->getTrailingObjects<CXXBaseSpecifier *>()); return E; } CXXFunctionalCastExpr * CXXFunctionalCastExpr::CreateEmpty(const ASTContext &C, unsigned PathSize) { - void *Buffer = C.Allocate(sizeof(CXXFunctionalCastExpr) - + PathSize * sizeof(CXXBaseSpecifier*)); + void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize)); return new (Buffer) CXXFunctionalCastExpr(EmptyShell(), PathSize); } |