LCOV - code coverage report
Current view: top level - lib/DebugInfo/PDB/Raw - InfoStreamBuilder.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 21 23 91.3 %
Date: 2017-01-24 23:09:07 Functions: 7 7 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- InfoStreamBuilder.cpp - PDB Info Stream Creation ---------*- 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/PDB/Raw/InfoStreamBuilder.h"
      11             : 
      12             : #include "llvm/DebugInfo/MSF/MSFBuilder.h"
      13             : #include "llvm/DebugInfo/MSF/MappedBlockStream.h"
      14             : #include "llvm/DebugInfo/MSF/StreamWriter.h"
      15             : #include "llvm/DebugInfo/PDB/Raw/InfoStream.h"
      16             : #include "llvm/DebugInfo/PDB/Raw/NamedStreamMap.h"
      17             : #include "llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h"
      18             : #include "llvm/DebugInfo/PDB/Raw/RawError.h"
      19             : #include "llvm/DebugInfo/PDB/Raw/RawTypes.h"
      20             : 
      21             : using namespace llvm;
      22             : using namespace llvm::codeview;
      23             : using namespace llvm::msf;
      24             : using namespace llvm::pdb;
      25             : 
      26           4 : InfoStreamBuilder::InfoStreamBuilder(msf::MSFBuilder &Msf,
      27           4 :                                      NamedStreamMap &NamedStreams)
      28             :     : Msf(Msf), Ver(PdbRaw_ImplVer::PdbImplVC70), Sig(-1), Age(0),
      29           4 :       NamedStreams(NamedStreams) {}
      30             : 
      31           4 : void InfoStreamBuilder::setVersion(PdbRaw_ImplVer V) { Ver = V; }
      32             : 
      33           4 : void InfoStreamBuilder::setSignature(uint32_t S) { Sig = S; }
      34             : 
      35           4 : void InfoStreamBuilder::setAge(uint32_t A) { Age = A; }
      36             : 
      37           4 : void InfoStreamBuilder::setGuid(PDB_UniqueId G) { Guid = G; }
      38             : 
      39           4 : Error InfoStreamBuilder::finalizeMsfLayout() {
      40           4 :   uint32_t Length = sizeof(InfoStreamHeader) + NamedStreams.finalize();
      41          12 :   if (auto EC = Msf.setStreamSize(StreamPDB, Length))
      42           0 :     return EC;
      43          12 :   return Error::success();
      44             : }
      45             : 
      46           4 : Error InfoStreamBuilder::commit(const msf::MSFLayout &Layout,
      47             :                                 const msf::WritableStream &Buffer) const {
      48             :   auto InfoS =
      49           8 :       WritableMappedBlockStream::createIndexedStream(Layout, Buffer, StreamPDB);
      50           8 :   StreamWriter Writer(*InfoS);
      51             : 
      52           4 :   InfoStreamHeader H;
      53           8 :   H.Age = Age;
      54           8 :   H.Signature = Sig;
      55           8 :   H.Version = Ver;
      56           4 :   H.Guid = Guid;
      57          12 :   if (auto EC = Writer.writeObject(H))
      58           0 :     return EC;
      59             : 
      60           4 :   return NamedStreams.commit(Writer);
      61             : }

Generated by: LCOV version 1.13