diff options
| -rw-r--r-- | clang-tools-extra/clangd/index/Serialization.cpp | 7 | ||||
| -rw-r--r-- | clang-tools-extra/clangd/index/Serialization.h | 5 |
2 files changed, 7 insertions, 5 deletions
diff --git a/clang-tools-extra/clangd/index/Serialization.cpp b/clang-tools-extra/clangd/index/Serialization.cpp index 958501de8b7..a2a20e64a96 100644 --- a/clang-tools-extra/clangd/index/Serialization.cpp +++ b/clang-tools-extra/clangd/index/Serialization.cpp @@ -331,6 +331,7 @@ std::pair<SymbolID, std::vector<Ref>> readRefs(Reader &Data, // A file is a RIFF chunk with type 'CdIx'. // It contains the sections: // - meta: version number +// - srcs: checksum of the source file // - stri: string table // - symb: symbols // - refs: references to symbols @@ -363,8 +364,8 @@ Expected<IndexFileIn> readRIFF(StringRef Data) { return Strings.takeError(); IndexFileIn Result; - if (Chunks.count("hash")) { - Reader Hash(Chunks.lookup("hash")); + if (Chunks.count("srcs")) { + Reader Hash(Chunks.lookup("srcs")); Result.Digest.emplace(); llvm::StringRef Digest = Hash.consume(Result.Digest->size()); std::copy(Digest.bytes_begin(), Digest.bytes_end(), Result.Digest->begin()); @@ -409,7 +410,7 @@ void writeRIFF(const IndexFileOut &Data, raw_ostream &OS) { if (Data.Digest) { llvm::StringRef Hash(reinterpret_cast<const char *>(Data.Digest->data()), Data.Digest->size()); - RIFF.Chunks.push_back({riff::fourCC("hash"), Hash}); + RIFF.Chunks.push_back({riff::fourCC("srcs"), Hash}); } StringTableOut Strings; diff --git a/clang-tools-extra/clangd/index/Serialization.h b/clang-tools-extra/clangd/index/Serialization.h index a2ee51a1e51..a7258f13510 100644 --- a/clang-tools-extra/clangd/index/Serialization.h +++ b/clang-tools-extra/clangd/index/Serialization.h @@ -37,10 +37,11 @@ enum class IndexFileFormat { // Holds the contents of an index file that was read. struct IndexFileIn { + using FileDigest = std::array<uint8_t, 20>; llvm::Optional<SymbolSlab> Symbols; llvm::Optional<RefSlab> Refs; // Digest of the source file that generated the contents. - llvm::Optional<std::array<uint8_t, 20>> Digest; + llvm::Optional<FileDigest> Digest; }; // Parse an index file. The input must be a RIFF or YAML file. llvm::Expected<IndexFileIn> readIndexFile(llvm::StringRef); @@ -50,7 +51,7 @@ struct IndexFileOut { const SymbolSlab *Symbols = nullptr; const RefSlab *Refs = nullptr; // Digest of the source file that generated the contents. - const std::array<uint8_t, 20> *Digest = nullptr; + const IndexFileIn::FileDigest *Digest = nullptr; // TODO: Support serializing Dex posting lists. IndexFileFormat Format = IndexFileFormat::RIFF; |

