diff options
| author | Eric Liu <ioeric@google.com> | 2019-04-15 12:32:28 +0000 |
|---|---|---|
| committer | Eric Liu <ioeric@google.com> | 2019-04-15 12:32:28 +0000 |
| commit | 9ef03dd20a589e1dd2b8e6589967d26e7433b073 (patch) | |
| tree | c868bc42632cf6cf474eec6eeced274645ea8ba4 /clang-tools-extra/clangd/ClangdServer.cpp | |
| parent | 2be3f868f9c21d9d9eb1d3d4608d8a319baaabcc (diff) | |
| download | bcm5719-llvm-9ef03dd20a589e1dd2b8e6589967d26e7433b073.tar.gz bcm5719-llvm-9ef03dd20a589e1dd2b8e6589967d26e7433b073.zip | |
[clangd] Wait for compile command in ASTWorker instead of ClangdServer
Summary:
This makes addDocument non-blocking and would also allow code completion
(in fallback mode) to run when worker waits for the compile command.
Reviewers: sammccall, ilya-biryukov
Reviewed By: ilya-biryukov
Subscribers: javed.absar, MaskRay, jkorous, arphaman, kadircet, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D60607
llvm-svn: 358400
Diffstat (limited to 'clang-tools-extra/clangd/ClangdServer.cpp')
| -rw-r--r-- | clang-tools-extra/clangd/ClangdServer.cpp | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/clang-tools-extra/clangd/ClangdServer.cpp b/clang-tools-extra/clangd/ClangdServer.cpp index 345c8b665ed..e14c1d29c3b 100644 --- a/clang-tools-extra/clangd/ClangdServer.cpp +++ b/clang-tools-extra/clangd/ClangdServer.cpp @@ -109,7 +109,7 @@ ClangdServer::ClangdServer(const GlobalCompilationDatabase &CDB, const FileSystemProvider &FSProvider, DiagnosticsConsumer &DiagConsumer, const Options &Opts) - : CDB(CDB), FSProvider(FSProvider), + : FSProvider(FSProvider), DynamicIdx(Opts.BuildDynamicSymbolIndex ? new FileIndex(Opts.HeavyweightDynamicSymbolIndex) : nullptr), @@ -121,7 +121,7 @@ ClangdServer::ClangdServer(const GlobalCompilationDatabase &CDB, // is parsed. // FIXME(ioeric): this can be slow and we may be able to index on less // critical paths. - WorkScheduler(Opts.AsyncThreadsCount, Opts.StorePreamblesInMemory, + WorkScheduler(CDB, Opts.AsyncThreadsCount, Opts.StorePreamblesInMemory, llvm::make_unique<UpdateIndexCallbacks>(DynamicIdx.get(), DiagConsumer), Opts.UpdateDebounce, Opts.RetentionPolicy) { @@ -155,12 +155,8 @@ void ClangdServer::addDocument(PathRef File, llvm::StringRef Contents, Opts.ClangTidyOpts = ClangTidyOptProvider->getOptions(File); Opts.SuggestMissingIncludes = SuggestMissingIncludes; - // FIXME: some build systems like Bazel will take time to preparing - // environment to build the file, it would be nice if we could emit a - // "PreparingBuild" status to inform users, it is non-trivial given the - // current implementation. + // Compile command is set asynchronously during update, as it can be slow. ParseInputs Inputs; - Inputs.CompileCommand = getCompileCommand(File); Inputs.FS = FSProvider.getFileSystem(); Inputs.Contents = Contents; Inputs.Opts = std::move(Opts); @@ -543,14 +539,6 @@ void ClangdServer::typeHierarchy(PathRef File, Position Pos, int Resolve, WorkScheduler.runWithAST("Type Hierarchy", File, Bind(Action, std::move(CB))); } -tooling::CompileCommand ClangdServer::getCompileCommand(PathRef File) { - trace::Span Span("GetCompileCommand"); - llvm::Optional<tooling::CompileCommand> C = CDB.getCompileCommand(File); - if (!C) // FIXME: Suppress diagnostics? Let the user know? - C = CDB.getFallbackCommand(File); - return std::move(*C); -} - void ClangdServer::onFileEvent(const DidChangeWatchedFilesParams &Params) { // FIXME: Do nothing for now. This will be used for indexing and potentially // invalidating other caches. |

