blob: 1f693475c9463afb8796ef9449c9c9783643aaa5 [file] [log] [blame]
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02001//===--- yaml2obj.h - -------------------------------------------*- C++ -*-===//
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/// \file
9/// Common declarations for yaml2obj
10//===----------------------------------------------------------------------===//
11#ifndef LLVM_TOOLS_YAML2OBJ_YAML2OBJ_H
12#define LLVM_TOOLS_YAML2OBJ_YAML2OBJ_H
13
14#include "llvm/ADT/STLExtras.h"
15#include <memory>
16
17namespace llvm {
18class raw_ostream;
19template <typename T> class SmallVectorImpl;
20class StringRef;
21class Twine;
22
23namespace object {
24class ObjectFile;
25}
26
27namespace COFFYAML {
28struct Object;
29}
30
31namespace ELFYAML {
32struct Object;
33}
34
35namespace MinidumpYAML {
36struct Object;
37}
38
39namespace WasmYAML {
40struct Object;
41}
42
43namespace ArchYAML {
44struct Archive;
45}
46
47namespace yaml {
48class Input;
49struct YamlObjectFile;
50
51using ErrorHandler = llvm::function_ref<void(const Twine &Msg)>;
52
53bool yaml2archive(ArchYAML::Archive &Doc, raw_ostream &Out, ErrorHandler EH);
54bool yaml2coff(COFFYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH);
55bool yaml2elf(ELFYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH,
56 uint64_t MaxSize);
57bool yaml2macho(YamlObjectFile &Doc, raw_ostream &Out, ErrorHandler EH);
58bool yaml2minidump(MinidumpYAML::Object &Doc, raw_ostream &Out,
59 ErrorHandler EH);
60bool yaml2wasm(WasmYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH);
61
62bool convertYAML(Input &YIn, raw_ostream &Out, ErrorHandler ErrHandler,
63 unsigned DocNum = 1, uint64_t MaxSize = UINT64_MAX);
64
65/// Convenience function for tests.
66std::unique_ptr<object::ObjectFile>
67yaml2ObjectFile(SmallVectorImpl<char> &Storage, StringRef Yaml,
68 ErrorHandler ErrHandler);
69
70} // namespace yaml
71} // namespace llvm
72
73#endif