LCOV - code coverage report
Current view: top level - lib/ObjectYAML - ObjectYAML.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 31 35 88.6 %
Date: 2017-09-14 15:23:50 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- ObjectYAML.cpp - YAML utilities for object files -------------------===//
       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             : // This file defines a wrapper class for handling tagged YAML input
      11             : //
      12             : //===----------------------------------------------------------------------===//
      13             : 
      14             : #include "llvm/ObjectYAML/ObjectYAML.h"
      15             : #include "llvm/ADT/Twine.h"
      16             : #include "llvm/Support/YAMLParser.h"
      17             : #include "llvm/Support/YAMLTraits.h"
      18             : #include <string>
      19             : 
      20             : using namespace llvm;
      21             : using namespace yaml;
      22             : 
      23         340 : void MappingTraits<YamlObjectFile>::mapping(IO &IO,
      24             :                                             YamlObjectFile &ObjectFile) {
      25         340 :   if (IO.outputting()) {
      26          60 :     if (ObjectFile.Elf)
      27           0 :       MappingTraits<ELFYAML::Object>::mapping(IO, *ObjectFile.Elf);
      28          60 :     if (ObjectFile.Coff)
      29           0 :       MappingTraits<COFFYAML::Object>::mapping(IO, *ObjectFile.Coff);
      30          60 :     if (ObjectFile.MachO)
      31          60 :       MappingTraits<MachOYAML::Object>::mapping(IO, *ObjectFile.MachO);
      32          60 :     if (ObjectFile.FatMachO)
      33           0 :       MappingTraits<MachOYAML::UniversalBinary>::mapping(IO,
      34           0 :                                                          *ObjectFile.FatMachO);
      35             :   } else {
      36         620 :     if (IO.mapTag("!ELF")) {
      37         246 :       ObjectFile.Elf.reset(new ELFYAML::Object());
      38         164 :       MappingTraits<ELFYAML::Object>::mapping(IO, *ObjectFile.Elf);
      39         456 :     } else if (IO.mapTag("!COFF")) {
      40         336 :       ObjectFile.Coff.reset(new COFFYAML::Object());
      41         336 :       MappingTraits<COFFYAML::Object>::mapping(IO, *ObjectFile.Coff);
      42         120 :     } else if (IO.mapTag("!mach-o")) {
      43          70 :       ObjectFile.MachO.reset(new MachOYAML::Object());
      44          70 :       MappingTraits<MachOYAML::Object>::mapping(IO, *ObjectFile.MachO);
      45          50 :     } else if (IO.mapTag("!fat-mach-o")) {
      46           3 :       ObjectFile.FatMachO.reset(new MachOYAML::UniversalBinary());
      47           1 :       MappingTraits<MachOYAML::UniversalBinary>::mapping(IO,
      48           2 :                                                          *ObjectFile.FatMachO);
      49          48 :     } else if (IO.mapTag("!WASM")) {
      50          66 :       ObjectFile.Wasm.reset(new WasmYAML::Object());
      51          44 :       MappingTraits<WasmYAML::Object>::mapping(IO, *ObjectFile.Wasm);
      52             :     } else {
      53           2 :       Input &In = (Input &)IO;
      54           6 :       std::string Tag = In.getCurrentNode()->getRawTag();
      55           2 :       if (Tag.empty())
      56           2 :         IO.setError("YAML Object File missing document type tag!");
      57             :       else
      58           1 :         IO.setError(
      59           3 :             Twine("YAML Object File unsupported document type tag '") +
      60           6 :             Twine(Tag) + Twine("'!"));
      61             :     }
      62             :   }
      63         340 : }

Generated by: LCOV version 1.13