This is an archive of the discontinued LLVM Phabricator instance.

[Parser] Correct initalizer typos before lambda capture type is deduced.
ClosedPublic

Authored by vsapsai on Aug 17 2017, 5:19 PM.

Details

Summary

This is the same assertion as in https://reviews.llvm.org/D25206 that is
triggered when RecordLayoutBuilder tries to compute the size of a field
(for capture "typo_boo" in the test case) whose type hasn't been
deduced.

The fix is to add CorrectDelayedTyposInExpr call to the cases when we
aren't disambiguating between an Obj-C message send and a lambda
expression.

rdar://problem/31760839

Event Timeline

vsapsai created this revision.Aug 17 2017, 5:19 PM

There's also a crash with the ( ... ) initializer:

namespace init_capture_undeclared_identifier {
  auto a = [x = y]{};

  int typo_foo;
  auto b = [x (typo_boo )]{}; 
}

I think you should move the added correction code before if (Init.isUsable()) to ensure that all paths are covered.

vsapsai updated this revision to Diff 111716.Aug 18 2017, 11:38 AM

Address review comments.

Moved CorrectDelayedTyposInExpr according to review comment and added
mentioned test case.

Removed the assertion as it didn't catch the expression

ParenListExpr 0x7f8297060e40 'NULL TYPE'
`-TypoExpr 0x7f8297060e30 '<dependent type>' lvalue

Didn't remove CorrectDelayedTyposInExpr for the case when we disambiguate
between lambda and Obj-C message send because we use corrected expression in
annotation token. Checked that correcting typos the second time returns the
same expression because there are no typos anymore.

vsapsai edited the summary of this revision. (Show Details)Aug 18 2017, 11:40 AM
arphaman accepted this revision.Aug 21 2017, 3:44 AM

LGTM, Thanks.

You should obtain commit access if you haven't already done so (https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access). I can commit this on your behalf as well if you want.

This revision is now accepted and ready to land.Aug 21 2017, 3:44 AM

Thanks for review, Alex. I've requested commit access and plan to commit the change myself to make sure everything works as expected.

This revision was automatically updated to reflect the committed changes.