[PATCH] D20490: [Parser] Fix a crash on invalid where a delayed TypoExpr was corrected twice

Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 13 14:03:31 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL272587: [Parser] Only correct delayed typos when needed (authored by epilk).

Changed prior to commit:
  http://reviews.llvm.org/D20490?vs=57980&id=60603#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20490

Files:
  cfe/trunk/lib/Parse/ParseExpr.cpp
  cfe/trunk/test/Sema/typo-correction.c

Index: cfe/trunk/test/Sema/typo-correction.c
===================================================================
--- cfe/trunk/test/Sema/typo-correction.c
+++ cfe/trunk/test/Sema/typo-correction.c
@@ -57,3 +57,11 @@
 }
 
 int d = X ? d : L; // expected-error 2 {{use of undeclared identifier}}
+
+int fn_with_ids() { ID = ID == ID >= ID ; } // expected-error 4 {{use of undeclared identifier}}
+
+int fn_with_rs(int r) { r = TYPO + r * TYPO; } // expected-error 2 {{use of undeclared identifier}}
+
+void fn_with_unknown(int a, int b) {
+  fn_with_unknown(unknown, unknown | unknown); // expected-error 3 {{use of undeclared identifier}}
+}
Index: cfe/trunk/lib/Parse/ParseExpr.cpp
===================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp
+++ cfe/trunk/lib/Parse/ParseExpr.cpp
@@ -446,6 +446,10 @@
 
         LHS = Actions.ActOnBinOp(getCurScope(), OpToken.getLocation(),
                                  OpToken.getKind(), LHS.get(), RHS.get());
+
+        // In this case, ActOnBinOp performed the CorrectDelayedTyposInExpr check.
+        if (!getLangOpts().CPlusPlus)
+          continue;
       } else {
         LHS = Actions.ActOnConditionalOp(OpToken.getLocation(), ColonLoc,
                                          LHS.get(), TernaryMiddle.get(),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20490.60603.patch
Type: text/x-patch
Size: 1308 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160613/8f3eb786/attachment-0001.bin>


More information about the cfe-commits mailing list