clang API Documentation
00001 //===--- DeclGroup.cpp - Classes for representing groups of Decls -*- C++ -*-==// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines the DeclGroup and DeclGroupRef classes. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #include "clang/AST/DeclGroup.h" 00015 #include "clang/AST/ASTContext.h" 00016 #include "clang/AST/Decl.h" 00017 #include "llvm/Support/Allocator.h" 00018 using namespace clang; 00019 00020 DeclGroup* DeclGroup::Create(ASTContext &C, Decl **Decls, unsigned NumDecls) { 00021 assert(NumDecls > 1 && "Invalid DeclGroup"); 00022 unsigned Size = sizeof(DeclGroup) + sizeof(Decl*) * NumDecls; 00023 void* Mem = C.Allocate(Size, llvm::AlignOf<DeclGroup>::Alignment); 00024 new (Mem) DeclGroup(NumDecls, Decls); 00025 return static_cast<DeclGroup*>(Mem); 00026 } 00027 00028 DeclGroup::DeclGroup(unsigned numdecls, Decl** decls) : NumDecls(numdecls) { 00029 assert(numdecls > 0); 00030 assert(decls); 00031 memcpy(this+1, decls, numdecls * sizeof(*decls)); 00032 }