Path: blob/main/contrib/llvm-project/llvm/lib/ObjectYAML/ArchiveEmitter.cpp
35233 views
//===- ArchiveEmitter.cpp ---------------------------- --------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "llvm/ObjectYAML/ArchiveYAML.h"9#include "llvm/ObjectYAML/yaml2obj.h"10#include "llvm/Support/Error.h"11#include "llvm/Support/raw_ostream.h"1213using namespace llvm;14using namespace ArchYAML;1516namespace llvm {17namespace yaml {1819bool yaml2archive(ArchYAML::Archive &Doc, raw_ostream &Out, ErrorHandler EH) {20Out.write(Doc.Magic.data(), Doc.Magic.size());2122if (Doc.Content) {23Doc.Content->writeAsBinary(Out);24return true;25}2627if (!Doc.Members)28return true;2930auto WriteField = [&](StringRef Field, uint8_t Size) {31Out.write(Field.data(), Field.size());32for (size_t I = Field.size(); I != Size; ++I)33Out.write(' ');34};3536for (const Archive::Child &C : *Doc.Members) {37for (auto &P : C.Fields)38WriteField(P.second.Value, P.second.MaxLength);3940if (C.Content)41C.Content->writeAsBinary(Out);42if (C.PaddingByte)43Out.write(*C.PaddingByte);44}4546return true;47}4849} // namespace yaml50} // namespace llvm515253