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 | a21719d6888c2963bd2395693072b1573cf35c18 (patch) | |
tree | d478ebacce61aace39fddd93a674523c6e78e425 /clang/lib/Sema/SemaOverload.cpp | |
parent | c25d3fe71e8e93dc956b3562785625e7746763f7 (diff) | |
download | bcm5719-llvm-a21719d6888c2963bd2395693072b1573cf35c18.tar.gz bcm5719-llvm-a21719d6888c2963bd2395693072b1573cf35c18.zip |
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.
llvm-svn: 167786
Diffstat (limited to 'clang/lib/Sema/SemaOverload.cpp')
-rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index e5a3deebc2f..47c433192c3 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/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) |