2017-11-10 08:59:22 +08:00
|
|
|
//===- DeclGroup.cpp - Classes for representing groups of Decls -----------===//
|
2008-09-26 01:13:40 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2009-02-14 03:06:18 +08:00
|
|
|
// This file defines the DeclGroup and DeclGroupRef classes.
|
2008-09-26 01:13:40 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "clang/AST/DeclGroup.h"
|
|
|
|
#include "clang/AST/ASTContext.h"
|
2017-11-10 08:59:22 +08:00
|
|
|
#include <cassert>
|
|
|
|
#include <memory>
|
|
|
|
|
2008-09-26 01:13:40 +08:00
|
|
|
using namespace clang;
|
|
|
|
|
2009-03-30 00:50:03 +08:00
|
|
|
DeclGroup* DeclGroup::Create(ASTContext &C, Decl **Decls, unsigned NumDecls) {
|
|
|
|
assert(NumDecls > 1 && "Invalid DeclGroup");
|
2015-12-30 06:13:13 +08:00
|
|
|
unsigned Size = totalSizeToAlloc<Decl *>(NumDecls);
|
2016-10-20 22:27:22 +08:00
|
|
|
void *Mem = C.Allocate(Size, alignof(DeclGroup));
|
2009-03-30 00:50:03 +08:00
|
|
|
new (Mem) DeclGroup(NumDecls, Decls);
|
|
|
|
return static_cast<DeclGroup*>(Mem);
|
2008-09-26 01:13:40 +08:00
|
|
|
}
|
|
|
|
|
2008-10-08 07:06:01 +08:00
|
|
|
DeclGroup::DeclGroup(unsigned numdecls, Decl** decls) : NumDecls(numdecls) {
|
2009-03-28 14:26:18 +08:00
|
|
|
assert(numdecls > 0);
|
|
|
|
assert(decls);
|
2015-12-30 06:13:13 +08:00
|
|
|
std::uninitialized_copy(decls, decls + numdecls,
|
|
|
|
getTrailingObjects<Decl *>());
|
2008-09-26 01:13:40 +08:00
|
|
|
}
|