]> granicus.if.org Git - clang/commitdiff
DiagnosticsEngine should clear DelayedDiagID before reporting the
authorAlex Lorenz <arphaman@gmail.com>
Wed, 3 May 2017 15:41:16 +0000 (15:41 +0000)
committerAlex Lorenz <arphaman@gmail.com>
Wed, 3 May 2017 15:41:16 +0000 (15:41 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302037 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/Diagnostic.cpp
test/Index/KeepGoingWithLotsOfErrors.mm [new file with mode: 0644]

index 6bdef78c074f7fb4337590a156121689bfeb1af0..2cd400dbd71f20a783c8ec2994b8a9b3d52726ec 100644 (file)
@@ -146,8 +146,9 @@ void DiagnosticsEngine::SetDelayedDiagnostic(unsigned DiagID, StringRef Arg1,
 }
 
 void DiagnosticsEngine::ReportDelayed() {
-  Report(DelayedDiagID) << DelayedDiagArg1 << DelayedDiagArg2;
+  unsigned ID = DelayedDiagID;
   DelayedDiagID = 0;
+  Report(ID) << DelayedDiagArg1 << DelayedDiagArg2;
   DelayedDiagArg1.clear();
   DelayedDiagArg2.clear();
 }
diff --git a/test/Index/KeepGoingWithLotsOfErrors.mm b/test/Index/KeepGoingWithLotsOfErrors.mm
new file mode 100644 (file)
index 0000000..0144617
--- /dev/null
@@ -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;
+}