1 //===- DeclGroup.cpp - Classes for representing groups of Decls -----------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file defines the DeclGroup and DeclGroupRef classes.
11 //===----------------------------------------------------------------------===//
13 #include "clang/AST/DeclGroup.h"
14 #include "clang/AST/ASTContext.h"
18 using namespace clang
;
20 DeclGroup
* DeclGroup::Create(ASTContext
&C
, Decl
**Decls
, unsigned NumDecls
) {
21 assert(NumDecls
> 1 && "Invalid DeclGroup");
22 unsigned Size
= totalSizeToAlloc
<Decl
*>(NumDecls
);
23 void *Mem
= C
.Allocate(Size
, alignof(DeclGroup
));
24 new (Mem
) DeclGroup(NumDecls
, Decls
);
25 return static_cast<DeclGroup
*>(Mem
);
28 DeclGroup::DeclGroup(unsigned numdecls
, Decl
** decls
) : NumDecls(numdecls
) {
31 std::uninitialized_copy(decls
, decls
+ numdecls
,
32 getTrailingObjects
<Decl
*>());