1 //===--- DeclGroup.cpp - Classes for representing groups of Decls -*- C++ -*-==//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the DeclGroup and DeclGroupRef classes.
12 //===----------------------------------------------------------------------===//
14 #include "clang/AST/DeclGroup.h"
15 #include "clang/AST/ASTContext.h"
16 #include "clang/AST/Decl.h"
17 using namespace clang;
19 DeclGroup* DeclGroup::Create(ASTContext &C, Decl **Decls, unsigned NumDecls) {
20 assert(NumDecls > 1 && "Invalid DeclGroup");
21 unsigned Size = totalSizeToAlloc<Decl *>(NumDecls);
22 void *Mem = C.Allocate(Size, alignof(DeclGroup));
23 new (Mem) DeclGroup(NumDecls, Decls);
24 return static_cast<DeclGroup*>(Mem);
27 DeclGroup::DeclGroup(unsigned numdecls, Decl** decls) : NumDecls(numdecls) {
30 std::uninitialized_copy(decls, decls + numdecls,
31 getTrailingObjects<Decl *>());