[ASan] Make insertion of version mismatch guard configurable
[llvm-core.git] / lib / Remarks / RemarkFormat.cpp
blobf2d0331ec6a83a0fbbcc7ce0fe93d99114dc559c
1 //===- RemarkFormat.cpp --------------------------------------------------===//
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 //
9 // Implementation of utilities to handle the different remark formats.
11 //===----------------------------------------------------------------------===//
13 #include "llvm/Remarks/RemarkFormat.h"
14 #include "llvm/ADT/StringSwitch.h"
16 using namespace llvm;
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'",
29 FormatStr.data());
31 return Result;