1 //===- RemarkFormat.cpp --------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // Implementation of utilities to handle the different remark formats.
11 //===----------------------------------------------------------------------===//
13 #include "llvm/Remarks/RemarkFormat.h"
14 #include "llvm/ADT/StringSwitch.h"
17 using namespace llvm::remarks
;
19 Expected
<Format
> llvm::remarks::parseFormat(StringRef FormatStr
) {
20 auto Result
= StringSwitch
<Format
>(FormatStr
)
21 .Cases("", "yaml", Format::YAML
)
22 .Case("yaml-strtab", Format::YAMLStrTab
)
23 .Case("bitstream", Format::Bitstream
)
24 .Default(Format::Unknown
);
26 if (Result
== Format::Unknown
)
27 return createStringError(std::make_error_code(std::errc::invalid_argument
),
28 "Unknown remark format: '%s'",