diff options
Diffstat (limited to 'lib/Frontend/SerializedDiagnosticReader.cpp')
-rw-r--r-- | lib/Frontend/SerializedDiagnosticReader.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/Frontend/SerializedDiagnosticReader.cpp b/lib/Frontend/SerializedDiagnosticReader.cpp index 0ebbd22af274..c4461d452e7b 100644 --- a/lib/Frontend/SerializedDiagnosticReader.cpp +++ b/lib/Frontend/SerializedDiagnosticReader.cpp @@ -11,7 +11,6 @@ #include "clang/Basic/FileManager.h" #include "clang/Frontend/SerializedDiagnostics.h" #include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/MemoryBuffer.h" using namespace clang; using namespace clang::serialized_diags; @@ -25,11 +24,8 @@ std::error_code SerializedDiagnosticReader::readDiagnostics(StringRef File) { if (!Buffer) return SDError::CouldNotLoad; - llvm::BitstreamReader StreamFile; - StreamFile.init((const unsigned char *)(*Buffer)->getBufferStart(), - (const unsigned char *)(*Buffer)->getBufferEnd()); - - llvm::BitstreamCursor Stream(StreamFile); + llvm::BitstreamCursor Stream(**Buffer); + Optional<llvm::BitstreamBlockInfo> BlockInfo; // Sniff for the signature. if (Stream.Read(8) != 'D' || @@ -45,10 +41,13 @@ std::error_code SerializedDiagnosticReader::readDiagnostics(StringRef File) { std::error_code EC; switch (Stream.ReadSubBlockID()) { - case llvm::bitc::BLOCKINFO_BLOCK_ID: - if (Stream.ReadBlockInfoBlock()) + case llvm::bitc::BLOCKINFO_BLOCK_ID: { + BlockInfo = Stream.ReadBlockInfoBlock(); + if (!BlockInfo) return SDError::MalformedBlockInfoBlock; + Stream.setBlockInfo(&*BlockInfo); continue; + } case BLOCK_META: if ((EC = readMetaBlock(Stream))) return EC; @@ -251,7 +250,7 @@ SerializedDiagnosticReader::readDiagnosticBlock(llvm::BitstreamCursor &Stream) { namespace { class SDErrorCategoryType final : public std::error_category { - const char *name() const LLVM_NOEXCEPT override { + const char *name() const noexcept override { return "clang.serialized_diags"; } std::string message(int IE) const override { |