forked from OSchip/llvm-project
[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
This commit is contained in:
parent
1fb81bcb9b
commit
b603a5e0e3
|
@ -696,11 +696,11 @@ bool semaCodeComplete(std::unique_ptr<CodeCompleteConsumer> Consumer,
|
||||||
Input.Preamble->CanReuse(*CI, ContentsBuffer.get(), Bounds,
|
Input.Preamble->CanReuse(*CI, ContentsBuffer.get(), Bounds,
|
||||||
Input.VFS.get());
|
Input.VFS.get());
|
||||||
}
|
}
|
||||||
|
// The diagnostic options must be set before creating a CompilerInstance.
|
||||||
|
CI->getDiagnosticOpts().IgnoreWarnings = true;
|
||||||
auto Clang = prepareCompilerInstance(
|
auto Clang = prepareCompilerInstance(
|
||||||
std::move(CI), Input.Preamble, std::move(ContentsBuffer),
|
std::move(CI), Input.Preamble, std::move(ContentsBuffer),
|
||||||
std::move(Input.PCHs), std::move(Input.VFS), DummyDiagsConsumer);
|
std::move(Input.PCHs), std::move(Input.VFS), DummyDiagsConsumer);
|
||||||
auto &DiagOpts = Clang->getDiagnosticOpts();
|
|
||||||
DiagOpts.IgnoreWarnings = true;
|
|
||||||
|
|
||||||
// Disable typo correction in Sema.
|
// Disable typo correction in Sema.
|
||||||
Clang->getLangOpts().SpellChecking = false;
|
Clang->getLangOpts().SpellChecking = false;
|
||||||
|
|
|
@ -79,12 +79,12 @@ calculateIncludePath(llvm::StringRef File, llvm::StringRef Code,
|
||||||
// added more than once.
|
// added more than once.
|
||||||
CI->getPreprocessorOpts().SingleFileParseMode = true;
|
CI->getPreprocessorOpts().SingleFileParseMode = true;
|
||||||
|
|
||||||
|
// The diagnostic options must be set before creating a CompilerInstance.
|
||||||
|
CI->getDiagnosticOpts().IgnoreWarnings = true;
|
||||||
auto Clang = prepareCompilerInstance(
|
auto Clang = prepareCompilerInstance(
|
||||||
std::move(CI), /*Preamble=*/nullptr,
|
std::move(CI), /*Preamble=*/nullptr,
|
||||||
llvm::MemoryBuffer::getMemBuffer(Code, File),
|
llvm::MemoryBuffer::getMemBuffer(Code, File),
|
||||||
std::make_shared<PCHContainerOperations>(), FS, IgnoreDiags);
|
std::make_shared<PCHContainerOperations>(), FS, IgnoreDiags);
|
||||||
auto &DiagOpts = Clang->getDiagnosticOpts();
|
|
||||||
DiagOpts.IgnoreWarnings = true;
|
|
||||||
|
|
||||||
if (Clang->getFrontendOpts().Inputs.empty())
|
if (Clang->getFrontendOpts().Inputs.empty())
|
||||||
return llvm::make_error<llvm::StringError>(
|
return llvm::make_error<llvm::StringError>(
|
||||||
|
|
Loading…
Reference in New Issue