mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 07:35:08 +00:00
Fix spurious "Failed to index" errors
This commit is contained in:
parent
bf698b85d4
commit
4ea0dee1c9
@ -1220,15 +1220,18 @@ std::vector<std::unique_ptr<IndexFile>>
|
||||
Index(CompletionManager *completion, WorkingFiles *wfiles, VFS *vfs,
|
||||
const std::string &opt_wdir, const std::string &file,
|
||||
const std::vector<const char *> &args,
|
||||
const std::vector<std::pair<std::string, std::string>> &remapped) {
|
||||
const std::vector<std::pair<std::string, std::string>> &remapped, bool &ok) {
|
||||
ok = true;
|
||||
if (!g_config->index.enabled)
|
||||
return {};
|
||||
|
||||
auto PCH = std::make_shared<PCHContainerOperations>();
|
||||
llvm::IntrusiveRefCntPtr<vfs::FileSystem> FS = vfs::getRealFileSystem();
|
||||
std::shared_ptr<CompilerInvocation> 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<FrontendAction> Action = createIndexingAction(
|
||||
DataConsumer, IndexOpts, std::make_unique<IndexFrontendAction>(param));
|
||||
|
||||
bool ok = false;
|
||||
{
|
||||
llvm::CrashRecoveryContext CRC;
|
||||
auto parse = [&]() {
|
||||
|
@ -292,5 +292,6 @@ std::vector<std::unique_ptr<IndexFile>>
|
||||
Index(CompletionManager *complete, WorkingFiles *wfiles, VFS *vfs,
|
||||
const std::string &opt_wdir, const std::string &file,
|
||||
const std::vector<const char *> &args,
|
||||
const std::vector<std::pair<std::string, std::string>> &remapped);
|
||||
}
|
||||
const std::vector<std::pair<std::string, std::string>> &remapped,
|
||||
bool &ok);
|
||||
} // namespace ccls::idx
|
||||
|
@ -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;
|
||||
|
@ -305,7 +305,8 @@ bool RunIndexTests(const std::string &filter_path, bool enable_update) {
|
||||
std::vector<const char *> 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;
|
||||
|
Loading…
Reference in New Issue
Block a user