annotate clang/lib/AST/DeclGroup.cpp @ 150:1d019706d866

LLVM10
author anatofuz
date Thu, 13 Feb 2020 15:10:13 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 //===- DeclGroup.cpp - Classes for representing groups of Decls -----------===//
anatofuz
parents:
diff changeset
2 //
anatofuz
parents:
diff changeset
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
anatofuz
parents:
diff changeset
4 // See https://llvm.org/LICENSE.txt for license information.
anatofuz
parents:
diff changeset
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
anatofuz
parents:
diff changeset
6 //
anatofuz
parents:
diff changeset
7 //===----------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
8 //
anatofuz
parents:
diff changeset
9 // This file defines the DeclGroup and DeclGroupRef classes.
anatofuz
parents:
diff changeset
10 //
anatofuz
parents:
diff changeset
11 //===----------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 #include "clang/AST/DeclGroup.h"
anatofuz
parents:
diff changeset
14 #include "clang/AST/ASTContext.h"
anatofuz
parents:
diff changeset
15 #include <cassert>
anatofuz
parents:
diff changeset
16 #include <memory>
anatofuz
parents:
diff changeset
17
anatofuz
parents:
diff changeset
18 using namespace clang;
anatofuz
parents:
diff changeset
19
anatofuz
parents:
diff changeset
20 DeclGroup* DeclGroup::Create(ASTContext &C, Decl **Decls, unsigned NumDecls) {
anatofuz
parents:
diff changeset
21 assert(NumDecls > 1 && "Invalid DeclGroup");
anatofuz
parents:
diff changeset
22 unsigned Size = totalSizeToAlloc<Decl *>(NumDecls);
anatofuz
parents:
diff changeset
23 void *Mem = C.Allocate(Size, alignof(DeclGroup));
anatofuz
parents:
diff changeset
24 new (Mem) DeclGroup(NumDecls, Decls);
anatofuz
parents:
diff changeset
25 return static_cast<DeclGroup*>(Mem);
anatofuz
parents:
diff changeset
26 }
anatofuz
parents:
diff changeset
27
anatofuz
parents:
diff changeset
28 DeclGroup::DeclGroup(unsigned numdecls, Decl** decls) : NumDecls(numdecls) {
anatofuz
parents:
diff changeset
29 assert(numdecls > 0);
anatofuz
parents:
diff changeset
30 assert(decls);
anatofuz
parents:
diff changeset
31 std::uninitialized_copy(decls, decls + numdecls,
anatofuz
parents:
diff changeset
32 getTrailingObjects<Decl *>());
anatofuz
parents:
diff changeset
33 }