diff options
| author | Haojian Wu <hokein@google.com> | 2018-02-22 13:35:01 +0000 |
|---|---|---|
| committer | Haojian Wu <hokein@google.com> | 2018-02-22 13:35:01 +0000 |
| commit | b603a5e0e3760eb8148e327bb184d60d6b6bfbd7 (patch) | |
| tree | 2640be9123cff5af4c679a3cb6022151bc1604cf /clang-tools-extra/clangd/Headers.cpp | |
| parent | 1fb81bcb9bb4ba5571b24847713894623e67a926 (diff) | |
| download | bcm5719-llvm-b603a5e0e3760eb8148e327bb184d60d6b6bfbd7.tar.gz bcm5719-llvm-b603a5e0e3760eb8148e327bb184d60d6b6bfbd7.zip | |
[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
Diffstat (limited to 'clang-tools-extra/clangd/Headers.cpp')
| -rw-r--r-- | clang-tools-extra/clangd/Headers.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/clang-tools-extra/clangd/Headers.cpp b/clang-tools-extra/clangd/Headers.cpp index db8029b2ac0..3cdacffc452 100644 --- a/clang-tools-extra/clangd/Headers.cpp +++ b/clang-tools-extra/clangd/Headers.cpp @@ -79,12 +79,12 @@ calculateIncludePath(llvm::StringRef File, llvm::StringRef Code, // 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>( |

