summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaLookup.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2009-08-28 07:59:38 +0000
committerJohn McCall <rjmccall@apple.com>2009-08-28 07:59:38 +0000
commitaa74a0c3b5a93777115ae07515a56020c78fabc7 (patch)
tree3102a3e4aeb178875cc67fcd49a135b9c18ffde0 /clang/lib/Sema/SemaLookup.cpp
parent2a2459a291babcf4ec810229b0b62da2706fe02c (diff)
downloadbcm5719-llvm-aa74a0c3b5a93777115ae07515a56020c78fabc7.tar.gz
bcm5719-llvm-aa74a0c3b5a93777115ae07515a56020c78fabc7.zip
Omnibus friend decl refactoring. Instead of cloning AST classes for friend
declarations of same, introduce a single AST class and add appropriate bits (encoded in the namespace) for whether a decl is "real" or not. Much hackery about previously-declared / not-previously-declared, but it's essentially mandated by the standard that friends alter lookup, and this is at least fairly non-intrusive. Refactor the Sema methods specific to friends for cleaner flow and less nesting. Incidentally solve a few bugs, but I remain confident that we can put them back. llvm-svn: 80353
Diffstat (limited to 'clang/lib/Sema/SemaLookup.cpp')
-rw-r--r--clang/lib/Sema/SemaLookup.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index 6627499d12d..4a699de6c8d 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -643,6 +643,13 @@ Sema::CppLookupName(Scope *S, DeclarationName Name,
"Can perform only C++ lookup");
unsigned IDNS
= getIdentifierNamespacesFromLookupNameKind(NameKind, /*CPlusPlus*/ true);
+
+ // If we're testing for redeclarations, also look in the friend namespaces.
+ if (RedeclarationOnly) {
+ if (IDNS & Decl::IDNS_Tag) IDNS |= Decl::IDNS_TagFriend;
+ if (IDNS & Decl::IDNS_Ordinary) IDNS |= Decl::IDNS_OrdinaryFriend;
+ }
+
Scope *Initial = S;
DeclContext *OutOfLineCtx = 0;
IdentifierResolver::iterator
@@ -1769,9 +1776,9 @@ void Sema::ArgumentDependentLookup(DeclarationName Name,
DeclContext::lookup_iterator I, E;
for (llvm::tie(I, E) = (*NS)->lookup(Name); I != E; ++I) {
Decl *D = *I;
- // Only count friend declarations which were declared in
- // associated classes.
- if (D->isInIdentifierNamespace(Decl::IDNS_Friend)) {
+ // If the only declaration here is an ordinary friend, consider
+ // it only if it was declared in an associated classes.
+ if (D->getIdentifierNamespace() == Decl::IDNS_OrdinaryFriend) {
DeclContext *LexDC = D->getLexicalDeclContext();
if (!AssociatedClasses.count(cast<CXXRecordDecl>(LexDC)))
continue;
OpenPOWER on IntegriCloud