IEnd = DI->second.end();
I != IEnd; /* Increment in loop. */) {
// If we only want nested name specifier corrections, ignore potential
- // corrections that have a different base identifier from the typo.
- if (AllowOnlyNNSChanges &&
- I->second.front().getCorrectionAsIdentifierInfo() != Typo) {
- TypoCorrectionConsumer::result_iterator Prev = I;
- ++I;
- DI->second.erase(Prev);
- continue;
+ // corrections that have a different base identifier from the typo or
+ // which have a normalized edit distance longer than the typo itself.
+ if (AllowOnlyNNSChanges) {
+ TypoCorrection &TC = I->second.front();
+ if (TC.getCorrectionAsIdentifierInfo() != Typo ||
+ TC.getEditDistance(true) > TypoLen) {
+ TypoCorrectionConsumer::result_iterator Prev = I;
+ ++I;
+ DI->second.erase(Prev);
+ continue;
+ }
}
// If the item already has been looked up or is a keyword, keep it.
// RUN: %clang_cc1 -fsyntax-only -verify %s
namespace A {
namespace B {
- class C { }; // expected-note 2 {{'A::B::C' declared here}}
+ class C { }; // expected-note {{'A::B::C' declared here}}
struct S { };
union U { };
}
}
void g() {
- A::B::D::E; // expected-error {{no member named 'D' in namespace 'A::B'}}
+ A::B::D::E; // expected-error-re {{no member named 'D' in namespace 'A::B'{{$}}}}
// FIXME: The typo corrections below should be suppressed since A::B::C
// doesn't have a member named D.
B::B::C::D; // expected-error {{no member named 'C' in 'B::B'; did you mean 'A::B::C'?}} \
- // expected-error {{no member named 'D' in 'A::B::C'}}
- ::C::D; // expected-error {{no member named 'C' in the global namespace; did you mean 'A::B::C'?}}\
- // expected-error {{no member named 'D' in 'A::B::C'}}
+ // expected-error-re {{no member named 'D' in 'A::B::C'{{$}}}}
+ ::C::D; // expected-error-re {{no member named 'C' in the global namespace{{$}}}}
}
int A::B::i = 10; // expected-error {{no member named 'i' in namespace 'A::B'}}
bar(); // expected-error-re {{use of undeclared identifier 'bar'{{$}}}}
}
}
+
+namespace std {
+class bernoulli_distribution {
+ public:
+ double p() const;
+};
+}
+void test() {
+ // Make sure that typo correction doesn't suggest changing 'p' to
+ // 'std::bernoulli_distribution::p' as that is most likely wrong.
+ if (p) // expected-error-re {{use of undeclared identifier 'p'{{$}}}}
+ return;
+}