diff options
Diffstat (limited to 'lib/AST')
-rw-r--r-- | lib/AST/CMakeLists.txt | 1 | ||||
-rw-r--r-- | lib/AST/DeclBase.cpp | 1 | ||||
-rw-r--r-- | lib/AST/DeclCXX.cpp | 22 | ||||
-rw-r--r-- | lib/AST/DeclFriend.cpp | 39 |
4 files changed, 41 insertions, 22 deletions
diff --git a/lib/AST/CMakeLists.txt b/lib/AST/CMakeLists.txt index 2f1a6af77a..3408a1e3cc 100644 --- a/lib/AST/CMakeLists.txt +++ b/lib/AST/CMakeLists.txt @@ -11,6 +11,7 @@ add_clang_library(clangAST Decl.cpp DeclBase.cpp DeclCXX.cpp + DeclFriend.cpp DeclGroup.cpp DeclObjC.cpp DeclPrinter.cpp diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index a9495343e8..1aac7cfd59 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -15,6 +15,7 @@ #include "clang/AST/Decl.h" #include "clang/AST/DeclContextInternals.h" #include "clang/AST/DeclCXX.h" +#include "clang/AST/DeclFriend.h" #include "clang/AST/DeclObjC.h" #include "clang/AST/DeclTemplate.h" #include "clang/AST/ExternalASTSource.h" diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp index 7f4ad34fb7..72b7f49dff 100644 --- a/lib/AST/DeclCXX.cpp +++ b/lib/AST/DeclCXX.cpp @@ -846,28 +846,6 @@ CXXConversionDecl::Create(ASTContext &C, CXXRecordDecl *RD, return new (C) CXXConversionDecl(RD, L, N, T, TInfo, isInline, isExplicit); } -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); -} - LinkageSpecDecl *LinkageSpecDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, 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); +} |