diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2011-06-05 23:36:55 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2011-06-05 23:36:55 +0000 |
commit | d50f1690986f0e2f8c95489f8d10a4af192b04a2 (patch) | |
tree | c381bbac8c550aa51e1564e1460085e05dd64834 /clang/lib/Sema/SemaOverload.cpp | |
parent | 998a591e32613d1e6b223999a4b8db47b468878d (diff) | |
download | bcm5719-llvm-d50f1690986f0e2f8c95489f8d10a4af192b04a2.tar.gz bcm5719-llvm-d50f1690986f0e2f8c95489f8d10a4af192b04a2.zip |
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.
llvm-svn: 132673
Diffstat (limited to 'clang/lib/Sema/SemaOverload.cpp')
-rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index ca9152e87e0..dec49357fef 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/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<DeclContext*, 4> 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 |