diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2015-12-30 11:49:41 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2015-12-30 11:49:41 +0000 |
| commit | 45b533945f0851ec234ca846e1af5ee1e4df0b6e (patch) | |
| tree | 0a5b74c0b9ca73aded34df95c91fcaf3815230d8 /lib/AST/DeclGroup.cpp | |
| parent | 7e86edd64bfae4e324224452e4ea879b3371a4bd (diff) | |
Notes
Diffstat (limited to 'lib/AST/DeclGroup.cpp')
| -rw-r--r-- | lib/AST/DeclGroup.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/AST/DeclGroup.cpp b/lib/AST/DeclGroup.cpp index 512837fdf3f4..f162e6d40c48 100644 --- a/lib/AST/DeclGroup.cpp +++ b/lib/AST/DeclGroup.cpp @@ -18,10 +18,8 @@ using namespace clang; DeclGroup* DeclGroup::Create(ASTContext &C, Decl **Decls, unsigned NumDecls) { - static_assert(sizeof(DeclGroup) % llvm::AlignOf<void *>::Alignment == 0, - "Trailing data is unaligned!"); assert(NumDecls > 1 && "Invalid DeclGroup"); - unsigned Size = sizeof(DeclGroup) + sizeof(Decl*) * NumDecls; + unsigned Size = totalSizeToAlloc<Decl *>(NumDecls); void* Mem = C.Allocate(Size, llvm::AlignOf<DeclGroup>::Alignment); new (Mem) DeclGroup(NumDecls, Decls); return static_cast<DeclGroup*>(Mem); @@ -30,5 +28,6 @@ DeclGroup* DeclGroup::Create(ASTContext &C, Decl **Decls, unsigned NumDecls) { DeclGroup::DeclGroup(unsigned numdecls, Decl** decls) : NumDecls(numdecls) { assert(numdecls > 0); assert(decls); - memcpy(this+1, decls, numdecls * sizeof(*decls)); + std::uninitialized_copy(decls, decls + numdecls, + getTrailingObjects<Decl *>()); } |
