diff --git a/src/indexer.cc b/src/indexer.cc index e10f7dcd..3254759e 100644 --- a/src/indexer.cc +++ b/src/indexer.cc @@ -1220,15 +1220,18 @@ std::vector> Index(CompletionManager *completion, WorkingFiles *wfiles, VFS *vfs, const std::string &opt_wdir, const std::string &file, const std::vector &args, - const std::vector> &remapped) { + const std::vector> &remapped, bool &ok) { + ok = true; if (!g_config->index.enabled) return {}; auto PCH = std::make_shared(); llvm::IntrusiveRefCntPtr FS = vfs::getRealFileSystem(); std::shared_ptr CI = BuildCompilerInvocation(args, FS); + // e.g. .s if (!CI) return {}; + ok = false; // -fparse-all-comments enables documentation in the indexer and in // code completion. CI->getLangOpts()->CommentOpts.ParseAllComments = @@ -1288,7 +1291,6 @@ Index(CompletionManager *completion, WorkingFiles *wfiles, VFS *vfs, std::unique_ptr Action = createIndexingAction( DataConsumer, IndexOpts, std::make_unique(param)); - bool ok = false; { llvm::CrashRecoveryContext CRC; auto parse = [&]() { diff --git a/src/indexer.h b/src/indexer.h index 11c2b58b..b9056114 100644 --- a/src/indexer.h +++ b/src/indexer.h @@ -292,5 +292,6 @@ std::vector> Index(CompletionManager *complete, WorkingFiles *wfiles, VFS *vfs, const std::string &opt_wdir, const std::string &file, const std::vector &args, - const std::vector> &remapped); -} + const std::vector> &remapped, + bool &ok); +} // namespace ccls::idx diff --git a/src/pipeline.cc b/src/pipeline.cc index f5d763ac..f31eb03d 100644 --- a/src/pipeline.cc +++ b/src/pipeline.cc @@ -266,10 +266,11 @@ bool Indexer_Parse(CompletionManager *completion, WorkingFiles *wfiles, if (content.size()) remapped.emplace_back(path_to_index, content); } + bool ok; auto indexes = idx::Index(completion, wfiles, vfs, entry.directory, - path_to_index, entry.args, remapped); + path_to_index, entry.args, remapped, ok); - if (indexes.empty()) { + if (!ok) { if (g_config->index.enabled && request.id.Valid()) { Out_Error out; out.id = request.id; diff --git a/src/test.cc b/src/test.cc index d60a3bb5..7eed1af0 100644 --- a/src/test.cc +++ b/src/test.cc @@ -305,7 +305,8 @@ bool RunIndexTests(const std::string &filter_path, bool enable_update) { std::vector cargs; for (auto &arg : flags) cargs.push_back(arg.c_str()); - auto dbs = ccls::idx::Index(&completion, &wfiles, &vfs, "", path, cargs, {}); + bool ok; + auto dbs = ccls::idx::Index(&completion, &wfiles, &vfs, "", path, cargs, {}, ok); for (const auto &entry : all_expected_output) { const std::string &expected_path = entry.first;