[cfe-commits] [PATCH] Fix typo correction of one qualified name to another.
David Blaikie
reviews at llvm-reviews.chandlerc.com
Wed Oct 10 14:23:05 PDT 2012
================
Comment at: lib/Sema/SemaDeclCXX.cpp:5811-5819
@@ -5810,10 +5810,11 @@
std::string CorrectedQuotedStr(Corrected.getQuoted(S.getLangOpts()));
- if (DeclContext *DC = S.computeDeclContext(SS, false))
+ if (DeclContext *DC = S.computeDeclContext(SS, false)) {
S.Diag(IdentLoc, diag::err_using_directive_member_suggest)
<< Ident << DC << CorrectedQuotedStr << SS.getRange()
- << FixItHint::CreateReplacement(IdentLoc, CorrectedStr);
- else
+ << FixItHint::CreateReplacement(Corrected.getCorrectionRange(),
+ CorrectedStr);
+ } else
S.Diag(IdentLoc, diag::err_using_directive_suggest)
<< Ident << CorrectedQuotedStr
<< FixItHint::CreateReplacement(IdentLoc, CorrectedStr);
----------------
Richard Smith wrote:
> Seems a bit jarring to have braces for the 'if' but not for the 'else'.
Ah, the braces on the 'if' must've been a throwback to when I was computing the correct range here rather than in the TypoCorrection. I've removed them.
================
Comment at: lib/Sema/SemaLookup.cpp:4059-4061
@@ -4058,3 +4058,5 @@
- return Result;
+ TypoCorrection TC = Result;
+ TC.setCorrectionRange(SS, TypoName);
+ return TC;
}
----------------
Richard Smith wrote:
> It makes me slightly uncomfortable that we're passing around partially-constructed TypoCorrections until we get here, but OK.
Likewise. As I mentioned in the description the only other ideas I had were:
* pass this extra information down through whatever layers are necessary to reach the places where TypoCorrections are constructed
* introduce a separate TypoCorrection type, one without the range, one with it - build the former from the latter at the return site
* optionally or in addition to the latter option, write a wrapper function around this one so that this code isn't duplicated twice & possibly lost if someone adds a 3rd non-failure return from this function.
I'm open to any/all ideas, this was just a first pass before I went down any of those paths in case anyone had better/other/strong ideas about which option might be worthwhile.
http://llvm-reviews.chandlerc.com/D57
BRANCH
qualified_correction
More information about the cfe-commits
mailing list