diff options
author | John McCall <rjmccall@apple.com> | 2010-03-11 07:50:04 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-03-11 07:50:04 +0000 |
commit | 92b7f70c924cbf4514e9e434cea7def51ab49860 (patch) | |
tree | 496b6a96374466d7013ed90abcf2e85e5d6c6a63 /lib/AST/DeclFriend.cpp | |
parent | bba16079eed1f3c8cd141685ecfaec9e78e07e35 (diff) |
Split C++ friend declarations into their own header/implementation file.
I'm expecting this portion of the AST to grow and change, and I'd like to
be able to do that with minimal recompilation. If this proves unnecessary
when access control is fully-implemented, I'll fold the classes back into
DeclCXX.h.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98249 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclFriend.cpp')
-rw-r--r-- | lib/AST/DeclFriend.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/AST/DeclFriend.cpp b/lib/AST/DeclFriend.cpp new file mode 100644 index 0000000000..8c7cadfbf7 --- /dev/null +++ b/lib/AST/DeclFriend.cpp @@ -0,0 +1,39 @@ +//===--- DeclFriend.cpp - C++ Friend Declaration AST Node Implementation --===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements the AST classes related to C++ friend +// declarations. +// +//===----------------------------------------------------------------------===// + +#include "clang/AST/DeclFriend.h" +#include "clang/AST/DeclTemplate.h" +using namespace clang; + +FriendDecl *FriendDecl::Create(ASTContext &C, DeclContext *DC, + SourceLocation L, + FriendUnion Friend, + SourceLocation FriendL) { +#ifndef NDEBUG + if (Friend.is<NamedDecl*>()) { + NamedDecl *D = Friend.get<NamedDecl*>(); + assert(isa<FunctionDecl>(D) || + isa<CXXRecordDecl>(D) || + isa<FunctionTemplateDecl>(D) || + isa<ClassTemplateDecl>(D)); + + // As a temporary hack, we permit template instantiation to point + // to the original declaration when instantiating members. + assert(D->getFriendObjectKind() || + (cast<CXXRecordDecl>(DC)->getTemplateSpecializationKind())); + } +#endif + + return new (C) FriendDecl(DC, L, Friend, FriendL); +} |