DeclFriend.cpp revision f5b2e4e507e7014d09331fda4e7f0d5682d13660
1//===--- 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 38 FriendDecl *FD = new (C) FriendDecl(DC, L, Friend, FriendL); 39 cast<CXXRecordDecl>(DC)->pushFriendDecl(FD); 40 return FD; 41} 42 43FriendDecl *FriendDecl::Create(ASTContext &C, EmptyShell Empty) { 44 return new (C) FriendDecl(Empty); 45} 46