diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-09-10 16:57:35 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-09-10 16:57:35 +0000 |
commit | e942bbe02b6fb332d1f13d38c6e1980b416cf89a (patch) | |
tree | e1dacc15d51066da2e7d6de19f6d41ddd135fd9a /lib/AST/DeclBase.cpp | |
parent | 736d8a66062eeb25a4b63dcac36d1d4c261a02c4 (diff) |
When performing unqualified name lookup into a DeclContext, also look into
all of the parent DeclContexts that aren't represented within the
Scope chain. This fixes some name-lookup problems in out-of-line
definitions of members of nested classes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81451 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclBase.cpp')
-rw-r--r-- | lib/AST/DeclBase.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index 34bc2b97e3..8d16139fcd 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -420,6 +420,22 @@ void DeclContext::DestroyDecls(ASTContext &C) { (*D++)->Destroy(C); } +/// \brief Find the parent context of this context that will be +/// used for unqualified name lookup. +/// +/// Generally, the parent lookup context is the semantic context. However, for +/// a friend function the parent lookup context is the lexical context, which +/// is the class in which the friend is declared. +DeclContext *DeclContext::getLookupParent() { + // FIXME: Find a better way to identify friends + if (isa<FunctionDecl>(this)) + if (getParent()->getLookupContext()->isFileContext() && + getLexicalParent()->getLookupContext()->isRecord()) + return getLexicalParent(); + + return getParent(); +} + bool DeclContext::isDependentContext() const { if (isFileContext()) return false; |