r316966 - Typo correct the condition of 'do-while' before exiting its scope

Alex Lorenz via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 30 15:55:12 PDT 2017


Author: arphaman
Date: Mon Oct 30 15:55:11 2017
New Revision: 316966

URL: http://llvm.org/viewvc/llvm-project?rev=316966&view=rev
Log:
Typo correct the condition of 'do-while' before exiting its scope

rdar://35172419

Modified:
    cfe/trunk/lib/Parse/ParseStmt.cpp
    cfe/trunk/test/SemaObjCXX/typo-correction.mm

Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=316966&r1=316965&r2=316966&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Mon Oct 30 15:55:11 2017
@@ -1479,6 +1479,9 @@ StmtResult Parser::ParseDoStatement() {
   DiagnoseAndSkipCXX11Attributes();
 
   ExprResult Cond = ParseExpression();
+  // Correct the typos in condition before closing the scope.
+  if (Cond.isUsable())
+    Cond = Actions.CorrectDelayedTyposInExpr(Cond);
   T.consumeClose();
   DoScope.Exit();
 

Modified: cfe/trunk/test/SemaObjCXX/typo-correction.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/typo-correction.mm?rev=316966&r1=316965&r2=316966&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/typo-correction.mm (original)
+++ cfe/trunk/test/SemaObjCXX/typo-correction.mm Mon Oct 30 15:55:11 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -fsyntax-only
+// RUN: %clang_cc1 %s -verify -fsyntax-only -Wno-objc-root-class
 
 class ClassA {};
 
@@ -55,3 +55,35 @@ void invalidNameInIvarAndPropertyBase()
   typoCandidate.x = 0; // expected-error {{use of undeclared identifier 'typoCandidate'; did you mean '_typoCandidate'?}}
 }
 @end
+
+// rdar://35172419
+// The scope of 'do-while' ends before typo-correction takes place.
+
+struct Mat2 { int rows; };
+
+ at implementation ImplNoInt // expected-warning {{cannot find interface declaration for 'ImplNoInt'}}
+
+- (void)typoCorrentInDoWhile {
+  Mat2 tlMat1; // expected-note {{'tlMat1' declared here}}
+  // Create many scopes to exhaust the cache.
+  do {
+    for (int index = 0; index < 2; index++) {
+      if (true) {
+        for (int specialTileType = 1; specialTileType < 5; specialTileType++) {
+          for (int i = 0; i < 10; i++) {
+            for (double scale = 0.95; scale <= 1.055; scale += 0.05) {
+              for (int j = 0; j < 10; j++) {
+                if (1 > 0.9) {
+                    for (int sptile = 1; sptile < 5; sptile++) {
+                    }
+                }
+              }
+            }
+          }
+        }
+      }
+    }
+  } while (tlMat.rows); // expected-error {{use of undeclared identifier 'tlMat'; did you mean 'tlMat1'}}
+}
+
+ at end




More information about the cfe-commits mailing list