From c86b984ea8ecb3e944dc3de48539f4c1f65851ea Mon Sep 17 00:00:00 2001 From: dim Date: Sun, 18 Jan 2015 16:23:48 +0000 Subject: Vendor import of clang RELEASE_360/rc1 tag r226102 (effectively, 3.6.0 RC1): https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_360/rc1@226102 --- lib/Serialization/GlobalModuleIndex.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'lib/Serialization/GlobalModuleIndex.cpp') diff --git a/lib/Serialization/GlobalModuleIndex.cpp b/lib/Serialization/GlobalModuleIndex.cpp index 9858122..4791388 100644 --- a/lib/Serialization/GlobalModuleIndex.cpp +++ b/lib/Serialization/GlobalModuleIndex.cpp @@ -122,11 +122,10 @@ typedef llvm::OnDiskIterableChainedHashTable } -GlobalModuleIndex::GlobalModuleIndex(llvm::MemoryBuffer *Buffer, +GlobalModuleIndex::GlobalModuleIndex(std::unique_ptr 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 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, -- cgit v1.1