LLVM  15.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 
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("!Arch")) {
37  ObjectFile.Arch.reset(new ArchYAML::Archive());
39  std::string Err =
41  if (!Err.empty())
42  IO.setError(Err);
43  } else if (IO.mapTag("!ELF")) {
44  ObjectFile.Elf.reset(new ELFYAML::Object());
46  } else if (IO.mapTag("!COFF")) {
47  ObjectFile.Coff.reset(new COFFYAML::Object());
49  } else if (IO.mapTag("!mach-o")) {
50  ObjectFile.MachO.reset(new MachOYAML::Object());
52  } else if (IO.mapTag("!fat-mach-o")) {
53  ObjectFile.FatMachO.reset(new MachOYAML::UniversalBinary());
55  *ObjectFile.FatMachO);
56  } else if (IO.mapTag("!minidump")) {
57  ObjectFile.Minidump.reset(new MinidumpYAML::Object());
59  } else if (IO.mapTag("!Offload")) {
60  ObjectFile.Offload.reset(new OffloadYAML::Binary());
62  } else if (IO.mapTag("!WASM")) {
63  ObjectFile.Wasm.reset(new WasmYAML::Object());
65  } else if (IO.mapTag("!XCOFF")) {
66  ObjectFile.Xcoff.reset(new XCOFFYAML::Object());
68  } else if (IO.mapTag("!dxcontainer")) {
69  ObjectFile.DXContainer.reset(new DXContainerYAML::Object());
71  *ObjectFile.DXContainer);
72  } else if (const Node *N = In.getCurrentNode()) {
73  if (N->getRawTag().empty())
74  IO.setError("YAML Object File missing document type tag!");
75  else
76  IO.setError("YAML Object File unsupported document type tag '" +
77  N->getRawTag() + "'!");
78  }
79  }
80 }
llvm::SPIRV::StorageClass::Input
@ Input
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
ObjectYAML.h
llvm::MachOYAML::Object
Definition: MachOYAML.h:130
llvm::yaml::Node
Abstract base class for all Nodes.
Definition: YAMLParser.h:118
YAMLParser.h
llvm::MinidumpYAML::Object
The top level structure representing a minidump object, consisting of a minidump header,...
Definition: MinidumpYAML.h:201
llvm::yaml::YamlObjectFile
Definition: ObjectYAML.h:29
llvm::yaml::MappingTraits
Definition: ModuleSummaryIndex.h:51
llvm::RISCVFeatures::validate
void validate(const Triple &TT, const FeatureBitset &FeatureBits)
Definition: RISCVBaseInfo.cpp:97
Twine.h
llvm::MachOYAML::UniversalBinary
Definition: MachOYAML.h:154
llvm::COFFYAML::Object
Definition: COFFYAML.h:103
llvm::ELFYAML::Object
Definition: ELFYAML.h:694
llvm::tgtok::In
@ In
Definition: TGLexer.h:51
llvm::ArchYAML::Archive
Definition: ArchiveYAML.h:24
llvm::XCOFFYAML::Object
Definition: XCOFFYAML.h:208
llvm::codeview::CodeViewContainer::ObjectFile
@ ObjectFile
YAMLTraits.h
llvm::WasmYAML::Object
Definition: WasmYAML.h:416
llvm::DXContainerYAML::Object
Definition: DXContainerYAML.h:62
N
#define N
llvm::OffloadYAML::Binary
Definition: OffloadYAML.h:26