2008-09-25 21:13:40 +04:00
|
|
|
//===--- DeclGroup.cpp - Classes for representing groups of Decls -*- C++ -*-==//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2009-02-13 22:06:18 +03:00
|
|
|
// This file defines the DeclGroup and DeclGroupRef classes.
|
2008-09-25 21:13:40 +04:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "clang/AST/DeclGroup.h"
|
|
|
|
#include "clang/AST/Decl.h"
|
|
|
|
#include "clang/AST/ASTContext.h"
|
|
|
|
#include "llvm/Support/Allocator.h"
|
|
|
|
using namespace clang;
|
|
|
|
|
2009-03-29 20:50:03 +04:00
|
|
|
DeclGroup* DeclGroup::Create(ASTContext &C, Decl **Decls, unsigned NumDecls) {
|
|
|
|
assert(NumDecls > 1 && "Invalid DeclGroup");
|
|
|
|
unsigned Size = sizeof(DeclGroup) + sizeof(Decl*) * NumDecls;
|
|
|
|
void* Mem = C.Allocate(Size, llvm::AlignOf<DeclGroup>::Alignment);
|
|
|
|
new (Mem) DeclGroup(NumDecls, Decls);
|
|
|
|
return static_cast<DeclGroup*>(Mem);
|
2008-09-25 21:13:40 +04:00
|
|
|
}
|
|
|
|
|
2008-10-08 03:06:01 +04:00
|
|
|
DeclGroup::DeclGroup(unsigned numdecls, Decl** decls) : NumDecls(numdecls) {
|
2009-03-28 09:26:18 +03:00
|
|
|
assert(numdecls > 0);
|
|
|
|
assert(decls);
|
2008-09-25 21:13:40 +04:00
|
|
|
memcpy(this+1, decls, numdecls * sizeof(*decls));
|
|
|
|
}
|