]> granicus.if.org Git - clang/commit
Fix a case where delayed typo correction should have resolved an
authorKaelyn Takata <rikka@google.com>
Fri, 16 Jan 2015 22:11:04 +0000 (22:11 +0000)
committerKaelyn Takata <rikka@google.com>
Fri, 16 Jan 2015 22:11:04 +0000 (22:11 +0000)
commit1b578c21b8068771e63b3fbe331f6e42e9b9d628
treef1a2b087a6ce31dad663ce9340961c19b5b8af6e
parenta77e006fa0a5c215e4b48a21e70dd323d165a5b4
Fix a case where delayed typo correction should have resolved an
ambiguity but wasn't.

In the new test case, "click" wasn't being corrected properly because
Sema::ClassifyName would call CorrectTypo for "click" then later
Sema::DiagnoseEmptyLookup would call CorrectTypoDelayed for the same use
of "click" (the former by the parser needing to determine what the
identifier is so it knows how to parse the statement, i.e. is it the
beginning of a declaration or an expression). CorrectTypo would record
that typo correction for "click" failed and CorrectTypoDelayed would see
that and not even try to correct the typo, even though in this case
CorrectTypo failed due to an ambiguity (both "Click" and "clock" having
an edit distance of one from "click") that could be resolved with more
information. The fix is two-fold:
  1) Have CorrectTypo not record failed corrections if the reason for
     the failure was two or more corrections with the same edit
     distance, and
  2) Make the CorrectionCandidateCallback used by
     Parser::ParseCastExpression reject FunctionDecl candidates when the
     next token after the identifier is a ".", "=", or "->" since
     functions cannot be assigned to and do not have members that can be
     referenced.

The reason for two correction spots is that from r222549 until r224375
landed, the first correction attempt would fail completely but the
second would suggest "clock" while having the note point to the
declaration of "Click".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226334 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Parse/ParseExpr.cpp
lib/Sema/SemaLookup.cpp
test/SemaCXX/typo-correction-delayed.cpp