LCOV - code coverage report
Current view: top level - lib/DebugInfo/PDB/Native - InfoStreamBuilder.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 28 33 84.8 %
Date: 2017-09-14 15:23:50 Functions: 8 8 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/Native/InfoStreamBuilder.h"
      11             : 
      12             : #include "llvm/DebugInfo/MSF/MSFBuilder.h"
      13             : #include "llvm/DebugInfo/MSF/MappedBlockStream.h"
      14             : #include "llvm/DebugInfo/PDB/Native/InfoStream.h"
      15             : #include "llvm/DebugInfo/PDB/Native/NamedStreamMap.h"
      16             : #include "llvm/DebugInfo/PDB/Native/PDBFileBuilder.h"
      17             : #include "llvm/DebugInfo/PDB/Native/RawError.h"
      18             : #include "llvm/DebugInfo/PDB/Native/RawTypes.h"
      19             : #include "llvm/Support/BinaryStreamWriter.h"
      20             : 
      21             : using namespace llvm;
      22             : using namespace llvm::codeview;
      23             : using namespace llvm::msf;
      24             : using namespace llvm::pdb;
      25             : 
      26          60 : InfoStreamBuilder::InfoStreamBuilder(msf::MSFBuilder &Msf,
      27          60 :                                      NamedStreamMap &NamedStreams)
      28             :     : Msf(Msf), Ver(PdbRaw_ImplVer::PdbImplVC70), Sig(-1), Age(0),
      29         120 :       NamedStreams(NamedStreams) {}
      30             : 
      31          57 : void InfoStreamBuilder::setVersion(PdbRaw_ImplVer V) { Ver = V; }
      32             : 
      33          57 : void InfoStreamBuilder::setSignature(uint32_t S) { Sig = S; }
      34             : 
      35          57 : void InfoStreamBuilder::setAge(uint32_t A) { Age = A; }
      36             : 
      37          57 : void InfoStreamBuilder::setGuid(GUID G) { Guid = G; }
      38             : 
      39          31 : void InfoStreamBuilder::addFeature(PdbRaw_FeatureSig Sig) {
      40          31 :   Features.push_back(Sig);
      41          31 : }
      42             : 
      43          60 : Error InfoStreamBuilder::finalizeMsfLayout() {
      44         120 :   uint32_t Length = sizeof(InfoStreamHeader) + NamedStreams.finalize() +
      45         120 :                     (Features.size() + 1) * sizeof(uint32_t);
      46         180 :   if (auto EC = Msf.setStreamSize(StreamPDB, Length))
      47           0 :     return EC;
      48         180 :   return Error::success();
      49             : }
      50             : 
      51          60 : Error InfoStreamBuilder::commit(const msf::MSFLayout &Layout,
      52             :                                 WritableBinaryStreamRef Buffer) const {
      53             :   auto InfoS = WritableMappedBlockStream::createIndexedStream(
      54         240 :       Layout, Buffer, StreamPDB, Msf.getAllocator());
      55         120 :   BinaryStreamWriter Writer(*InfoS);
      56             : 
      57             :   InfoStreamHeader H;
      58         120 :   H.Age = Age;
      59         120 :   H.Signature = Sig;
      60         120 :   H.Version = Ver;
      61          60 :   H.Guid = Guid;
      62         180 :   if (auto EC = Writer.writeObject(H))
      63           0 :     return EC;
      64             : 
      65         180 :   if (auto EC = NamedStreams.commit(Writer))
      66           0 :     return EC;
      67         180 :   if (auto EC = Writer.writeInteger(0))
      68           0 :     return EC;
      69         271 :   for (auto E : Features) {
      70          93 :     if (auto EC = Writer.writeEnum(E))
      71           0 :       return EC;
      72             :   }
      73         180 :   return Error::success();
      74             : }

Generated by: LCOV version 1.13