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 | bbbbe4eaafec9f46c853c7209145de73a3b7bab3 (patch) | |
| tree | 6272476afe4bfd1dbc3dbeb12488ade75fab3c06 /clang/lib | |
| parent | 4cbe83cccbda81adb9b6e410110b7e6df694b290 (diff) | |
| download | bcm5719-llvm-bbbbe4eaafec9f46c853c7209145de73a3b7bab3.tar.gz bcm5719-llvm-bbbbe4eaafec9f46c853c7209145de73a3b7bab3.zip | |
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.
llvm-svn: 98249
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | clang/lib/AST/DeclBase.cpp | 1 | ||||
| -rw-r--r-- | clang/lib/AST/DeclCXX.cpp | 22 | ||||
| -rw-r--r-- | clang/lib/AST/DeclFriend.cpp | 39 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaCodeComplete.cpp | 3 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaTemplate.cpp | 1 |
6 files changed, 43 insertions, 24 deletions
diff --git a/clang/lib/AST/CMakeLists.txt b/clang/lib/AST/CMakeLists.txt index 2f1a6af77aa..3408a1e3cc7 100644 --- a/clang/lib/AST/CMakeLists.txt +++ b/clang/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/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index a9495343e88..1aac7cfd598 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/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/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp index 7f4ad34fb7f..72b7f49dff0 100644 --- a/clang/lib/AST/DeclCXX.cpp +++ b/clang/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/clang/lib/AST/DeclFriend.cpp b/clang/lib/AST/DeclFriend.cpp new file mode 100644 index 00000000000..8c7cadfbf74 --- /dev/null +++ b/clang/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); +} diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index edf1bc51eb9..4693fa974ed 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -365,8 +365,7 @@ bool ResultBuilder::isInterestingDecl(NamedDecl *ND, // Friend declarations and declarations introduced due to friends are never // added as results. - if (isa<FriendDecl>(ND) || - (IDNS & (Decl::IDNS_OrdinaryFriend | Decl::IDNS_TagFriend))) + if (IDNS & (Decl::IDNS_OrdinaryFriend | Decl::IDNS_TagFriend)) return false; // Class template (partial) specializations are never added as results. diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 7c4cab11836..79298acc229 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -15,6 +15,7 @@ #include "clang/AST/ASTContext.h" #include "clang/AST/Expr.h" #include "clang/AST/ExprCXX.h" +#include "clang/AST/DeclFriend.h" #include "clang/AST/DeclTemplate.h" #include "clang/Parse/DeclSpec.h" #include "clang/Parse/Template.h" |

