From 10413a46a0d8abe7d6a14e99ce582dac0ad069e8 Mon Sep 17 00:00:00 2001 From: Kaelyn Uhrain Date: Tue, 2 Jul 2013 23:47:44 +0000 Subject: Allow typo correction to try removing nested name specifiers. The removal is tried by retrying the failed lookup of a correction candidate with either the MemberContext or SS (CXXScopeSpecifier) or both set to NULL if they weren't already. If the candidate identifier is then looked up successfully, make a note in the candidate that the SourceRange should include any existing nested name specifier even if the candidate isn't adding a different one (i.e. the candidate has a NULL NestedNameSpecifier). Also tweak the diagnostic messages to differentiate between a suggestion that just replaces the identifer but leaves the existing nested name specifier intact and one that replaces the entire qualified identifier, in cases where the suggested replacement is unqualified. llvm-svn: 185487 --- clang/lib/Sema/SemaExprMember.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'clang/lib/Sema/SemaExprMember.cpp') diff --git a/clang/lib/Sema/SemaExprMember.cpp b/clang/lib/Sema/SemaExprMember.cpp index 73ca265fb2d..7151fc55041 100644 --- a/clang/lib/Sema/SemaExprMember.cpp +++ b/clang/lib/Sema/SemaExprMember.cpp @@ -610,6 +610,8 @@ LookupMemberExprInRecord(Sema &SemaRef, LookupResult &R, Corrected.getAsString(SemaRef.getLangOpts())); std::string CorrectedQuotedStr( Corrected.getQuoted(SemaRef.getLangOpts())); + bool droppedSpecifier = + Corrected.WillReplaceSpecifier() && Name.getAsString() == CorrectedStr; R.setLookupName(Corrected.getCorrection()); for (TypoCorrection::decl_iterator DI = Corrected.begin(), @@ -620,7 +622,7 @@ LookupMemberExprInRecord(Sema &SemaRef, LookupResult &R, R.resolveKind(); SemaRef.Diag(R.getNameLoc(), diag::err_no_member_suggest) - << Name << DC << CorrectedQuotedStr << SS.getRange() + << Name << DC << droppedSpecifier << CorrectedQuotedStr << SS.getRange() << FixItHint::CreateReplacement(Corrected.getCorrectionRange(), CorrectedStr); -- cgit v1.2.3