Commit Graph

22 Commits

Author SHA1 Message Date
Charles Li 85dec55989 [Lit Test] Updated 20 Lit tests to be C++11 compatible.
This is the 5th Lit test patch.
Expanded expected diagnostics to vary by C++ dialect.
Expanded RUN line to: default, C++98/03 and C++11.

llvm-svn: 255196
2015-12-10 01:07:17 +00:00
Kaelyn Takata 40055d1185 Diagnose delayed typos when parsing a postfix expression with an
unmatched l_paren before setting the LHS to ExprError().

Fixes PR23285.

llvm-svn: 236371
2015-05-02 00:49:18 +00:00
Kaelyn Takata a8dfd33611 Also correct typos in the middle of a ternary expression when the RHS is invalid.
The LHS was already being corrected before being set to ExprError when
the RHS is invalid, but when it was present the middle of a ternary
expression would be dropped in the error paths.

Fixes PR23350.

llvm-svn: 236347
2015-05-01 20:59:18 +00:00
Kaelyn Takata 92565b51aa Diagnose delayed typos in an expr list that is in an invalid expression.
Previously, if the expr list parsed fine but the expr to the left of the
open parenthesis was invalid (when parsing the suffix of a
postfix-expression), the parsed expr list was just ignored.

Fixes PR23005.

llvm-svn: 233347
2015-03-27 01:44:47 +00:00
Kaelyn Takata c49838b331 Revert a change from r222797 that is no longer needed and can cause
infinite recursion.

Also guard against said infinite recursion by adding an assert that will
trigger if CorrectDelayedTyposInExpr is called before a previous call to
CorrectDelayedTyposInExpr returns (i.e. if the TreeTransform run by
CorrectDelayedTyposInExpr calls a sequence of methods that
end up calling CorrectDelayedTyposInExpr, as the new test case had done
prior to this commit). Fixes PR22292.

llvm-svn: 227368
2015-01-28 21:10:46 +00:00
Kaelyn Takata 7a503694fe Fix a think-o in handling ambiguous corrections for a TypoExpr.
Under certain circumstances, the identifier mentioned in the diagnostic
won't match the intended correction even though the replacement
expression and the note pointing to the decl are both correct.
Basically, the TreeTransform assumes the TypoExpr's Consumer points to
the correct TypoCorrection, but the handling of typos that appear to be
ambiguous from the point of view of TransformTypoExpr would cause that
assumption to be violated by altering the Consumer's correction stream.
This fix allows the Consumer's correction stream to be reset to the
right TypoCorrection after successfully resolving the percieved ambiguity.

Included is a fix to suppress correcting the RHS of an assignment to the
LHS of that assignment for non-C++ code, to prevent a regression in
test/SemaObjC/provisional-ivar-lookup.m.

This fixes PR22297.

llvm-svn: 227251
2015-01-27 22:01:39 +00:00
Kaelyn Takata 21a886936b Correct all typos in the initialization arguments, even if one could not
be corrected.

This fixes PR22250, which exposed the bug where if there's more than one
TypoExpr in the arguments, once one failed to be corrected none of the
TypoExprs after it would be handled at all thanks to an early return.

llvm-svn: 226624
2015-01-21 00:04:19 +00:00
Kaelyn Takata ae9e97c9d6 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
2015-01-16 22:11:04 +00:00
Kaelyn Takata 42118a9524 Handle OpaqueValueExprs more intelligently in the TransformTypos tree
transform.

Also diagnose typos in the initializer of an invalid C++ declaration.
Both issues were hit using the same line of test code, depending on
whether the code was treated as C or C++.

Fixes PR22092.

llvm-svn: 225389
2015-01-07 21:16:39 +00:00
Kaelyn Takata 9112607400 Correct delayed typos in the operand to typeof expressions.
Fixes PR21947.

llvm-svn: 224558
2014-12-19 01:28:40 +00:00
Kaelyn Takata 938204aa02 Try typo correction on all initialization arguments and be less
pessimistic about when to do so.

This also fixes PR21905 as the initialization argument was no longer
viewed as being type dependent due to the TypoExpr being type-cast.

llvm-svn: 224386
2014-12-16 23:07:00 +00:00
Nick Lewycky 4d59b77883 Look at whether TransformTypos returned a different Expr instead of looking at the number of uncorrected typos before and after. Correcting one typo may produce an expression with another TypoExpr in it, leading to matching counts even though a typo was corrected.
Fixes PR21925!

llvm-svn: 224380
2014-12-16 22:02:06 +00:00
Reid Kleckner a9e65ba19d Implement feedback on r224172 in PR21899
Based on suggestions from Kaelyn.

llvm-svn: 224173
2014-12-13 01:11:23 +00:00
Reid Kleckner a7fe33e0f6 Typo correction: Ignore temporary binding exprs after overload resolution
Transformation of a CallExpr doesn't always result in a new CallExpr.

Fixes PR21899.

llvm-svn: 224172
2014-12-13 00:53:10 +00:00
Kaelyn Takata a15a6dc78e Handle possible TypoExprs in member initializers.
Includes a new test case since none of the existing tests were hitting
this code path.

llvm-svn: 223705
2014-12-08 22:41:42 +00:00
Kaelyn Takata 53ac6a04eb Handle delayed corrections in a couple more error paths in ParsePostfixExpressionSuffix.
llvm-svn: 223209
2014-12-03 05:30:54 +00:00
Kaelyn Takata 999dd85e16 Ensure typos in the default values of template parameters get diagnosed.
llvm-svn: 223177
2014-12-02 23:32:20 +00:00
Kaelyn Takata 443d61d62a Ensure that any TypoExprs in the arguments to bultins with custom type
checking are handled before the custom type checking is performed.

Fixes PR21669.

llvm-svn: 222797
2014-11-25 23:04:09 +00:00
Kaelyn Takata 4c3ffc4fef Properly correct initializer expressions based on whether they would be valid.
llvm-svn: 222550
2014-11-21 18:48:00 +00:00
Kaelyn Takata 5ca2ecd2b2 Use the full-Expr filter to disambiguate equidistant correction
candidates.

llvm-svn: 222549
2014-11-21 18:47:58 +00:00
Kaelyn Takata 57e07c950d Ensure all TypoExprs are diagnosed by the tree transform.
If there is more than one TypoExpr within the expr being transformed and
any but the last TypoExpr seen don't have any viable candidates, the
tree transform will be aborted early and the remaining TypoExprs are
never seen and hence never diagnosed. This adds a simple
RecursiveASTVisitor to find all of the TypoExprs to be diagnosed in the
case where typo correction of the entire expr fails (and the result of
the tree transform is an ExprError).

llvm-svn: 222465
2014-11-20 22:06:44 +00:00
Kaelyn Takata fe408a77f6 Wire up LookupMemberExpr to use the new TypoExpr.
This includes adding the new TypoExpr-based lazy typo correction to
LookupMemberExprInRecord as an alternative to the existing eager typo
correction.

llvm-svn: 220698
2014-10-27 18:07:46 +00:00