diff options
author | Kaelyn Takata <rikka@google.com> | 2015-01-16 22:11:04 +0000 |
---|---|---|
committer | Kaelyn Takata <rikka@google.com> | 2015-01-16 22:11:04 +0000 |
commit | ae9e97c9d6aeeacc07b48a15b49852d1681a2fc1 (patch) | |
tree | 27dfef9643c4906b16ae55441f3d2508c38335d2 /clang/lib/Sema/SemaLookup.cpp | |
parent | 76723d733bdac9e9f68a0a0b4388d470bfd5e3a0 (diff) | |
download | bcm5719-llvm-ae9e97c9d6aeeacc07b48a15b49852d1681a2fc1.tar.gz bcm5719-llvm-ae9e97c9d6aeeacc07b48a15b49852d1681a2fc1.zip |
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".
llvm-svn: 226334
Diffstat (limited to 'clang/lib/Sema/SemaLookup.cpp')
-rw-r--r-- | clang/lib/Sema/SemaLookup.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 3445264461f..c4fe0589c4b 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -4284,7 +4284,7 @@ TypoCorrection Sema::CorrectTypo(const DeclarationNameInfo &TypoName, // Record the failure's location if needed and return an empty correction. If // this was an unqualified lookup and we believe the callback object did not // filter out possible corrections, also cache the failure for the typo. - return FailedCorrection(Typo, TypoName.getLoc(), RecordFailure); + return FailedCorrection(Typo, TypoName.getLoc(), RecordFailure && !SecondBestTC); } /// \brief Try to "correct" a typo in the source code by finding @@ -4337,9 +4337,7 @@ TypoExpr *Sema::CorrectTypoDelayed( TypoCorrection Empty; auto Consumer = makeTypoCorrectionConsumer( TypoName, LookupKind, S, SS, std::move(CCC), MemberContext, - EnteringContext, OPT, - /*SearchModules=*/(Mode == CTK_ErrorRecovery) && getLangOpts().Modules && - getLangOpts().ModulesSearchAll); + EnteringContext, OPT, Mode == CTK_ErrorRecovery); if (!Consumer || Consumer->empty()) return nullptr; |