diff options
Diffstat (limited to 'lib/Serialization/GlobalModuleIndex.cpp')
| -rw-r--r-- | lib/Serialization/GlobalModuleIndex.cpp | 25 | 
1 files changed, 13 insertions, 12 deletions
diff --git a/lib/Serialization/GlobalModuleIndex.cpp b/lib/Serialization/GlobalModuleIndex.cpp index 9858122325053..4791388045472 100644 --- a/lib/Serialization/GlobalModuleIndex.cpp +++ b/lib/Serialization/GlobalModuleIndex.cpp @@ -122,11 +122,10 @@ typedef llvm::OnDiskIterableChainedHashTable<IdentifierIndexReaderTrait>  } -GlobalModuleIndex::GlobalModuleIndex(llvm::MemoryBuffer *Buffer, +GlobalModuleIndex::GlobalModuleIndex(std::unique_ptr<llvm::MemoryBuffer> Buffer,                                       llvm::BitstreamCursor Cursor) -  : Buffer(Buffer), IdentifierIndex(), -    NumIdentifierLookups(), NumIdentifierLookupHits() -{ +    : Buffer(std::move(Buffer)), IdentifierIndex(), NumIdentifierLookups(), +      NumIdentifierLookupHits() {    // Read the global index.    bool InGlobalIndexBlock = false;    bool Done = false; @@ -260,7 +259,7 @@ GlobalModuleIndex::readIndex(StringRef Path) {      return std::make_pair(nullptr, EC_IOError);    } -  return std::make_pair(new GlobalModuleIndex(Buffer.release(), Cursor), +  return std::make_pair(new GlobalModuleIndex(std::move(Buffer), Cursor),                          EC_None);  } @@ -494,19 +493,17 @@ namespace {  bool GlobalModuleIndexBuilder::loadModuleFile(const FileEntry *File) {    // Open the module file. -  std::unique_ptr<llvm::MemoryBuffer> Buffer; -  std::string ErrorStr; -  Buffer.reset(FileMgr.getBufferForFile(File, &ErrorStr, /*isVolatile=*/true)); + +  auto Buffer = FileMgr.getBufferForFile(File, /*isVolatile=*/true);    if (!Buffer) {      return true;    }    // Initialize the input stream    llvm::BitstreamReader InStreamFile; -  llvm::BitstreamCursor InStream; -  InStreamFile.init((const unsigned char *)Buffer->getBufferStart(), -                  (const unsigned char *)Buffer->getBufferEnd()); -  InStream.init(InStreamFile); +  InStreamFile.init((const unsigned char *)(*Buffer)->getBufferStart(), +                    (const unsigned char *)(*Buffer)->getBufferEnd()); +  llvm::BitstreamCursor InStream(InStreamFile);    // Sniff for the signature.    if (InStream.Read(8) != 'C' || @@ -591,6 +588,10 @@ bool GlobalModuleIndexBuilder::loadModuleFile(const FileEntry *File) {          off_t StoredSize = (off_t)Record[Idx++];          time_t StoredModTime = (time_t)Record[Idx++]; +        // Skip the stored signature. +        // FIXME: we could read the signature out of the import and validate it. +        Idx++; +          // Retrieve the imported file name.          unsigned Length = Record[Idx++];          SmallString<128> ImportedFile(Record.begin() + Idx,  | 
