summaryrefslogtreecommitdiff
path: root/test/SemaCXX/typo-correction-pt2.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Add a new flag, -fspell-checking-limit=<number> to control how many times ↵Nick Lewycky2014-12-161-358/+0
| | | | | | | | | we'll do spell checking. Note that spell checking will change the produced AST, so we don't automatically change this value when someone sets -ferror-limit=. With this, merge test typo-correction-pt2.cpp into typo-correction.cpp. Remove Sema::UnqualifiedTyposCorrected, a cache of corrected typos. It would only cache typo corrections that didn't provide ValidateCandidate of which there were few left, and it had a bug when we had the same identifier spelled wrong twice. See the last two tests in typo-correction.cpp for cases this fires. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224375 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix two small bugs in typo correction. One assertion failure building member ↵Nick Lewycky2014-12-131-0/+24
| | | | | | | | | expressions because the lookup finds a different name than the original, fixed by updating the LookupResult's name with the name of the found decl. Second is that we also diagnose delayed typo exprs in the index of an array subscript expression. The testcase shows a third bug with a FIXME in it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224183 91177308-0d34-0410-b5e6-96231b3b80d8
* Filter out non-static class members when correcting non-member-references.Kaelyn Takata2014-11-051-0/+13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221319 91177308-0d34-0410-b5e6-96231b3b80d8
* Wire up LookupMemberExpr to use the new TypoExpr.Kaelyn Takata2014-10-271-1/+1
| | | | | | | | This includes adding the new TypoExpr-based lazy typo correction to LookupMemberExprInRecord as an alternative to the existing eager typo correction. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220698 91177308-0d34-0410-b5e6-96231b3b80d8
* Be smarter when parsing variable declarations with unknown types.Kaelyn Takata2014-10-141-0/+10
| | | | | | | | | Specifically, avoid typo-correcting the variable name into a type before typo-correcting the actual type name in the declaration. Doing so results in a very unpleasant cascade of errors, with the typo correction of the actual type name being buried in the middle. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@219732 91177308-0d34-0410-b5e6-96231b3b80d8
* Add another keyword-selection flag to CorrectionCandidateCallback.Kaelyn Takata2014-07-281-0/+9
| | | | | | | | | | The new flag, WantFunctionLikeCasts, covers a subset of the keywords covered by WantTypeSpecifiers that can be used in casts that look like function calls, e.g. "return long(5);", while excluding the keywords like "enum" and "const" that would be included when WantTypeSpecifiers is true but cannot be used in something that looks like a function call. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214109 91177308-0d34-0410-b5e6-96231b3b80d8
* Propagate isAddressOfMember into typo correction so that we don't correct ↵Nick Lewycky2014-06-231-0/+13
| | | | | | &qualified-id into &unqualified-id. Also make sure to set the naming class when we find the qualified-id in a different class than the nested name specifier specified so far. Fixes PR19681! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211551 91177308-0d34-0410-b5e6-96231b3b80d8
* Move TypoCorrection filtering into the TypoCorrectionConsumer and make it ↵Kaelyn Takata2014-06-111-0/+9
| | | | | | | | | | | | incremental. The only external/visible functional change that fell out of this refactoring is that there was one less case where the typo caching and/or counting didn't work properly. The result is that a test case had to be moved from typo-correction.cpp to typo-correction-pt2.cpp to avoid the hard-coded limit on per file/TU typo correction attempts. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210669 91177308-0d34-0410-b5e6-96231b3b80d8
* Try harder about not suggesting methods as corrections when theyKaelyn Takata2014-04-041-0/+22
| | | | | | | | obviously won't work. Specifically, don't suggest methods (static or not) from unrelated classes when the expression is a method call through a specific object. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@205653 91177308-0d34-0410-b5e6-96231b3b80d8
* Be a bit smarter about what nested name qualifiers to allow whenKaelyn Uhrain2014-03-211-0/+13
| | | | | | performing typo correction on very short (1 or 2 char) identifiers. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204525 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't suggest non-static methods as corrections when they obviouslyKaelyn Uhrain2014-02-281-0/+9
| | | | | | | won't work (i.e. when not doing a member lookup and not in a method from the same class or a descendant class). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202520 91177308-0d34-0410-b5e6-96231b3b80d8
* Enable correcting a member declaration where the type is class template,Kaelyn Uhrain2014-02-131-0/+11
| | | | | | | | | and the class name is shadowed by another member. Recovery still needs to be figured out, which is non-trivial since the parser has already gone down a much different path than if it had recognized the class template as type instead of seeing the member that shadowed the class template. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201360 91177308-0d34-0410-b5e6-96231b3b80d8
* PR18685: Ignore class template specializations as potentialKaelyn Uhrain2014-02-091-0/+16
| | | | | | | nested-name-specifiers for typos unless the typo already has a nested-name-specifier that is a template specialization. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201056 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't consider records with a NULL identifier as a name for typo correction.Kaelyn Uhrain2014-02-051-0/+8
| | | | | | | | | Because in C++, "anonymous" doesn't mean "nameless" for records. In other words, RecordDecl::isAnonymousStructOrUnion only returns true if the record lacks a name *and* is not used as the type in an object's declaration. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200868 91177308-0d34-0410-b5e6-96231b3b80d8
* Make Sema::BuildCXXNestedNameSpecifier correctly clear the previousKaelyn Uhrain2013-12-161-0/+18
| | | | | | | | CXXScopeSpec when necessary while performing typo correction. This fixes the crash reported in PR18213 (the problem existed since r185487, and r193020 made it easier to hit). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197409 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Don't require -re suffix on -verify directives with regexes."Alp Toker2013-12-141-8/+8
| | | | | | | | | | This patch was submitted to the list for review and didn't receive a LGTM. (In fact one explicit objection and one query were raised.) This reverts commit r197295. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197299 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't require -re suffix on -verify directives with regexes.Hans Wennborg2013-12-141-8/+8
| | | | | | Differential Revision: http://llvm-reviews.chandlerc.com/D2392 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197295 91177308-0d34-0410-b5e6-96231b3b80d8
* Change semantics of regex expectations in the diagnostic verifierHans Wennborg2013-12-111-8/+8
| | | | | | | | | | | | | | | | | | | | | | | Previously, a line like // expected-error-re {{foo}} treats the entirety of foo as a regex. This is inconvenient when matching type names containing regex characters. For example, to match "void *(class test8::A::*)(void)" inside such a regex, one would have to type "void \*\(class test8::A::\*\)\(void\)". This patch changes the semantics of expected-error-re to only treat the parts of the directive wrapped in double curly braces as regexes. This avoids the escaping problem and leads to nicer patterns for those cases; see e.g. the change to test/Sema/format-strings-scanf.c. (The balanced search for closing }} of a directive also makes us handle the full directive in test\SemaCXX\constexpr-printing.cpp:41 and :53.) Differential Revision: http://llvm-reviews.chandlerc.com/D2388 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197092 91177308-0d34-0410-b5e6-96231b3b80d8
* Allow CorrectTypo to replace CXXScopeSpecifiers that refer to classes.Kaelyn Uhrain2013-10-191-0/+13
| | | | | | | | | | | Now that CorrectTypo knows how to correctly search classes for typo correction candidates, there is no good reason to only replace an existing CXXScopeSpecifier if it refers to a namespace. While the actual enablement was a matter of changing a single comparison, the fallout from enabling the functionality required a lot more code changes (including my two previous commits). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193020 91177308-0d34-0410-b5e6-96231b3b80d8
* Do not use typo correction that is unaccessible.Serge Pavlov2013-10-141-0/+17
| | | | | | | | | This patch fixes PR17019. When doing typo correction, Sema::CorrectTypo uses correction already seen for the same typo. This causes problems if that correction is from another scope and cannot be accessed in the current. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192594 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a typo suggestion regression introduced by r191544.Kaelyn Uhrain2013-10-011-0/+7
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191798 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix typo correction usage of SemaAccess.cpp.Eli Friedman2013-10-011-0/+9
| | | | | | | | | | When we check access for lookup results, make sure we propagate the result's access to the access control APIs; this can be different from the natural access of the declaration depending on the path used by the lookup. PR17394. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191726 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't suggest namespaces if the next token is a '.'Kaelyn Uhrain2013-09-271-0/+7
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191589 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't give suggest things like function names on the left side of "=".Kaelyn Uhrain2013-09-271-0/+5
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191545 91177308-0d34-0410-b5e6-96231b3b80d8
* Avoid the hard-coded limit on the number of typo corrections attempted.Kaelyn Uhrain2013-09-271-0/+31
| | | | | | | | | | | | | | | Move some tests from typo-correction.cpp to typo-correction-pt2.cpp because they were running afoul of the hard-coded limit of 20 typos corrected. Some of the tests after it were still working due to the limit not applying to cached corrections and in cases where a non-NULL MemberContext is passed in to Sema::CorrectTypo. Most of the moved tests still passed after being moved, but the test involving "data_struct" had only been passing because the test had exceeded that limit so a fix for it is also included (most of the changes to ParseStmt.cpp are shared with and originated from another typo correction impovement that was split into a separate commit). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191544 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix error recovery when a return type correction includes a new name specifier.Kaelyn Uhrain2013-09-261-3/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191459 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach typo correction to look inside of classes like it does namespaces.Kaelyn Uhrain2013-09-261-0/+61
| | | | | | | | | | | | | | | Unlike with namespaces, searching inside of classes requires also checking the access to correction candidates (i.e. don't suggest a correction to a private class member for a correction occurring outside that class and its methods or friends). Included is a small (one line) fix for a bug, that was uncovered while cleaning up the unit tests, where the decls from a TypoCorrection candidate were preserved in new TypoCorrection candidates that are derived (copied) from the old TypoCorrection--notably when creating a new candidate by changing the NestedNameSpecifier associated with the base idenitifer. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191449 91177308-0d34-0410-b5e6-96231b3b80d8
* Refactor all diagnosing of TypoCorrections through a common function, inRichard Smith2013-08-171-4/+4
| | | | | | | | preparation for teaching this function how to diagnose a correction that includes importing a module. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188602 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a crasher than manifests when typo correction suggests a function template.Richard Trieu2013-07-311-0/+19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187467 91177308-0d34-0410-b5e6-96231b3b80d8
* Attempt typo correction for function calls with the wrong number of arguments.Kaelyn Uhrain2013-07-081-0/+16
Combined with typo correction's new ability to apply global/absolute nested name specifiers to possible corrections, cases such as in PR12287 where the desired function is being shadowed by a lexically closer function with the same name but a different number of parameters will now include a FixIt. On a side note, since the test for this change caused test/SemaCXX/typo-correction.cpp to exceed the typo correction limit for a single file, I've included a test case for exceeding the limit and added some comments to both the original and part two of typo-correction.cpp warning future editors of the files about the limit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185881 91177308-0d34-0410-b5e6-96231b3b80d8