Path: blob/main/contrib/llvm-project/clang/lib/AST/DeclGroup.cpp
35260 views
//===- DeclGroup.cpp - Classes for representing groups of Decls -----------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file defines the DeclGroup and DeclGroupRef classes.9//10//===----------------------------------------------------------------------===//1112#include "clang/AST/DeclGroup.h"13#include "clang/AST/ASTContext.h"14#include <cassert>15#include <memory>1617using namespace clang;1819DeclGroup* DeclGroup::Create(ASTContext &C, Decl **Decls, unsigned NumDecls) {20assert(NumDecls > 1 && "Invalid DeclGroup");21unsigned Size = totalSizeToAlloc<Decl *>(NumDecls);22void *Mem = C.Allocate(Size, alignof(DeclGroup));23new (Mem) DeclGroup(NumDecls, Decls);24return static_cast<DeclGroup*>(Mem);25}2627DeclGroup::DeclGroup(unsigned numdecls, Decl** decls) : NumDecls(numdecls) {28assert(numdecls > 0);29assert(decls);30std::uninitialized_copy(decls, decls + numdecls,31getTrailingObjects<Decl *>());32}333435