Author: arphaman
Date: Wed May  3 10:41:16 2017
New Revision: 302037

URL: http://llvm.org/viewvc/llvm-project?rev=302037&view=rev
Log:
DiagnosticsEngine should clear DelayedDiagID before reporting the
delayed diagnostic

This avoids an infinite loop that was uncovered in one of our internal tests
by r301992. The testcase is the most reduced version of that auto-generated
test.

rdar://31962618

Added:
    cfe/trunk/test/Index/KeepGoingWithLotsOfErrors.mm
Modified:
    cfe/trunk/lib/Basic/Diagnostic.cpp

Modified: cfe/trunk/lib/Basic/Diagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=302037&r1=302036&r2=302037&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Wed May  3 10:41:16 2017
@@ -146,8 +146,9 @@ void DiagnosticsEngine::SetDelayedDiagno
 }
 
 void DiagnosticsEngine::ReportDelayed() {
-  Report(DelayedDiagID) << DelayedDiagArg1 << DelayedDiagArg2;
+  unsigned ID = DelayedDiagID;
   DelayedDiagID = 0;
+  Report(ID) << DelayedDiagArg1 << DelayedDiagArg2;
   DelayedDiagArg1.clear();
   DelayedDiagArg2.clear();
 }

Added: cfe/trunk/test/Index/KeepGoingWithLotsOfErrors.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/KeepGoingWithLotsOfErrors.mm?rev=302037&view=auto
==============================================================================
--- cfe/trunk/test/Index/KeepGoingWithLotsOfErrors.mm (added)
+++ cfe/trunk/test/Index/KeepGoingWithLotsOfErrors.mm Wed May  3 10:41:16 2017
@@ -0,0 +1,29 @@
+// RUN: env CINDEXTEST_KEEP_GOING=1 c-index-test -code-completion-at=%s:25:1 %s
+// Shouldn't crash!
+// This is the minimized test that triggered an infinite loop:
+
++(BOOL) onEntity {
+}
+
+-(const Object &) a_200 {
+}
+
+-(int) struct {
+}
+
+-(int) bar {
+}
+
+-(int) part {
+}
+
++(some_type_t) piece {
+}
+
++(void) z_Z_42 {
+  ([self onEntity: [] { 42];
+  } class: ^ {  }
+];
+  [super];
+  BOOL struct;
+}


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to