clang API Documentation

DeclFriend.cpp
Go to the documentation of this file.
00001 //===--- DeclFriend.cpp - C++ Friend Declaration AST Node Implementation --===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file implements the AST classes related to C++ friend
00011 // declarations.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #include "clang/AST/DeclFriend.h"
00016 #include "clang/AST/DeclTemplate.h"
00017 using namespace clang;
00018 
00019 void FriendDecl::anchor() { }
00020 
00021 FriendDecl *FriendDecl::Create(ASTContext &C, DeclContext *DC,
00022                                SourceLocation L,
00023                                FriendUnion Friend,
00024                                SourceLocation FriendL) {
00025 #ifndef NDEBUG
00026   if (Friend.is<NamedDecl*>()) {
00027     NamedDecl *D = Friend.get<NamedDecl*>();
00028     assert(isa<FunctionDecl>(D) ||
00029            isa<CXXRecordDecl>(D) ||
00030            isa<FunctionTemplateDecl>(D) ||
00031            isa<ClassTemplateDecl>(D));
00032 
00033     // As a temporary hack, we permit template instantiation to point
00034     // to the original declaration when instantiating members.
00035     assert(D->getFriendObjectKind() ||
00036            (cast<CXXRecordDecl>(DC)->getTemplateSpecializationKind()));
00037   }
00038 #endif
00039 
00040   FriendDecl *FD = new (C) FriendDecl(DC, L, Friend, FriendL);
00041   cast<CXXRecordDecl>(DC)->pushFriendDecl(FD);
00042   return FD;
00043 }
00044 
00045 FriendDecl *FriendDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
00046   void *Mem = AllocateDeserializedDecl(C, ID, sizeof(FriendDecl));
00047   return new (Mem) FriendDecl(EmptyShell());
00048 }