LLVM 19.0.0git
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
19using namespace llvm;
20using namespace yaml;
21
24 if (IO.outputting()) {
25 if (ObjectFile.Elf)
27 if (ObjectFile.Coff)
29 if (ObjectFile.Goff)
31 if (ObjectFile.MachO)
33 if (ObjectFile.FatMachO)
35 *ObjectFile.FatMachO);
36 } else {
37 Input &In = (Input &)IO;
38 if (IO.mapTag("!Arch")) {
39 ObjectFile.Arch.reset(new ArchYAML::Archive());
41 std::string Err =
43 if (!Err.empty())
44 IO.setError(Err);
45 } else if (IO.mapTag("!ELF")) {
46 ObjectFile.Elf.reset(new ELFYAML::Object());
48 } else if (IO.mapTag("!COFF")) {
49 ObjectFile.Coff.reset(new COFFYAML::Object());
51 } else if (IO.mapTag("!GOFF")) {
52 ObjectFile.Goff.reset(new GOFFYAML::Object());
54 } else if (IO.mapTag("!mach-o")) {
55 ObjectFile.MachO.reset(new MachOYAML::Object());
57 } else if (IO.mapTag("!fat-mach-o")) {
58 ObjectFile.FatMachO.reset(new MachOYAML::UniversalBinary());
60 *ObjectFile.FatMachO);
61 } else if (IO.mapTag("!minidump")) {
62 ObjectFile.Minidump.reset(new MinidumpYAML::Object());
64 } else if (IO.mapTag("!Offload")) {
65 ObjectFile.Offload.reset(new OffloadYAML::Binary());
67 } else if (IO.mapTag("!WASM")) {
68 ObjectFile.Wasm.reset(new WasmYAML::Object());
70 } else if (IO.mapTag("!XCOFF")) {
71 ObjectFile.Xcoff.reset(new XCOFFYAML::Object());
73 } else if (IO.mapTag("!dxcontainer")) {
74 ObjectFile.DXContainer.reset(new DXContainerYAML::Object());
76 *ObjectFile.DXContainer);
77 } else if (const Node *N = In.getCurrentNode()) {
78 if (N->getRawTag().empty())
79 IO.setError("YAML Object File missing document type tag!");
80 else
81 IO.setError("YAML Object File unsupported document type tag '" +
82 N->getRawTag() + "'!");
83 }
84 }
85}
This class is the base class for all object file types.
Definition: ObjectFile.h:229
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
#define N
The top level structure representing a minidump object, consisting of a minidump header,...
Definition: MinidumpYAML.h:201