[clangd] Correct setting ignoreWarnings in CodeCompletion.
Summary:
We should set the flag before creating ComplierInstance -- when
CopmilerInstance gets initialized, it also initializes the DiagnosticsEngine
using the DiagnosticOptions.
This was hidden deeply -- as clang suppresses all diagnostics when we
hit the code-completion (but internally it does do unnecessary analysis stuff).
As a bonus point, this fix will optmize the completion speed -- clang won't do
any analysis (e.g. -Wunreachable-code, -Wthread-safety-analysisi) at all internally.
Reviewers: ilya-biryukov
Reviewed By: ilya-biryukov
Subscribers: klimek, jkorous-apple, ioeric, cfe-commits
Differential Revision: https://reviews.llvm.org/D43569
llvm-svn: 325779
diff --git a/clang-tools-extra/clangd/CodeComplete.cpp b/clang-tools-extra/clangd/CodeComplete.cpp
index d582adc..74ea89d 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -696,11 +696,11 @@
Input.Preamble->CanReuse(*CI, ContentsBuffer.get(), Bounds,
Input.VFS.get());
}
+ // The diagnostic options must be set before creating a CompilerInstance.
+ CI->getDiagnosticOpts().IgnoreWarnings = true;
auto Clang = prepareCompilerInstance(
std::move(CI), Input.Preamble, std::move(ContentsBuffer),
std::move(Input.PCHs), std::move(Input.VFS), DummyDiagsConsumer);
- auto &DiagOpts = Clang->getDiagnosticOpts();
- DiagOpts.IgnoreWarnings = true;
// Disable typo correction in Sema.
Clang->getLangOpts().SpellChecking = false;