diff options
Diffstat (limited to 'clang/lib/Serialization')
-rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 23 | ||||
-rw-r--r-- | clang/lib/Serialization/GlobalModuleIndex.cpp | 9 | ||||
-rw-r--r-- | clang/lib/Serialization/ModuleManager.cpp | 5 |
3 files changed, 13 insertions, 24 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 650c46e9ff0..5c875ee7319 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -1711,7 +1711,7 @@ void ASTReader::ReadDefinedMacros() { BitstreamCursor &MacroCursor = I->MacroCursor; // If there was no preprocessor block, skip this file. - if (!MacroCursor.getBitStreamReader()) + if (MacroCursor.getBitcodeBytes().empty()) continue; BitstreamCursor Cursor = MacroCursor; @@ -3798,7 +3798,7 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName, return Success; } -static ASTFileSignature readASTFileSignature(llvm::BitstreamReader &StreamFile); +static ASTFileSignature readASTFileSignature(StringRef PCH); /// \brief Whether \p Stream starts with the AST/PCH file magic number 'CPCH'. static bool startsWithASTFileMagic(BitstreamCursor &Stream) { @@ -3885,8 +3885,7 @@ ASTReader::ReadASTCore(StringRef FileName, ModuleFile &F = *M; BitstreamCursor &Stream = F.Stream; - PCHContainerRdr.ExtractPCH(F.Buffer->getMemBufferRef(), F.StreamFile); - Stream.init(&F.StreamFile); + Stream = BitstreamCursor(PCHContainerRdr.ExtractPCH(*F.Buffer)); F.SizeInBits = F.Buffer->getBufferSize() * 8; // Sniff for the signature. @@ -4175,10 +4174,10 @@ void ASTReader::finalizeForWriting() { // Nothing to do for now. } -/// \brief Reads and return the signature record from \p StreamFile's control -/// block, or else returns 0. -static ASTFileSignature readASTFileSignature(llvm::BitstreamReader &StreamFile){ - BitstreamCursor Stream(StreamFile); +/// \brief Reads and return the signature record from \p PCH's control block, or +/// else returns 0. +static ASTFileSignature readASTFileSignature(StringRef PCH) { + BitstreamCursor Stream(PCH); if (!startsWithASTFileMagic(Stream)) return 0; @@ -4216,9 +4215,7 @@ std::string ASTReader::getOriginalSourceFile( } // Initialize the stream - llvm::BitstreamReader StreamFile; - PCHContainerRdr.ExtractPCH((*Buffer)->getMemBufferRef(), StreamFile); - BitstreamCursor Stream(StreamFile); + BitstreamCursor Stream(PCHContainerRdr.ExtractPCH(**Buffer)); // Sniff for the signature. if (!startsWithASTFileMagic(Stream)) { @@ -4318,9 +4315,7 @@ bool ASTReader::readASTFileControlBlock( } // Initialize the stream - llvm::BitstreamReader StreamFile; - PCHContainerRdr.ExtractPCH((*Buffer)->getMemBufferRef(), StreamFile); - BitstreamCursor Stream(StreamFile); + BitstreamCursor Stream(PCHContainerRdr.ExtractPCH(**Buffer)); // Sniff for the signature. if (!startsWithASTFileMagic(Stream)) diff --git a/clang/lib/Serialization/GlobalModuleIndex.cpp b/clang/lib/Serialization/GlobalModuleIndex.cpp index e55ed40b227..9f986d54a98 100644 --- a/clang/lib/Serialization/GlobalModuleIndex.cpp +++ b/clang/lib/Serialization/GlobalModuleIndex.cpp @@ -245,11 +245,8 @@ GlobalModuleIndex::readIndex(StringRef Path) { return std::make_pair(nullptr, EC_NotFound); std::unique_ptr<llvm::MemoryBuffer> Buffer = std::move(BufferOrErr.get()); - /// \brief The bitstream reader from which we'll read the AST file. - llvm::BitstreamReader Reader(*Buffer); - /// \brief The main bitstream cursor for the main block. - llvm::BitstreamCursor Cursor(Reader); + llvm::BitstreamCursor Cursor(*Buffer); // Sniff for the signature. if (Cursor.Read(8) != 'B' || @@ -503,9 +500,7 @@ bool GlobalModuleIndexBuilder::loadModuleFile(const FileEntry *File) { } // Initialize the input stream - llvm::BitstreamReader InStreamFile; - PCHContainerRdr.ExtractPCH((*Buffer)->getMemBufferRef(), InStreamFile); - llvm::BitstreamCursor InStream(InStreamFile); + llvm::BitstreamCursor InStream(PCHContainerRdr.ExtractPCH(**Buffer)); // Sniff for the signature. if (InStream.Read(8) != 'C' || diff --git a/clang/lib/Serialization/ModuleManager.cpp b/clang/lib/Serialization/ModuleManager.cpp index 0a176f6fa80..e50dcaab2f6 100644 --- a/clang/lib/Serialization/ModuleManager.cpp +++ b/clang/lib/Serialization/ModuleManager.cpp @@ -135,15 +135,14 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type, } // Initialize the stream. - PCHContainerRdr.ExtractPCH(ModuleEntry->Buffer->getMemBufferRef(), - ModuleEntry->StreamFile); + ModuleEntry->Data = PCHContainerRdr.ExtractPCH(*ModuleEntry->Buffer); } if (ExpectedSignature) { // If we've not read the control block yet, read the signature eagerly now // so that we can check it. if (!ModuleEntry->Signature) - ModuleEntry->Signature = ReadSignature(ModuleEntry->StreamFile); + ModuleEntry->Signature = ReadSignature(ModuleEntry->Data); if (ModuleEntry->Signature != ExpectedSignature) { ErrorStr = ModuleEntry->Signature ? "signature mismatch" |