From: Chandler Carruth Date: Sun, 5 Jun 2011 23:36:55 +0000 (+0000) Subject: Richard Smith was correct about how the sets should be computed for X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=74d487e085c1555fb694c7ddf58315ae5e1bbecd;p=clang Richard Smith was correct about how the sets should be computed for this. My suggestion assumed a viable erase method for iterators on SmallPtrSet. This patch restores his original pattern. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132673 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index ca9152e87e..dec49357fe 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -7873,29 +7873,26 @@ DiagnoseTwoPhaseLookup(Sema &SemaRef, SourceLocation FnLoc, AssociatedNamespaces, AssociatedClasses); // Never suggest declaring a function within namespace 'std'. + Sema::AssociatedNamespaceSet SuggestedNamespaces; if (DeclContext *Std = SemaRef.getStdNamespace()) { - // Use two passes: SmallPtrSet::erase invalidates too many iterators - // to be used in the loop. - llvm::SmallVector StdNamespaces; for (Sema::AssociatedNamespaceSet::iterator it = AssociatedNamespaces.begin(), - end = AssociatedNamespaces.end(); it != end; ++it) - if (Std->Encloses(*it)) - StdNamespaces.push_back(*it); - for (unsigned I = 0; I != StdNamespaces.size(); ++I) - AssociatedNamespaces.erase(StdNamespaces[I]); + end = AssociatedNamespaces.end(); it != end; ++it) { + if (!Std->Encloses(*it)) + SuggestedNamespaces.insert(*it); + } } SemaRef.Diag(R.getNameLoc(), diag::err_not_found_by_two_phase_lookup) << R.getLookupName(); - if (AssociatedNamespaces.empty()) { + if (SuggestedNamespaces.empty()) { SemaRef.Diag(Best->Function->getLocation(), diag::note_not_found_by_two_phase_lookup) << R.getLookupName() << 0; - } else if (AssociatedNamespaces.size() == 1) { + } else if (SuggestedNamespaces.size() == 1) { SemaRef.Diag(Best->Function->getLocation(), diag::note_not_found_by_two_phase_lookup) - << R.getLookupName() << 1 << *AssociatedNamespaces.begin(); + << R.getLookupName() << 1 << *SuggestedNamespaces.begin(); } else { // FIXME: It would be useful to list the associated namespaces here, // but the diagnostics infrastructure doesn't provide a way to produce