diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2012-11-13 00:08:34 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2012-11-13 00:08:34 +0000 |
commit | d05df512cd6dfa32a696bcdd3dced825efe94bc4 (patch) | |
tree | e8adef3c49a5f079a29913f4649c02632bf0cfd4 /lib/Sema/SemaOverload.cpp | |
parent | 51ceb7bab599ea7d39d290ff5e88e4a1f0f5bc5c (diff) |
When filtering the list of associated namespaces so that we don't suggest people
add functions to namespace 'std', also filter out namespaces with '__' anywhere
in the name.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167786 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaOverload.cpp')
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index e5a3deebc2..47c433192c 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -9536,18 +9536,16 @@ DiagnoseTwoPhaseLookup(Sema &SemaRef, SourceLocation FnLoc, SemaRef.FindAssociatedClassesAndNamespaces(FnLoc, Args, AssociatedNamespaces, AssociatedClasses); - // Never suggest declaring a function within namespace 'std'. + // Never suggest declaring a function within namespace 'std'. Sema::AssociatedNamespaceSet SuggestedNamespaces; - if (DeclContext *Std = SemaRef.getStdNamespace()) { - for (Sema::AssociatedNamespaceSet::iterator - it = AssociatedNamespaces.begin(), - end = AssociatedNamespaces.end(); it != end; ++it) { - if (!Std->Encloses(*it)) - SuggestedNamespaces.insert(*it); - } - } else { - // Lacking the 'std::' namespace, use all of the associated namespaces. - SuggestedNamespaces = AssociatedNamespaces; + DeclContext *Std = SemaRef.getStdNamespace(); + for (Sema::AssociatedNamespaceSet::iterator + it = AssociatedNamespaces.begin(), + end = AssociatedNamespaces.end(); it != end; ++it) { + NamespaceDecl *Assoc = cast<NamespaceDecl>(*it); + if ((!Std || !Std->Encloses(Assoc)) && + Assoc->getQualifiedNameAsString().find("__") == std::string::npos) + SuggestedNamespaces.insert(Assoc); } SemaRef.Diag(R.getNameLoc(), diag::err_not_found_by_two_phase_lookup) |