diff options
author | Kaelyn Uhrain <rikka@google.com> | 2012-06-07 23:57:12 +0000 |
---|---|---|
committer | Kaelyn Uhrain <rikka@google.com> | 2012-06-07 23:57:12 +0000 |
commit | b7fe579968a2fad25d95514f96c6649aae519c81 (patch) | |
tree | 3f782e0b7fbc330b083d192ab54be8e9166f4275 /lib/Sema/SemaDecl.cpp | |
parent | ef094a1ab79c57269b627cb19748384d9a26fb31 (diff) |
Teach the FixIt in DiagnoseInvalidRedeclaration how to replace the written
nested name specifiers in addition to the function's identifier when the
correction has a different nested name specifier.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158178 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 44a2bb5d5a..fdda9014dc 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -4742,15 +4742,19 @@ static NamedDecl* DiagnoseInvalidRedeclaration( } } - if (Correction) - SemaRef.Diag(NewFD->getLocation(), DiagMsg) + if (Correction) { + SourceRange FixItLoc(NewFD->getLocation()); + CXXScopeSpec &SS = ExtraArgs.D.getCXXScopeSpec(); + if (Correction.getCorrectionSpecifier() && SS.isValid()) + FixItLoc.setBegin(SS.getBeginLoc()); + SemaRef.Diag(NewFD->getLocStart(), DiagMsg) << Name << NewDC << Correction.getQuoted(SemaRef.getLangOpts()) << FixItHint::CreateReplacement( - NewFD->getLocation(), - Correction.getAsString(SemaRef.getLangOpts())); - else + FixItLoc, Correction.getAsString(SemaRef.getLangOpts())); + } else { SemaRef.Diag(NewFD->getLocation(), DiagMsg) << Name << NewDC << NewFD->getLocation(); + } bool NewFDisConst = false; if (CXXMethodDecl *NewMD = dyn_cast<CXXMethodDecl>(NewFD)) |