From c04c9fa750be08c9aa3d720f9679bee04169cb47 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sat, 23 Dec 2017 15:08:36 -0800 Subject: [PATCH] Don't emit more diagnostics after hitting -ferror-limit --- src/clang_complete.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/clang_complete.cc b/src/clang_complete.cc index 99caa9fd..e02f1930 100644 --- a/src/clang_complete.cc +++ b/src/clang_complete.cc @@ -335,8 +335,13 @@ void TryEnsureDocumentParsed(ClangCompleteManager* manager, for (unsigned i = 0; i < num_diagnostics; ++i) { optional diagnostic = BuildAndDisposeDiagnostic( clang_getDiagnostic((*tu)->cx_tu, i), session->file.filename); - if (diagnostic) + if (diagnostic) { + // "too many errors emitted, stopping now [-ferror-limit=]" has line = 0 + // and got subtracted by 1 after conversion to lsDiagnostic + if (diagnostic->range.start.line == -1) + break; ls_diagnostics.push_back(*diagnostic); + } } manager->on_diagnostic_(session->file.filename, ls_diagnostics); } @@ -504,8 +509,13 @@ void CompletionQueryMain(ClangCompleteManager* completion_manager) { CXDiagnostic cx_diag = clang_getDiagnostic(session->tu->cx_tu, i); optional diagnostic = BuildAndDisposeDiagnostic(cx_diag, path); - if (diagnostic) + if (diagnostic) { + // "too many errors emitted, stopping now [-ferror-limit=]" has line = 0 + // and got subtracted by 1 after conversion to lsDiagnostic + if (diagnostic->range.start.line == -1) + break; ls_diagnostics.push_back(*diagnostic); + } } completion_manager->on_diagnostic_(session->file.filename, ls_diagnostics);