blob: 99bfe40c31f4ab440dd76d69d81eb54bb67cdbdf [file] [log] [blame]
John McCall92b7f702010-03-11 07:50:04 +00001//===--- DeclFriend.cpp - C++ Friend Declaration AST Node Implementation --===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the AST classes related to C++ friend
11// declarations.
12//
13//===----------------------------------------------------------------------===//
14
15#include "clang/AST/DeclFriend.h"
16#include "clang/AST/DeclTemplate.h"
17using namespace clang;
18
19FriendDecl *FriendDecl::Create(ASTContext &C, DeclContext *DC,
20 SourceLocation L,
21 FriendUnion Friend,
22 SourceLocation FriendL) {
23#ifndef NDEBUG
24 if (Friend.is<NamedDecl*>()) {
25 NamedDecl *D = Friend.get<NamedDecl*>();
26 assert(isa<FunctionDecl>(D) ||
27 isa<CXXRecordDecl>(D) ||
28 isa<FunctionTemplateDecl>(D) ||
29 isa<ClassTemplateDecl>(D));
30
31 // As a temporary hack, we permit template instantiation to point
32 // to the original declaration when instantiating members.
33 assert(D->getFriendObjectKind() ||
34 (cast<CXXRecordDecl>(DC)->getTemplateSpecializationKind()));
35 }
36#endif
37
John McCalld60e22e2010-03-12 01:19:31 +000038 FriendDecl *FD = new (C) FriendDecl(DC, L, Friend, FriendL);
39 cast<CXXRecordDecl>(DC)->pushFriendDecl(FD);
40 return FD;
John McCall92b7f702010-03-11 07:50:04 +000041}
Argyrios Kyrtzidis67643342010-06-29 22:47:00 +000042
43FriendDecl *FriendDecl::Create(ASTContext &C, EmptyShell Empty) {
44 return new (C) FriendDecl(Empty);
45}