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

llvm-svn: 302037
This commit is contained in:
Alex Lorenz 2017-05-03 15:41:16 +00:00
parent d10df49c90
commit d7dfec818b
2 changed files with 31 additions and 1 deletions

View 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();
}

View File

@ -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;
}