clang-tools  16.0.0git
BackgroundIndexLoader.h
Go to the documentation of this file.
1 //===--- BackgroundIndexLoader.h - Load shards from index storage-*- C++-*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_BACKGROUNDINDEXLOADER_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_BACKGROUNDINDEXLOADER_H
11 
12 #include "index/Background.h"
13 #include "support/Path.h"
14 #include "llvm/ADT/ArrayRef.h"
15 #include <memory>
16 #include <vector>
17 
18 namespace clang {
19 namespace clangd {
20 
21 /// Represents a shard loaded from storage, stores contents in \p Shard and
22 /// metadata about the source file that generated this shard.
23 struct LoadedShard {
24  /// Path of the source file that produced this shard.
26  /// Digest of the source file contents that produced this shard.
28  /// Whether the RefSlab in Shard should be used for updating symbol reference
29  /// counts when building an index.
30  bool CountReferences = false;
31  /// Whether the indexing action producing that shard had errors.
32  bool HadErrors = false;
33  /// Path to a TU that is depending on this shard.
35  /// Will be nullptr when index storage couldn't provide a valid shard for
36  /// AbsolutePath.
37  std::unique_ptr<IndexFileIn> Shard;
38 };
39 
40 /// Loads all shards for the TU \p MainFile from \p Storage.
41 std::vector<LoadedShard>
42 loadIndexShards(llvm::ArrayRef<Path> MainFiles,
43  BackgroundIndexStorage::Factory &IndexStorageFactory,
44  const GlobalCompilationDatabase &CDB);
45 
46 } // namespace clangd
47 } // namespace clang
48 
49 #endif
clang::clangd::LoadedShard::Shard
std::unique_ptr< IndexFileIn > Shard
Will be nullptr when index storage couldn't provide a valid shard for AbsolutePath.
Definition: BackgroundIndexLoader.h:37
Background.h
clang::clangd::Path
std::string Path
A typedef to represent a file path.
Definition: Path.h:26
Path.h
clang::clangd::GlobalCompilationDatabase
Provides compilation arguments used for parsing C and C++ files.
Definition: GlobalCompilationDatabase.h:34
clang::clangd::loadIndexShards
std::vector< LoadedShard > loadIndexShards(llvm::ArrayRef< Path > MainFiles, BackgroundIndexStorage::Factory &IndexStorageFactory, const GlobalCompilationDatabase &CDB)
Loads all shards for the TU MainFile from Storage.
Definition: BackgroundIndexLoader.cpp:120
clang::clangd::LoadedShard::AbsolutePath
Path AbsolutePath
Path of the source file that produced this shard.
Definition: BackgroundIndexLoader.h:25
clang::clangd::LoadedShard::CountReferences
bool CountReferences
Whether the RefSlab in Shard should be used for updating symbol reference counts when building an ind...
Definition: BackgroundIndexLoader.h:30
clang::clangd::LoadedShard::HadErrors
bool HadErrors
Whether the indexing action producing that shard had errors.
Definition: BackgroundIndexLoader.h:32
clang::clangd::BackgroundIndexStorage::Factory
llvm::unique_function< BackgroundIndexStorage *(PathRef)> Factory
Definition: Background.h:57
clang::clangd::FileDigest
std::array< uint8_t, 8 > FileDigest
Definition: SourceCode.h:41
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
clang::clangd::LoadedShard::DependentTU
Path DependentTU
Path to a TU that is depending on this shard.
Definition: BackgroundIndexLoader.h:34
clang::clangd::LoadedShard
Represents a shard loaded from storage, stores contents in Shard and metadata about the source file t...
Definition: BackgroundIndexLoader.h:23
clang::clangd::LoadedShard::Digest
FileDigest Digest
Digest of the source file contents that produced this shard.
Definition: BackgroundIndexLoader.h:27