LLVM
20.0.0git
lib
ObjectYAML
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
13
#include "
llvm/ObjectYAML/ObjectYAML.h
"
14
#include "
llvm/ADT/Twine.h
"
15
#include "
llvm/Support/YAMLParser.h
"
16
#include "
llvm/Support/YAMLTraits.h
"
17
#include <string>
18
19
using namespace
llvm
;
20
using namespace
yaml;
21
22
void
MappingTraits<YamlObjectFile>::mapping
(IO &IO,
23
YamlObjectFile
&
ObjectFile
) {
24
if
(IO.outputting()) {
25
if
(
ObjectFile
.Elf)
26
MappingTraits<ELFYAML::Object>::mapping
(IO, *
ObjectFile
.Elf);
27
if
(
ObjectFile
.Coff)
28
MappingTraits<COFFYAML::Object>::mapping
(IO, *
ObjectFile
.Coff);
29
if
(
ObjectFile
.Goff)
30
MappingTraits<GOFFYAML::Object>::mapping
(IO, *
ObjectFile
.Goff);
31
if
(
ObjectFile
.MachO)
32
MappingTraits<MachOYAML::Object>::mapping
(IO, *
ObjectFile
.MachO);
33
if
(
ObjectFile
.FatMachO)
34
MappingTraits<MachOYAML::UniversalBinary>::mapping
(IO,
35
*
ObjectFile
.FatMachO);
36
}
else
{
37
Input &
In
= (Input &)IO;
38
if
(IO.mapTag(
"!Arch"
)) {
39
ObjectFile
.Arch.reset(
new
ArchYAML::Archive
());
40
MappingTraits<ArchYAML::Archive>::mapping
(IO, *
ObjectFile
.Arch);
41
std::string Err =
42
MappingTraits<ArchYAML::Archive>::validate
(IO, *
ObjectFile
.Arch);
43
if
(!Err.empty())
44
IO.setError(Err);
45
}
else
if
(IO.mapTag(
"!ELF"
)) {
46
ObjectFile
.Elf.reset(
new
ELFYAML::Object
());
47
MappingTraits<ELFYAML::Object>::mapping
(IO, *
ObjectFile
.Elf);
48
}
else
if
(IO.mapTag(
"!COFF"
)) {
49
ObjectFile
.Coff.reset(
new
COFFYAML::Object
());
50
MappingTraits<COFFYAML::Object>::mapping
(IO, *
ObjectFile
.Coff);
51
}
else
if
(IO.mapTag(
"!GOFF"
)) {
52
ObjectFile
.Goff.reset(
new
GOFFYAML::Object
());
53
MappingTraits<GOFFYAML::Object>::mapping
(IO, *
ObjectFile
.Goff);
54
}
else
if
(IO.mapTag(
"!mach-o"
)) {
55
ObjectFile
.MachO.reset(
new
MachOYAML::Object
());
56
MappingTraits<MachOYAML::Object>::mapping
(IO, *
ObjectFile
.MachO);
57
}
else
if
(IO.mapTag(
"!fat-mach-o"
)) {
58
ObjectFile
.FatMachO.reset(
new
MachOYAML::UniversalBinary
());
59
MappingTraits<MachOYAML::UniversalBinary>::mapping
(IO,
60
*
ObjectFile
.FatMachO);
61
}
else
if
(IO.mapTag(
"!minidump"
)) {
62
ObjectFile
.Minidump.reset(
new
MinidumpYAML::Object
());
63
MappingTraits<MinidumpYAML::Object>::mapping
(IO, *
ObjectFile
.Minidump);
64
}
else
if
(IO.mapTag(
"!Offload"
)) {
65
ObjectFile
.Offload.reset(
new
OffloadYAML::Binary
());
66
MappingTraits<OffloadYAML::Binary>::mapping
(IO, *
ObjectFile
.Offload);
67
}
else
if
(IO.mapTag(
"!WASM"
)) {
68
ObjectFile
.Wasm.reset(
new
WasmYAML::Object
());
69
MappingTraits<WasmYAML::Object>::mapping
(IO, *
ObjectFile
.Wasm);
70
}
else
if
(IO.mapTag(
"!XCOFF"
)) {
71
ObjectFile
.Xcoff.reset(
new
XCOFFYAML::Object
());
72
MappingTraits<XCOFFYAML::Object>::mapping
(IO, *
ObjectFile
.Xcoff);
73
}
else
if
(IO.mapTag(
"!dxcontainer"
)) {
74
ObjectFile
.DXContainer.reset(
new
DXContainerYAML::Object
());
75
MappingTraits<DXContainerYAML::Object>::mapping
(IO,
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
}
ObjectYAML.h
Twine.h
YAMLParser.h
YAMLTraits.h
Node
Definition:
ItaniumDemangle.h:163
llvm::object::ObjectFile
This class is the base class for all object file types.
Definition:
ObjectFile.h:229
llvm::tgtok::In
@ In
Definition:
TGLexer.h:84
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:
AddressRanges.h:18
N
#define N
llvm::ArchYAML::Archive
Definition:
ArchiveYAML.h:25
llvm::COFFYAML::Object
Definition:
COFFYAML.h:116
llvm::DXContainerYAML::Object
Definition:
DXContainerYAML.h:164
llvm::ELFYAML::Object
Definition:
ELFYAML.h:723
llvm::GOFFYAML::Object
Definition:
GOFFYAML.h:39
llvm::MachOYAML::Object
Definition:
MachOYAML.h:139
llvm::MachOYAML::UniversalBinary
Definition:
MachOYAML.h:163
llvm::MinidumpYAML::Object
The top level structure representing a minidump object, consisting of a minidump header,...
Definition:
MinidumpYAML.h:220
llvm::OffloadYAML::Binary
Definition:
OffloadYAML.h:26
llvm::WasmYAML::Object
Definition:
WasmYAML.h:417
llvm::XCOFFYAML::Object
Definition:
XCOFFYAML.h:213
llvm::yaml::MappingTraits
Definition:
ModuleSummaryIndex.h:54
llvm::yaml::YamlObjectFile
Definition:
ObjectYAML.h:30
Generated on Sat Dec 21 2024 23:13:03 for LLVM by
1.9.6