diff options
author | John McCall <rjmccall@apple.com> | 2009-08-11 06:59:38 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2009-08-11 06:59:38 +0000 |
commit | 3f9a8a60614b763785d54ad08821745d03a4af70 (patch) | |
tree | 4cdd17b3e7e2a8d2f1a65bdc089ea3fa6c95ff24 /include/clang | |
parent | b98b1991c7ad1eaedb863bdbdd784ec164277675 (diff) |
Argument-dependent lookup for friend declarations. Add a new decl type,
FriendFunctionDecl, and create instances as appropriate.
The design of FriendFunctionDecl is still somewhat up in the air; you can
befriend arbitrary types of functions --- methods, constructors, etc. ---
and it's not clear that this representation captures that very well.
We'll have a better picture when we start consuming this data in access
control.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78653 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang')
-rw-r--r-- | include/clang/AST/DeclBase.h | 8 | ||||
-rw-r--r-- | include/clang/AST/DeclCXX.h | 30 | ||||
-rw-r--r-- | include/clang/AST/DeclNodes.def | 1 | ||||
-rw-r--r-- | include/clang/Parse/Action.h | 3 |
4 files changed, 41 insertions, 1 deletions
diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index ea782c9a66..0979733644 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -827,6 +827,14 @@ public: /// semantic context via makeDeclVisibleInContext. void addDecl(Decl *D); + /// @brief Add the declaration D to this context without modifying + /// any lookup tables. + /// + /// This is useful for some operations in dependent contexts where + /// the semantic context might not be dependent; this basically + /// only happens with friends. + void addHiddenDecl(Decl *D); + /// lookup_iterator - An iterator that provides access to the results /// of looking up a name within this context. typedef NamedDecl **lookup_iterator; diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h index 8b601cb810..00e583fa6e 100644 --- a/include/clang/AST/DeclCXX.h +++ b/include/clang/AST/DeclCXX.h @@ -1213,6 +1213,36 @@ public: static bool classof(const CXXConversionDecl *D) { return true; } }; +/// FriendFunctionDecl - Represents the declaration (and possibly +/// the definition) of a friend function. +class FriendFunctionDecl : public FunctionDecl { + // Location of the 'friend' specifier. + const SourceLocation FriendLoc; + + FriendFunctionDecl(DeclContext *DC, SourceLocation L, + DeclarationName N, QualType T, + bool isInline, SourceLocation FriendL) + : FunctionDecl(FriendFunction, DC, L, N, T, None, isInline), + FriendLoc(FriendL) + {} + +public: + static FriendFunctionDecl *Create(ASTContext &C, DeclContext *DC, + SourceLocation L, DeclarationName N, + QualType T, bool isInline, + SourceLocation FriendL); + + SourceLocation getFriendLoc() const { + return FriendLoc; + } + + // Implement isa/cast/dyncast/etc. + static bool classof(const Decl *D) { + return D->getKind() == FriendFunction; + } + static bool classof(const FriendFunctionDecl *D) { return true; } +}; + /// LinkageSpecDecl - This represents a linkage specification. For example: /// extern "C" void foo(); /// diff --git a/include/clang/AST/DeclNodes.def b/include/clang/AST/DeclNodes.def index 9fac06f8fc..8d5c0681d7 100644 --- a/include/clang/AST/DeclNodes.def +++ b/include/clang/AST/DeclNodes.def @@ -92,6 +92,7 @@ ABSTRACT_DECL(Named, Decl) ABSTRACT_DECL(Value, NamedDecl) DECL(EnumConstant, ValueDecl) DECL(Function, ValueDecl) + DECL(FriendFunction, FunctionDecl) DECL(CXXMethod, FunctionDecl) DECL(CXXConstructor, CXXMethodDecl) DECL(CXXDestructor, CXXMethodDecl) diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h index 777f75e5a6..cef378f558 100644 --- a/include/clang/Parse/Action.h +++ b/include/clang/Parse/Action.h @@ -1143,7 +1143,8 @@ public: /// ActOnFriendDecl - This action is called when a friend declaration is /// encountered. virtual DeclPtrTy ActOnFriendDecl(Scope *S, - llvm::PointerUnion<const DeclSpec*,Declarator*> D) { + llvm::PointerUnion<const DeclSpec*,Declarator*> D, + bool IsDefinition) { return DeclPtrTy(); } |