[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
Wed May 1 12:23:53 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL359713: [Parser] Avoid correcting delayed typos in array subscript multiple times. (authored by vsapsai, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D60848?vs=197421&id=197608#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60848/new/

https://reviews.llvm.org/D60848

Files:
  cfe/trunk/lib/Parse/ParseExpr.cpp
  cfe/trunk/test/SemaCXX/typo-correction.cpp
  cfe/trunk/test/SemaObjC/typo-correction-subscript.m


Index: cfe/trunk/lib/Parse/ParseExpr.cpp
===================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp
+++ cfe/trunk/lib/Parse/ParseExpr.cpp
@@ -1582,7 +1582,9 @@
 
       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 @@
         }
       } else {
         LHS = ExprError();
-      }
-      if (LHS.isInvalid()) {
-        (void)Actions.CorrectDelayedTyposInExpr(OrigLHS);
-        (void)Actions.CorrectDelayedTyposInExpr(Idx);
-        (void)Actions.CorrectDelayedTyposInExpr(Length);
-        LHS = ExprError();
         Idx = ExprError();
       }
 
Index: cfe/trunk/test/SemaCXX/typo-correction.cpp
===================================================================
--- cfe/trunk/test/SemaCXX/typo-correction.cpp
+++ cfe/trunk/test/SemaCXX/typo-correction.cpp
@@ -678,7 +678,7 @@
 struct a0is0 {};
 struct b0is0 {};
 int g() {
-  0 [                 // expected-error {{subscripted value is not an array}}
+  0 [
       sizeof(c0is0)]; // expected-error {{use of undeclared identifier}}
 };
 }
Index: cfe/trunk/test/SemaObjC/typo-correction-subscript.m
===================================================================
--- cfe/trunk/test/SemaObjC/typo-correction-subscript.m
+++ cfe/trunk/test/SemaObjC/typo-correction-subscript.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple i386-apple-macosx10.10 -fobjc-arc -fsyntax-only -Wno-objc-root-class %s -verify -disable-free
+
+ at class Dictionary;
+
+ at interface Test
+ at end
+ at implementation Test
+// rdar://problem/47403222
+- (void)rdar47403222:(Dictionary *)opts {
+  [self undeclaredMethod:undeclaredArg];
+  // expected-error at -1{{no visible @interface for 'Test' declares the selector 'undeclaredMethod:'}}
+  opts[(__bridge id)undeclaredKey] = 0;
+  // expected-error at -1{{use of undeclared identifier 'undeclaredKey'}}
+}
+ at end


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60848.197608.patch
Type: text/x-patch
Size: 2188 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190501/1a7d6536/attachment-0001.bin>


More information about the cfe-commits mailing list