191e5f4b4SKadir Cetinkaya //===--- BackgroundIndexLoader.h - Load shards from index storage-*- C++-*-===// 291e5f4b4SKadir Cetinkaya // 391e5f4b4SKadir Cetinkaya // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 491e5f4b4SKadir Cetinkaya // See https://llvm.org/LICENSE.txt for license information. 591e5f4b4SKadir Cetinkaya // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 691e5f4b4SKadir Cetinkaya // 791e5f4b4SKadir Cetinkaya //===----------------------------------------------------------------------===// 891e5f4b4SKadir Cetinkaya 9*5bd643d3SChristian Kühnel #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_BACKGROUNDINDEXLOADER_H 10*5bd643d3SChristian Kühnel #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_BACKGROUNDINDEXLOADER_H 1191e5f4b4SKadir Cetinkaya 1291e5f4b4SKadir Cetinkaya #include "index/Background.h" 13ad97ccf6SSam McCall #include "support/Path.h" 1491e5f4b4SKadir Cetinkaya #include "llvm/ADT/ArrayRef.h" 1591e5f4b4SKadir Cetinkaya #include <memory> 1691e5f4b4SKadir Cetinkaya #include <vector> 1791e5f4b4SKadir Cetinkaya 1891e5f4b4SKadir Cetinkaya namespace clang { 1991e5f4b4SKadir Cetinkaya namespace clangd { 2091e5f4b4SKadir Cetinkaya 2191e5f4b4SKadir Cetinkaya /// Represents a shard loaded from storage, stores contents in \p Shard and 2291e5f4b4SKadir Cetinkaya /// metadata about the source file that generated this shard. 2391e5f4b4SKadir Cetinkaya struct LoadedShard { 2491e5f4b4SKadir Cetinkaya /// Path of the source file that produced this shard. 2591e5f4b4SKadir Cetinkaya Path AbsolutePath; 2691e5f4b4SKadir Cetinkaya /// Digest of the source file contents that produced this shard. 2791e5f4b4SKadir Cetinkaya FileDigest Digest = {}; 2891e5f4b4SKadir Cetinkaya /// Whether the RefSlab in Shard should be used for updating symbol reference 2991e5f4b4SKadir Cetinkaya /// counts when building an index. 3091e5f4b4SKadir Cetinkaya bool CountReferences = false; 3191e5f4b4SKadir Cetinkaya /// Whether the indexing action producing that shard had errors. 3291e5f4b4SKadir Cetinkaya bool HadErrors = false; 3391e5f4b4SKadir Cetinkaya /// Path to a TU that is depending on this shard. 3491e5f4b4SKadir Cetinkaya Path DependentTU; 3591e5f4b4SKadir Cetinkaya /// Will be nullptr when index storage couldn't provide a valid shard for 3691e5f4b4SKadir Cetinkaya /// AbsolutePath. 3791e5f4b4SKadir Cetinkaya std::unique_ptr<IndexFileIn> Shard; 3891e5f4b4SKadir Cetinkaya }; 3991e5f4b4SKadir Cetinkaya 4091e5f4b4SKadir Cetinkaya /// Loads all shards for the TU \p MainFile from \p Storage. 4191e5f4b4SKadir Cetinkaya std::vector<LoadedShard> 4291e5f4b4SKadir Cetinkaya loadIndexShards(llvm::ArrayRef<Path> MainFiles, 4391e5f4b4SKadir Cetinkaya BackgroundIndexStorage::Factory &IndexStorageFactory, 4491e5f4b4SKadir Cetinkaya const GlobalCompilationDatabase &CDB); 4591e5f4b4SKadir Cetinkaya 4691e5f4b4SKadir Cetinkaya } // namespace clangd 4791e5f4b4SKadir Cetinkaya } // namespace clang 4891e5f4b4SKadir Cetinkaya 4991e5f4b4SKadir Cetinkaya #endif 50