diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2016-11-08 04:17:11 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2016-11-08 04:17:11 +0000 |
commit | 77c89b6958f51a0b26c4849d37a200c1bc0319df (patch) | |
tree | 7ac81d7f4f32b81635db74539ad07fdbd1a6c535 /clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp | |
parent | 939c7d916e1631cf2a005b4ba6c03726ecbe0f85 (diff) | |
download | llvm-77c89b6958f51a0b26c4849d37a200c1bc0319df.zip llvm-77c89b6958f51a0b26c4849d37a200c1bc0319df.tar.gz llvm-77c89b6958f51a0b26c4849d37a200c1bc0319df.tar.bz2 |
Bitcode: Decouple block info block state from reader.
As proposed on llvm-dev:
http://lists.llvm.org/pipermail/llvm-dev/2016-October/106630.html
Move block info block state to a new class, BitstreamBlockInfo.
Clients may set the block info for a particular cursor with the
BitstreamCursor::setBlockInfo() method.
At this point BitstreamReader is not much more than a container for an
ArrayRef<uint8_t>, so remove it and replace all uses with direct uses
of memory buffers.
Differential Revision: https://reviews.llvm.org/D26259
llvm-svn: 286207
Diffstat (limited to 'clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp')
-rw-r--r-- | clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp index 42a97822..baf7811 100644 --- a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp +++ b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp @@ -312,8 +312,9 @@ ObjectFilePCHContainerWriter::CreatePCHContainerGenerator( CI, MainFileName, OutputFileName, std::move(OS), Buffer); } -void ObjectFilePCHContainerReader::ExtractPCH( - llvm::MemoryBufferRef Buffer, llvm::BitstreamReader &StreamFile) const { +StringRef +ObjectFilePCHContainerReader::ExtractPCH(llvm::MemoryBufferRef Buffer) const { + StringRef PCH; auto OFOrErr = llvm::object::ObjectFile::createObjectFile(Buffer); if (OFOrErr) { auto &OF = OFOrErr.get(); @@ -323,10 +324,8 @@ void ObjectFilePCHContainerReader::ExtractPCH( StringRef Name; Section.getName(Name); if ((!IsCOFF && Name == "__clangast") || (IsCOFF && Name == "clangast")) { - StringRef Buf; - Section.getContents(Buf); - StreamFile = llvm::BitstreamReader(Buf); - return; + Section.getContents(PCH); + return PCH; } } } @@ -334,8 +333,9 @@ void ObjectFilePCHContainerReader::ExtractPCH( if (EIB.convertToErrorCode() == llvm::object::object_error::invalid_file_type) // As a fallback, treat the buffer as a raw AST. - StreamFile = llvm::BitstreamReader(Buffer); + PCH = Buffer.getBuffer(); else EIB.log(llvm::errs()); }); + return PCH; } |