1 //===--- DeclFriend.cpp - C++ Friend Declaration AST Node Implementation --===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the AST classes related to C++ friend
13 //===----------------------------------------------------------------------===//
15 #include "clang/AST/DeclFriend.h"
16 #include "clang/AST/DeclTemplate.h"
17 using namespace clang;
19 FriendDecl *FriendDecl::Create(ASTContext &C, DeclContext *DC,
22 SourceLocation FriendL) {
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));
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()));
38 FriendDecl *FD = new (C) FriendDecl(DC, L, Friend, FriendL);
39 cast<CXXRecordDecl>(DC)->pushFriendDecl(FD);
43 FriendDecl *FriendDecl::Create(ASTContext &C, EmptyShell Empty) {
44 return new (C) FriendDecl(Empty);