summaryrefslogtreecommitdiff
path: root/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2016-11-02 00:08:19 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2016-11-02 00:08:19 +0000
commit202d09ece44fd6b8dd1c15195920c4746bbce237 (patch)
tree30d5007a04000da419e8d4ad9c1c83cbfbff147d /lib/CodeGen/ObjectFilePCHContainerOperations.cpp
parent153d45226d1ee6f028089deb92f16f530fe6fb52 (diff)
downloadclang-202d09ece44fd6b8dd1c15195920c4746bbce237.tar.gz
Bitcode: Change reader interface to take memory buffers.
As proposed on llvm-dev: http://lists.llvm.org/pipermail/llvm-dev/2016-October/106595.html This change also fixes an API oddity where BitstreamCursor::Read() would return zero for the first read past the end of the bitstream, but would report_fatal_error for subsequent reads. Now we always report_fatal_error for all reads past the end. Updated clients to check for the end of the bitstream before reading from it. I also needed to add padding to the invalid bitcode tests in test/Bitcode/. This is because the streaming interface was not checking that the file size is a multiple of 4. Differential Revision: https://reviews.llvm.org/D26219 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@285773 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/ObjectFilePCHContainerOperations.cpp')
-rw-r--r--lib/CodeGen/ObjectFilePCHContainerOperations.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/CodeGen/ObjectFilePCHContainerOperations.cpp b/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
index f2090f9583..42a9782219 100644
--- a/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
+++ b/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
@@ -325,8 +325,8 @@ void ObjectFilePCHContainerReader::ExtractPCH(
if ((!IsCOFF && Name == "__clangast") || (IsCOFF && Name == "clangast")) {
StringRef Buf;
Section.getContents(Buf);
- return StreamFile.init((const unsigned char *)Buf.begin(),
- (const unsigned char *)Buf.end());
+ StreamFile = llvm::BitstreamReader(Buf);
+ return;
}
}
}
@@ -334,8 +334,7 @@ void ObjectFilePCHContainerReader::ExtractPCH(
if (EIB.convertToErrorCode() ==
llvm::object::object_error::invalid_file_type)
// As a fallback, treat the buffer as a raw AST.
- StreamFile.init((const unsigned char *)Buffer.getBufferStart(),
- (const unsigned char *)Buffer.getBufferEnd());
+ StreamFile = llvm::BitstreamReader(Buffer);
else
EIB.log(llvm::errs());
});