diff options
Diffstat (limited to 'clang/lib/AST/DeclGroup.cpp')
| -rw-r--r-- | clang/lib/AST/DeclGroup.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/clang/lib/AST/DeclGroup.cpp b/clang/lib/AST/DeclGroup.cpp new file mode 100644 index 000000000000..27dbdaab6f30 --- /dev/null +++ b/clang/lib/AST/DeclGroup.cpp @@ -0,0 +1,33 @@ +//===- DeclGroup.cpp - Classes for representing groups of Decls -----------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines the DeclGroup and DeclGroupRef classes. +// +//===----------------------------------------------------------------------===// + +#include "clang/AST/DeclGroup.h" +#include "clang/AST/ASTContext.h" +#include <cassert> +#include <memory> + +using namespace clang; + +DeclGroup* DeclGroup::Create(ASTContext &C, Decl **Decls, unsigned NumDecls) { + assert(NumDecls > 1 && "Invalid DeclGroup"); + unsigned Size = totalSizeToAlloc<Decl *>(NumDecls); + void *Mem = C.Allocate(Size, alignof(DeclGroup)); + new (Mem) DeclGroup(NumDecls, Decls); + return static_cast<DeclGroup*>(Mem); +} + +DeclGroup::DeclGroup(unsigned numdecls, Decl** decls) : NumDecls(numdecls) { + assert(numdecls > 0); + assert(decls); + std::uninitialized_copy(decls, decls + numdecls, + getTrailingObjects<Decl *>()); +} |
