[PATCH] D60848: [Parser] Avoid correcting delayed typos in array subscript multiple times.
Volodymyr Sapsai via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 23 17:47:11 PDT 2019
vsapsai added a comment.
In D60848#1472799 <https://reviews.llvm.org/D60848#1472799>, @erik.pilkington wrote:
> Wait, why is NumTypos incorrect here? I think its because we don't handle the typo on the line: `[self undeclaredMethod:undeclaredArg];`, even the following asserts now. Seems like the right fix would be to track down why we aren't handling the typo in the message expr.
>
> // RUN: clang -cc1 %s -fobjc-arc
> @implementation X
> -x { [self undeclaredMethod:undeclaredArg]; }
> @end
>
The reason why we aren't handling the typo in this case is because TypoExpr is created for `undeclaredArg` and when we emit `err_arc_may_not_respond` <https://github.com/llvm/llvm-project/blob/36371d61ec8ddd13ad922845de6f4c6b95cd21f2/clang/lib/Sema/SemaExprObjC.cpp#L2931-L2934> we just return `ExprError` and drop `MultiExprArg` without checking if it contains TypoExpr or not. It is possible to fix this case but we have many more. Some of them are
@class Test;
void test(void) {
Test *obj;
[obj test:undeclaredArg];
}
struct S {
int x;
} S;
void test(void) {
[S test:undeclaredArg];
}
I think that with the current design for delayed typos it's not feasible to fix all of these lingering delayed typos. Given that with disabled assertions non-empty `DelayedTypos` in `~Sema` isn't causing crashes, I've decided to improve handling the subscripts.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60848/new/
https://reviews.llvm.org/D60848
More information about the cfe-commits
mailing list