[PATCH] D36853: [Parser] Correct initalizer typos before lambda capture type is deduced.

Volodymyr Sapsai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 18 11:38:15 PDT 2017

vsapsai updated this revision to Diff 111716.
vsapsai added a comment.

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.



Index: clang/test/SemaCXX/cxx1y-init-captures.cpp
--- clang/test/SemaCXX/cxx1y-init-captures.cpp
+++ clang/test/SemaCXX/cxx1y-init-captures.cpp
@@ -206,3 +206,11 @@
   find(weight); // expected-note {{in instantiation of function template specialization}}
+namespace init_capture_undeclared_identifier {
+  auto a = [x = y]{}; // expected-error{{use of undeclared identifier 'y'}}
+  int typo_foo; // expected-note 2 {{'typo_foo' declared here}}
+  auto b = [x = typo_boo]{}; // expected-error{{use of undeclared identifier 'typo_boo'; did you mean 'typo_foo'}}
+  auto c = [x(typo_boo)]{}; // expected-error{{use of undeclared identifier 'typo_boo'; did you mean 'typo_foo'}}
Index: clang/lib/Parse/ParseExprCXX.cpp
--- clang/lib/Parse/ParseExprCXX.cpp
+++ clang/lib/Parse/ParseExprCXX.cpp
@@ -966,6 +966,8 @@
     // that would be an error.
     ParsedType InitCaptureType;
+    if (!Init.isInvalid())
+      Init = Actions.CorrectDelayedTyposInExpr(Init.get());
     if (Init.isUsable()) {
       // Get the pointer and store it in an lvalue, so we can use it as an
       // out argument.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36853.111716.patch
Type: text/x-patch
Size: 1244 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170818/1ca63571/attachment.bin>

More information about the cfe-commits mailing list