Skip to content

Commit b603a5e

Browse files
committedFeb 22, 2018
[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
1 parent 1fb81bc commit b603a5e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed
 

‎clang-tools-extra/clangd/CodeComplete.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -696,11 +696,11 @@ bool semaCodeComplete(std::unique_ptr<CodeCompleteConsumer> Consumer,
696696
Input.Preamble->CanReuse(*CI, ContentsBuffer.get(), Bounds,
697697
Input.VFS.get());
698698
}
699+
// The diagnostic options must be set before creating a CompilerInstance.
700+
CI->getDiagnosticOpts().IgnoreWarnings = true;
699701
auto Clang = prepareCompilerInstance(
700702
std::move(CI), Input.Preamble, std::move(ContentsBuffer),
701703
std::move(Input.PCHs), std::move(Input.VFS), DummyDiagsConsumer);
702-
auto &DiagOpts = Clang->getDiagnosticOpts();
703-
DiagOpts.IgnoreWarnings = true;
704704

705705
// Disable typo correction in Sema.
706706
Clang->getLangOpts().SpellChecking = false;

‎clang-tools-extra/clangd/Headers.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ calculateIncludePath(llvm::StringRef File, llvm::StringRef Code,
7979
// added more than once.
8080
CI->getPreprocessorOpts().SingleFileParseMode = true;
8181

82+
// The diagnostic options must be set before creating a CompilerInstance.
83+
CI->getDiagnosticOpts().IgnoreWarnings = true;
8284
auto Clang = prepareCompilerInstance(
8385
std::move(CI), /*Preamble=*/nullptr,
8486
llvm::MemoryBuffer::getMemBuffer(Code, File),
8587
std::make_shared<PCHContainerOperations>(), FS, IgnoreDiags);
86-
auto &DiagOpts = Clang->getDiagnosticOpts();
87-
DiagOpts.IgnoreWarnings = true;
8888

8989
if (Clang->getFrontendOpts().Inputs.empty())
9090
return llvm::make_error<llvm::StringError>(

0 commit comments

Comments
 (0)
Please sign in to comment.