diff --git a/indexer/Driver.cc b/indexer/Driver.cc index e77ea10a..85f8e8d1 100644 --- a/indexer/Driver.cc +++ b/indexer/Driver.cc @@ -703,8 +703,10 @@ class Driver { fullIndex.SerializeToOstream(&outputStream); } - bool isMultiplyIndexedApproximate(const std::string &relativePath, - AbsolutePathRef shardPath) const { + bool + isMultiplyIndexedApproximate(const std::string &relativePath, + AbsolutePathRef shardPath, + absl::flat_hash_set &badJobIds) const { auto multiplyIndexed = this->planner.isMultiplyIndexed( RootRelativePathRef{relativePath, RootKind::Project}); bool isMultiplyIndexed; @@ -719,15 +721,7 @@ class Driver { if (auto optFileName = shardPath.fileName()) { if (auto optJobId = ShardPaths::tryParseJobId(*optFileName)) { auto jobId = optJobId.value(); - spdlog::info("the unknown header was encountered when processing " - "the compilation command at index {} in the " - "compilation database", - jobId); - spdlog::info( - "it may be possible to reproduce this issue by subsetting the " - "compilation database using `jq '.[{}:{}]` {} > bad.json` and " - "re-running `scip-clang --compdb-path=bad.json `", - jobId, jobId + 1, this->options.compdbPath.asStringRef()); + badJobIds.insert(jobId); } } // Be conservative here @@ -787,6 +781,8 @@ class Driver { return true; }; + absl::flat_hash_set badJobIds{}; + scip::IndexBuilder builder{fullIndex}; // TODO: Measure how much time this is taking and parallelize if too slow. for (auto &paths : this->shardPaths) { @@ -796,7 +792,7 @@ class Driver { } for (auto &doc : *indexShard.mutable_documents()) { bool isMultiplyIndexed = this->isMultiplyIndexedApproximate( - doc.relative_path(), paths.docsAndExternals.asRef()); + doc.relative_path(), paths.docsAndExternals.asRef(), badJobIds); builder.addDocument(std::move(doc), isMultiplyIndexed); } // See NOTE(ref: precondition-deterministic-ext-symbol-docs); in @@ -808,6 +804,21 @@ class Driver { } } + if (!badJobIds.empty()) { + std::vector badJobIdsSorted{badJobIds.begin(), badJobIds.end()}; + absl::c_sort(badJobIdsSorted); + spdlog::info("previously unseen headers were encountered when processing" + " the compilation commands at indexes [{}] in the " + "compilation database", + fmt::join(badJobIdsSorted, ",")); + spdlog::info( + "it may be possible to reproduce this issue by subsetting the " + "compilation database using `jq '[.[{}]]` {} > bad.json` and " + "re-running `scip-clang --compdb-path=bad.json `", + fmt::join(badJobIdsSorted, ","), + this->options.compdbPath.asStringRef()); + } + auto symbolToInfoMap = builder.populateSymbolToInfoMap(); for (auto &paths : this->shardPaths) {