aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2011-06-05 23:36:55 +0000
committerChandler Carruth <chandlerc@gmail.com>2011-06-05 23:36:55 +0000
commit74d487e085c1555fb694c7ddf58315ae5e1bbecd (patch)
tree612934482c21a8d4d820669757fc86f47ee8b6b3
parentf50e88a793dd5bc7073c717fec78912e3234e95a (diff)
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
-rw-r--r--lib/Sema/SemaOverload.cpp19
1 files changed, 8 insertions, 11 deletions
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<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