| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_SERIALIZATION_H |
| 25 |
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_SERIALIZATION_H |
| 26 |
|
| 27 |
#include "Headers.h" |
| 28 |
#include "index/Index.h" |
| 29 |
#include "index/Symbol.h" |
| 30 |
#include "clang/Tooling/CompilationDatabase.h" |
| 31 |
#include "llvm/Support/Error.h" |
| 32 |
#include <optional> |
| 33 |
|
| 34 |
namespace clang { |
| 35 |
namespace clangd { |
| 36 |
|
| 37 |
enum class IndexFileFormat { |
| 38 |
RIFF, |
| 39 |
YAML, |
| 40 |
}; |
| 41 |
|
| 42 |
|
| 43 |
struct IndexFileIn { |
| 44 |
std::optional<SymbolSlab> Symbols; |
| 45 |
std::optional<RefSlab> Refs; |
| 46 |
std::optional<RelationSlab> Relations; |
| 47 |
|
| 48 |
std::optional<IncludeGraph> Sources; |
| 49 |
|
| 50 |
std::optional<tooling::CompileCommand> Cmd; |
| 51 |
}; |
| 52 |
|
| 53 |
llvm::Expected<IndexFileIn> readIndexFile(llvm::StringRef, SymbolOrigin); |
| 54 |
|
| 55 |
|
| 56 |
struct IndexFileOut { |
| 57 |
const SymbolSlab *Symbols = nullptr; |
| 58 |
const RefSlab *Refs = nullptr; |
| 59 |
const RelationSlab *Relations = nullptr; |
| 60 |
|
| 61 |
const IncludeGraph *Sources = nullptr; |
| 62 |
|
| 63 |
IndexFileFormat Format = IndexFileFormat::RIFF; |
| 64 |
const tooling::CompileCommand *Cmd = nullptr; |
| 65 |
|
| 66 |
IndexFileOut() = default; |
| 67 |
IndexFileOut(const IndexFileIn &I) |
| 68 |
: Symbols(I.Symbols ? &*I.Symbols : nullptr), |
| 69 |
Refs(I.Refs ? &*I.Refs : nullptr), |
| 70 |
Relations(I.Relations ? &*I.Relations : nullptr), |
| 71 |
Sources(I.Sources ? &*I.Sources : nullptr), |
| 72 |
Cmd(I.Cmd ? &*I.Cmd : nullptr) {} |
| 73 |
}; |
| 74 |
|
| 75 |
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const IndexFileOut &O); |
| 76 |
|
| 77 |
|
| 78 |
std::string toYAML(const Symbol &); |
| 79 |
std::string toYAML(const std::pair<SymbolID, ArrayRef<Ref>> &); |
| 80 |
std::string toYAML(const Relation &); |
| 81 |
std::string toYAML(const Ref &); |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
std::unique_ptr<SymbolIndex> loadIndex(llvm::StringRef Filename, |
| 86 |
SymbolOrigin Origin, bool UseDex = true); |
| 87 |
|
| 88 |
} |
| 89 |
} |
| 90 |
|
| 91 |
#endif |