llvm/lib/DebugInfo/CodeView/ModuleSubstream.cpp
NAKAMURA Takumi 96678fa6d8 Revert r296215, "[PDB] General improvements to Stream library." and followings.
r296215, "[PDB] General improvements to Stream library."
r296217, "Disable BinaryStreamTest.StreamReaderObject temporarily."
r296220, "Re-enable BinaryStreamTest.StreamReaderObject."
r296244, "[PDB] Disable some tests that are breaking bots."
r296249, "Add static_cast to silence -Wc++11-narrowing."

std::errc::no_buffer_space should be used for OS-oriented errors for socket transmission.
(Seek discussions around llvm/xray.)

I could substitute s/no_buffer_space/others/g, but I revert whole them ATM.

Could we define and use LLVM errors there?

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296258 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-25 17:04:23 +00:00

46 lines
1.5 KiB
C++

//===- ModuleSubstream.cpp --------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "llvm/DebugInfo/CodeView/ModuleSubstream.h"
#include "llvm/DebugInfo/MSF/BinaryStreamReader.h"
using namespace llvm;
using namespace llvm::codeview;
using namespace llvm::msf;
ModuleSubstream::ModuleSubstream() : Kind(ModuleSubstreamKind::None) {}
ModuleSubstream::ModuleSubstream(ModuleSubstreamKind Kind,
ReadableStreamRef Data)
: Kind(Kind), Data(Data) {}
Error ModuleSubstream::initialize(ReadableStreamRef Stream,
ModuleSubstream &Info) {
const ModuleSubsectionHeader *Header;
StreamReader Reader(Stream);
if (auto EC = Reader.readObject(Header))
return EC;
ModuleSubstreamKind Kind =
static_cast<ModuleSubstreamKind>(uint32_t(Header->Kind));
if (auto EC = Reader.readStreamRef(Info.Data, Header->Length))
return EC;
Info.Kind = Kind;
return Error::success();
}
uint32_t ModuleSubstream::getRecordLength() const {
return sizeof(ModuleSubsectionHeader) + Data.getLength();
}
ModuleSubstreamKind ModuleSubstream::getSubstreamKind() const { return Kind; }
ReadableStreamRef ModuleSubstream::getRecordData() const { return Data; }