Address comments.
authorKadir Cetinkaya <kadircet@google.com>
Mon, 19 Nov 2018 18:06:36 +0000 (18:06 +0000)
committerKadir Cetinkaya <kadircet@google.com>
Mon, 19 Nov 2018 18:06:36 +0000 (18:06 +0000)
llvm-svn: 347237

clang-tools-extra/clangd/index/Serialization.cpp
clang-tools-extra/clangd/index/Serialization.h

index 958501d..a2a20e6 100644 (file)
@@ -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;
index a2ee51a..a7258f1 100644 (file)
@@ -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;