LLVM  9.0.0svn
ObjectYAML.cpp
Go to the documentation of this file.
1 //===- ObjectYAML.cpp - YAML utilities for object files -------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines a wrapper class for handling tagged YAML input
10 //
11 //===----------------------------------------------------------------------===//
12 
14 #include "llvm/ADT/Twine.h"
17 #include <string>
18 
19 using namespace llvm;
20 using namespace yaml;
21 
23  YamlObjectFile &ObjectFile) {
24  if (IO.outputting()) {
25  if (ObjectFile.Elf)
27  if (ObjectFile.Coff)
29  if (ObjectFile.MachO)
31  if (ObjectFile.FatMachO)
33  *ObjectFile.FatMachO);
34  } else {
35  Input &In = (Input &)IO;
36  if (IO.mapTag("!ELF")) {
37  ObjectFile.Elf.reset(new ELFYAML::Object());
39  } else if (IO.mapTag("!COFF")) {
40  ObjectFile.Coff.reset(new COFFYAML::Object());
42  } else if (IO.mapTag("!mach-o")) {
43  ObjectFile.MachO.reset(new MachOYAML::Object());
45  } else if (IO.mapTag("!fat-mach-o")) {
46  ObjectFile.FatMachO.reset(new MachOYAML::UniversalBinary());
48  *ObjectFile.FatMachO);
49  } else if (IO.mapTag("!minidump")) {
50  ObjectFile.Minidump.reset(new MinidumpYAML::Object());
52  } else if (IO.mapTag("!WASM")) {
53  ObjectFile.Wasm.reset(new WasmYAML::Object());
55  } else if (const Node *N = In.getCurrentNode()) {
56  if (N->getRawTag().empty())
57  IO.setError("YAML Object File missing document type tag!");
58  else
59  IO.setError("YAML Object File unsupported document type tag '" +
60  N->getRawTag() + "'!");
61  }
62  }
63 }
This class represents lattice values for constants.
Definition: AllocatorList.h:23
std::unique_ptr< COFFYAML::Object > Coff
Definition: ObjectYAML.h:27
The top level structure representing a minidump object, consisting of a minidump header, and zero or more streams.
Definition: MinidumpYAML.h:160
std::unique_ptr< MinidumpYAML::Object > Minidump
Definition: ObjectYAML.h:30
std::unique_ptr< MachOYAML::Object > MachO
Definition: ObjectYAML.h:28
std::unique_ptr< MachOYAML::UniversalBinary > FatMachO
Definition: ObjectYAML.h:29
std::unique_ptr< WasmYAML::Object > Wasm
Definition: ObjectYAML.h:31
#define N
std::unique_ptr< ELFYAML::Object > Elf
Definition: ObjectYAML.h:26
Abstract base class for all Nodes.
Definition: YAMLParser.h:113