• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
14 using namespace llvm;
15 using namespace llvm::codeview;
16 
ModuleSubstream()17 ModuleSubstream::ModuleSubstream() : Kind(ModuleSubstreamKind::None) {}
18 
ModuleSubstream(ModuleSubstreamKind Kind,StreamRef Data)19 ModuleSubstream::ModuleSubstream(ModuleSubstreamKind Kind, StreamRef Data)
20     : Kind(Kind), Data(Data) {}
21 
initialize(StreamRef Stream,ModuleSubstream & Info)22 Error 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 
getRecordLength() const36 uint32_t ModuleSubstream::getRecordLength() const {
37   return sizeof(ModuleSubsectionHeader) + Data.getLength();
38 }
39 
getSubstreamKind() const40 ModuleSubstreamKind ModuleSubstream::getSubstreamKind() const { return Kind; }
41 
getRecordData() const42 StreamRef ModuleSubstream::getRecordData() const { return Data; }
43