LCOV - code coverage report
Current view: top level - lib/DebugInfo/CodeView - DebugCrossExSubsection.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 14 20 70.0 %
Date: 2017-09-14 15:23:50 Functions: 4 5 80.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- DebugCrossExSubsection.cpp -----------------------------------------===//
       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/DebugCrossExSubsection.h"
      11             : #include "llvm/DebugInfo/CodeView/CodeViewError.h"
      12             : #include "llvm/Support/BinaryStreamWriter.h"
      13             : #include "llvm/Support/Error.h"
      14             : #include <cstdint>
      15             : 
      16             : using namespace llvm;
      17             : using namespace llvm::codeview;
      18             : 
      19           2 : Error DebugCrossModuleExportsSubsectionRef::initialize(
      20             :     BinaryStreamReader Reader) {
      21           2 :   if (Reader.bytesRemaining() % sizeof(CrossModuleExport) != 0)
      22             :     return make_error<CodeViewError>(
      23             :         cv_error_code::corrupt_record,
      24           0 :         "Cross Scope Exports section is an invalid size!");
      25             : 
      26           2 :   uint32_t Size = Reader.bytesRemaining() / sizeof(CrossModuleExport);
      27           2 :   return Reader.readArray(References, Size);
      28             : }
      29             : 
      30           0 : Error DebugCrossModuleExportsSubsectionRef::initialize(BinaryStreamRef Stream) {
      31           0 :   BinaryStreamReader Reader(Stream);
      32           0 :   return initialize(Reader);
      33             : }
      34             : 
      35           4 : void DebugCrossModuleExportsSubsection::addMapping(uint32_t Local,
      36             :                                                    uint32_t Global) {
      37           4 :   Mappings[Local] = Global;
      38           4 : }
      39             : 
      40           6 : uint32_t DebugCrossModuleExportsSubsection::calculateSerializedSize() const {
      41          12 :   return Mappings.size() * sizeof(CrossModuleExport);
      42             : }
      43             : 
      44           2 : Error DebugCrossModuleExportsSubsection::commit(
      45             :     BinaryStreamWriter &Writer) const {
      46          10 :   for (const auto &M : Mappings) {
      47          12 :     if (auto EC = Writer.writeInteger(M.first))
      48           0 :       return EC;
      49          12 :     if (auto EC = Writer.writeInteger(M.second))
      50           0 :       return EC;
      51             :   }
      52           6 :   return Error::success();
      53             : }

Generated by: LCOV version 1.13