diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-08-17 00:46:16 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-08-17 00:46:16 +0000 |
commit | f9b1510576b2039ed1a32a3696efac07ed815171 (patch) | |
tree | 68fe203f268acda5e47cba936fcdded72c64aa76 /clang/lib/Sema/SemaCXXScopeSpec.cpp | |
parent | 15a2fccb787b4040b4f5b514b21b6c6337c48306 (diff) | |
download | bcm5719-llvm-f9b1510576b2039ed1a32a3696efac07ed815171.tar.gz bcm5719-llvm-f9b1510576b2039ed1a32a3696efac07ed815171.zip |
Refactor all diagnosing of TypoCorrections through a common function, in
preparation for teaching this function how to diagnose a correction that
includes importing a module.
llvm-svn: 188602
Diffstat (limited to 'clang/lib/Sema/SemaCXXScopeSpec.cpp')
-rw-r--r-- | clang/lib/Sema/SemaCXXScopeSpec.cpp | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/clang/lib/Sema/SemaCXXScopeSpec.cpp b/clang/lib/Sema/SemaCXXScopeSpec.cpp index 9701f7d7519..327d55f0b3f 100644 --- a/clang/lib/Sema/SemaCXXScopeSpec.cpp +++ b/clang/lib/Sema/SemaCXXScopeSpec.cpp @@ -489,31 +489,23 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S, // different kind of error, so look for typos. DeclarationName Name = Found.getLookupName(); NestedNameSpecifierValidatorCCC Validator(*this); - TypoCorrection Corrected; Found.clear(); - if ((Corrected = CorrectTypo(Found.getLookupNameInfo(), - Found.getLookupKind(), S, &SS, Validator, - LookupCtx, EnteringContext))) { - std::string CorrectedStr(Corrected.getAsString(getLangOpts())); - std::string CorrectedQuotedStr(Corrected.getQuoted(getLangOpts())); - bool droppedSpecifier = Corrected.WillReplaceSpecifier() && - Name.getAsString() == CorrectedStr; - if (LookupCtx) - Diag(Found.getNameLoc(), diag::err_no_member_suggest) - << Name << LookupCtx << droppedSpecifier << CorrectedQuotedStr - << SS.getRange() - << FixItHint::CreateReplacement(Corrected.getCorrectionRange(), - CorrectedStr); - else - Diag(Found.getNameLoc(), diag::err_undeclared_var_use_suggest) - << Name << CorrectedQuotedStr - << FixItHint::CreateReplacement(Corrected.getCorrectionRange(), - CorrectedStr); - - if (NamedDecl *ND = Corrected.getCorrectionDecl()) { - Diag(ND->getLocation(), diag::note_previous_decl) << CorrectedQuotedStr; + if (TypoCorrection Corrected = + CorrectTypo(Found.getLookupNameInfo(), Found.getLookupKind(), S, + &SS, Validator, LookupCtx, EnteringContext)) { + if (LookupCtx) { + bool DroppedSpecifier = + Corrected.WillReplaceSpecifier() && + Name.getAsString() == Corrected.getAsString(getLangOpts()); + diagnoseTypo(Corrected, PDiag(diag::err_no_member_suggest) + << Name << LookupCtx << DroppedSpecifier + << SS.getRange()); + } else + diagnoseTypo(Corrected, PDiag(diag::err_undeclared_var_use_suggest) + << Name); + + if (NamedDecl *ND = Corrected.getCorrectionDecl()) Found.addDecl(ND); - } Found.setLookupName(Corrected.getCorrection()); } else { Found.setLookupName(&Identifier); |