[clang-tools-extra] r325779 - [clangd] Correct setting ignoreWarnings in CodeCompletion.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 22 05:35:01 PST 2018
Author: hokein
Date: Thu Feb 22 05:35:01 2018
New Revision: 325779
URL: http://llvm.org/viewvc/llvm-project?rev=325779&view=rev
Log:
[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
Modified:
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/clangd/Headers.cpp
Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=325779&r1=325778&r2=325779&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Thu Feb 22 05:35:01 2018
@@ -696,11 +696,11 @@ bool semaCodeComplete(std::unique_ptr<Co
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;
Modified: clang-tools-extra/trunk/clangd/Headers.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Headers.cpp?rev=325779&r1=325778&r2=325779&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/Headers.cpp (original)
+++ clang-tools-extra/trunk/clangd/Headers.cpp Thu Feb 22 05:35:01 2018
@@ -79,12 +79,12 @@ calculateIncludePath(llvm::StringRef Fil
// added more than once.
CI->getPreprocessorOpts().SingleFileParseMode = true;
+ // The diagnostic options must be set before creating a CompilerInstance.
+ CI->getDiagnosticOpts().IgnoreWarnings = true;
auto Clang = prepareCompilerInstance(
std::move(CI), /*Preamble=*/nullptr,
llvm::MemoryBuffer::getMemBuffer(Code, File),
std::make_shared<PCHContainerOperations>(), FS, IgnoreDiags);
- auto &DiagOpts = Clang->getDiagnosticOpts();
- DiagOpts.IgnoreWarnings = true;
if (Clang->getFrontendOpts().Inputs.empty())
return llvm::make_error<llvm::StringError>(
More information about the cfe-commits
mailing list