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 | d1e9d835f30a4505c280504bad9f59d68cbd7a50 (patch) | |
tree | b7b4a0abc67d79844bd531dde8844b7040d7949a /clang/lib/Sema/SemaLookup.cpp | |
parent | 4d4a2e09a94968ba45dfeb6c294e7b339b81427f (diff) | |
download | bcm5719-llvm-d1e9d835f30a4505c280504bad9f59d68cbd7a50.tar.gz bcm5719-llvm-d1e9d835f30a4505c280504bad9f59d68cbd7a50.zip |
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.
llvm-svn: 78653
Diffstat (limited to 'clang/lib/Sema/SemaLookup.cpp')
-rw-r--r-- | clang/lib/Sema/SemaLookup.cpp | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index ef105374fac..c600f99a404 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -1756,28 +1756,17 @@ void Sema::ArgumentDependentLookup(DeclarationName Name, // associated classes are visible within their respective // namespaces even if they are not visible during an ordinary // lookup (11.4). - // - // We implement the second clause in the loop below. - DeclContext::lookup_iterator I, E; - for (llvm::tie(I, E) = (*NS)->lookup(Name); I != E; ++I) - CollectFunctionDecl(Functions, *I); - } - - // Look for friend function declarations in associated classes - // which name functions in associated namespaces. - for (AssociatedClassSet::iterator AC = AssociatedClasses.begin(), - ACEnd = AssociatedClasses.end(); - AC != ACEnd; ++AC) { DeclContext::lookup_iterator I, E; - for (llvm::tie(I, E) = (*AC)->lookup(Name); I != E; ++I) { + for (llvm::tie(I, E) = (*NS)->lookup(Name); I != E; ++I) { Decl *D = *I; - if (!D->isInIdentifierNamespace(Decl::IDNS_Friend)) - continue; - - DeclContext *DC = D->getDeclContext(); - if (!AssociatedNamespaces.count(DC)) - continue; - + // Only count friend declarations which were declared in + // associated classes. + if (D->isInIdentifierNamespace(Decl::IDNS_Friend)) { + DeclContext *LexDC = D->getLexicalDeclContext(); + if (!AssociatedClasses.count(cast<CXXRecordDecl>(LexDC))) + continue; + } + CollectFunctionDecl(Functions, D); } } |