1//===- ModuleSubstream.cpp --------------------------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10#include "llvm/DebugInfo/CodeView/ModuleSubstream.h" 11 12#include "llvm/DebugInfo/CodeView/StreamReader.h" 13 14using namespace llvm; 15using namespace llvm::codeview; 16 17ModuleSubstream::ModuleSubstream() : Kind(ModuleSubstreamKind::None) {} 18 19ModuleSubstream::ModuleSubstream(ModuleSubstreamKind Kind, StreamRef Data) 20 : Kind(Kind), Data(Data) {} 21 22Error ModuleSubstream::initialize(StreamRef Stream, ModuleSubstream &Info) { 23 const ModuleSubsectionHeader *Header; 24 StreamReader Reader(Stream); 25 if (auto EC = Reader.readObject(Header)) 26 return EC; 27 28 ModuleSubstreamKind Kind = 29 static_cast<ModuleSubstreamKind>(uint32_t(Header->Kind)); 30 if (auto EC = Reader.readStreamRef(Info.Data, Header->Length)) 31 return EC; 32 Info.Kind = Kind; 33 return Error::success(); 34} 35 36uint32_t ModuleSubstream::getRecordLength() const { 37 return sizeof(ModuleSubsectionHeader) + Data.getLength(); 38} 39 40ModuleSubstreamKind ModuleSubstream::getSubstreamKind() const { return Kind; } 41 42StreamRef ModuleSubstream::getRecordData() const { return Data; } 43