summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaCXXScopeSpec.cpp
diff options
context:
space:
mode:
authorKaelyn Uhrain <rikka@google.com>2013-07-02 23:47:44 +0000
committerKaelyn Uhrain <rikka@google.com>2013-07-02 23:47:44 +0000
commit10413a46a0d8abe7d6a14e99ce582dac0ad069e8 (patch)
tree035345bb35cb1d0e02290c611e2188d0629e3e10 /clang/lib/Sema/SemaCXXScopeSpec.cpp
parentb18b0c0f16c63585f69d72bc0991c1c09c813220 (diff)
downloadbcm5719-llvm-10413a46a0d8abe7d6a14e99ce582dac0ad069e8.tar.gz
bcm5719-llvm-10413a46a0d8abe7d6a14e99ce582dac0ad069e8.zip
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
Diffstat (limited to 'clang/lib/Sema/SemaCXXScopeSpec.cpp')
-rw-r--r--clang/lib/Sema/SemaCXXScopeSpec.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaCXXScopeSpec.cpp b/clang/lib/Sema/SemaCXXScopeSpec.cpp
index de68e2e1e46..9701f7d7519 100644
--- a/clang/lib/Sema/SemaCXXScopeSpec.cpp
+++ b/clang/lib/Sema/SemaCXXScopeSpec.cpp
@@ -496,16 +496,20 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S,
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 << CorrectedQuotedStr << SS.getRange()
+ << 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(Found.getNameLoc(), CorrectedStr);
-
+ << FixItHint::CreateReplacement(Corrected.getCorrectionRange(),
+ CorrectedStr);
+
if (NamedDecl *ND = Corrected.getCorrectionDecl()) {
Diag(ND->getLocation(), diag::note_previous_decl) << CorrectedQuotedStr;
Found.addDecl(ND);
OpenPOWER on IntegriCloud