1//===--- 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 yaml {
44class Input;
45struct YamlObjectFile;
46
47using ErrorHandler = llvm::function_ref<void(const Twine &Msg)>;
48
49bool yaml2coff(COFFYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH);
50bool yaml2elf(ELFYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH,
51              uint64_t MaxSize);
52bool yaml2macho(YamlObjectFile &Doc, raw_ostream &Out, ErrorHandler EH);
53bool yaml2minidump(MinidumpYAML::Object &Doc, raw_ostream &Out,
54                   ErrorHandler EH);
55bool yaml2wasm(WasmYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH);
56
57bool convertYAML(Input &YIn, raw_ostream &Out, ErrorHandler ErrHandler,
58                 unsigned DocNum = 1, uint64_t MaxSize = UINT64_MAX);
59
60/// Convenience function for tests.
61std::unique_ptr<object::ObjectFile>
62yaml2ObjectFile(SmallVectorImpl<char> &Storage, StringRef Yaml,
63                ErrorHandler ErrHandler);
64
65} // namespace yaml
66} // namespace llvm
67
68#endif
69