clang-tools  10.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_BACKGROUND_INDEX_LOADER_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_BACKGROUND_INDEX_LOADER_H
11 
12 #include "Path.h"
13 #include "index/Background.h"
14 #include "llvm/ADT/ArrayRef.h"
15 #include "llvm/ADT/DenseMap.h"
16 #include "llvm/ADT/Optional.h"
17 #include "llvm/ADT/StringMap.h"
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/Support/VirtualFileSystem.h"
20 #include <memory>
21 #include <vector>
22 
23 namespace clang {
24 namespace clangd {
25 
26 /// Represents a shard loaded from storage, stores contents in \p Shard and
27 /// metadata about the source file that generated this shard.
28 struct LoadedShard {
29  /// Path of the source file that produced this shard.
31  /// Digest of the source file contents that produced this shard.
33  /// Whether the RefSlab in Shard should be used for updating symbol reference
34  /// counts when building an index.
35  bool CountReferences = false;
36  /// Whether the indexing action producing that shard had errors.
37  bool HadErrors = false;
38  /// Path to a TU that is depending on this shard.
40  /// Will be nullptr when index storage couldn't provide a valid shard for
41  /// AbsolutePath.
42  std::unique_ptr<IndexFileIn> Shard;
43 };
44 
45 /// Loads all shards for the TU \p MainFile from \p Storage.
46 std::vector<LoadedShard>
47 loadIndexShards(llvm::ArrayRef<Path> MainFiles,
48  BackgroundIndexStorage::Factory &IndexStorageFactory,
49  const GlobalCompilationDatabase &CDB);
50 
51 } // namespace clangd
52 } // namespace clang
53 
54 #endif
FileDigest Digest
Digest of the source file contents that produced this shard.
llvm::unique_function< BackgroundIndexStorage *(PathRef)> Factory
Definition: Background.h:56
Path DependentTU
Path to a TU that is depending on this shard.
std::array< uint8_t, 8 > FileDigest
Definition: SourceCode.h:38
Path AbsolutePath
Path of the source file that produced this shard.
bool CountReferences
Whether the RefSlab in Shard should be used for updating symbol reference counts when building an ind...
Provides compilation arguments used for parsing C and C++ files.
std::string Path
A typedef to represent a file path.
Definition: Path.h:20
std::vector< LoadedShard > loadIndexShards(llvm::ArrayRef< Path > MainFiles, BackgroundIndexStorage::Factory &IndexStorageFactory, const GlobalCompilationDatabase &CDB)
Loads all shards for the TU MainFile from Storage.
Represents a shard loaded from storage, stores contents in Shard and metadata about the source file t...
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
bool HadErrors
Whether the indexing action producing that shard had errors.
std::unique_ptr< IndexFileIn > Shard
Will be nullptr when index storage couldn&#39;t provide a valid shard for AbsolutePath.