llvm/lib/Remarks/RemarkFormat.cpp
Francis Visoiu Mistrih ce4ba232b0 [Remarks][NFC] Combine ParserFormat and SerializerFormat
It's useless to have both.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366216 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-16 15:24:59 +00:00

31 lines
1.1 KiB
C++

//===- RemarkFormat.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
//
//===----------------------------------------------------------------------===//
//
// Implementation of utilities to handle the different remark formats.
//
//===----------------------------------------------------------------------===//
#include "llvm/Remarks/RemarkFormat.h"
#include "llvm/ADT/StringSwitch.h"
using namespace llvm;
using namespace llvm::remarks;
Expected<Format> llvm::remarks::parseFormat(StringRef FormatStr) {
auto Result = StringSwitch<Format>(FormatStr)
.Cases("", "yaml", Format::YAML)
.Default(Format::Unknown);
if (Result == Format::Unknown)
return createStringError(std::make_error_code(std::errc::invalid_argument),
"Unknown remark serializer format: '%s'",
FormatStr.data());
return Result;
}