diff options
author | Volodymyr Sapsai <vsapsai@apple.com> | 2019-05-01 19:24:50 +0000 |
---|---|---|
committer | Volodymyr Sapsai <vsapsai@apple.com> | 2019-05-01 19:24:50 +0000 |
commit | 31f7c4aa77e17c7d42494d0cbdeee2fc0cf80345 (patch) | |
tree | 2330e4e9f47cfe0f0082d34ea07fb867cb64d58c /clang/lib/Parse/ParseExpr.cpp | |
parent | 0a4aeec16eda1ebbaff4539c174926f43305142b (diff) | |
download | bcm5719-llvm-31f7c4aa77e17c7d42494d0cbdeee2fc0cf80345.tar.gz bcm5719-llvm-31f7c4aa77e17c7d42494d0cbdeee2fc0cf80345.zip |
[Parser] Avoid correcting delayed typos in array subscript multiple times.
We correct some typos in `ActOnArraySubscriptExpr` and
`ActOnOMPArraySectionExpr`, so when their result is `ExprError`, we can
end up correcting delayed typos in the same expressions again. In
general it is OK but when `NumTypos` is incorrect, we can hit the
assertion
> Assertion failed: (Entry != DelayedTypos.end() && "Failed to get the state for a TypoExpr!"), function getTypoExprState, file clang/lib/Sema/SemaLookup.cpp, line 5219.
Fix by replacing some subscript `ExprResult` with typo-corrected expressions
instead of keeping the original expressions. Thus if original expressions
contained `TypoExpr`, we'll use corrected expressions instead of trying to
correct them again.
rdar://problem/47403222
Reviewers: rsmith, erik.pilkington, majnemer
Reviewed By: erik.pilkington
Subscribers: jkorous, dexonsmith, cfe-commits
Differential Revision: https://reviews.llvm.org/D60848
llvm-svn: 359713
Diffstat (limited to 'clang/lib/Parse/ParseExpr.cpp')
-rw-r--r-- | clang/lib/Parse/ParseExpr.cpp | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index 4039df888ad..b8f3288284f 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/lib/Parse/ParseExpr.cpp @@ -1582,7 +1582,9 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { SourceLocation RLoc = Tok.getLocation(); - ExprResult OrigLHS = LHS; + LHS = Actions.CorrectDelayedTyposInExpr(LHS); + Idx = Actions.CorrectDelayedTyposInExpr(Idx); + Length = Actions.CorrectDelayedTyposInExpr(Length); if (!LHS.isInvalid() && !Idx.isInvalid() && !Length.isInvalid() && Tok.is(tok::r_square)) { if (ColonLoc.isValid()) { @@ -1594,12 +1596,6 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { } } else { LHS = ExprError(); - } - if (LHS.isInvalid()) { - (void)Actions.CorrectDelayedTyposInExpr(OrigLHS); - (void)Actions.CorrectDelayedTyposInExpr(Idx); - (void)Actions.CorrectDelayedTyposInExpr(Length); - LHS = ExprError(); Idx = ExprError(); } |