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