mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-18 18:42:46 +02:00
53daa4154e
llvm-svn: 366939
49 lines
1.9 KiB
C++
49 lines
1.9 KiB
C++
//===- RemarkSerializer.cpp -----------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file provides tools for serializing remarks.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/Remarks/RemarkSerializer.h"
|
|
#include "llvm/Remarks/YAMLRemarkSerializer.h"
|
|
|
|
using namespace llvm;
|
|
using namespace llvm::remarks;
|
|
|
|
Expected<std::unique_ptr<RemarkSerializer>>
|
|
remarks::createRemarkSerializer(Format RemarksFormat, raw_ostream &OS) {
|
|
switch (RemarksFormat) {
|
|
case Format::Unknown:
|
|
return createStringError(std::errc::invalid_argument,
|
|
"Unknown remark serializer format.");
|
|
case Format::YAML:
|
|
return llvm::make_unique<YAMLRemarkSerializer>(OS);
|
|
case Format::YAMLStrTab:
|
|
return llvm::make_unique<YAMLStrTabRemarkSerializer>(OS);
|
|
}
|
|
llvm_unreachable("Unknown remarks::Format enum");
|
|
}
|
|
|
|
Expected<std::unique_ptr<RemarkSerializer>>
|
|
remarks::createRemarkSerializer(Format RemarksFormat, raw_ostream &OS,
|
|
remarks::StringTable StrTab) {
|
|
switch (RemarksFormat) {
|
|
case Format::Unknown:
|
|
return createStringError(std::errc::invalid_argument,
|
|
"Unknown remark serializer format.");
|
|
case Format::YAML:
|
|
return createStringError(std::errc::invalid_argument,
|
|
"Unable to use a string table with the yaml "
|
|
"format. Use 'yaml-strtab' instead.");
|
|
case Format::YAMLStrTab:
|
|
return llvm::make_unique<YAMLStrTabRemarkSerializer>(OS, std::move(StrTab));
|
|
}
|
|
llvm_unreachable("Unknown remarks::Format enum");
|
|
}
|