LLVM  10.0.0svn
RemarkFormat.cpp
Go to the documentation of this file.
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.
10 //
11 //===----------------------------------------------------------------------===//
12 
14 #include "llvm/ADT/StringSwitch.h"
15 
16 using namespace llvm;
17 using namespace llvm::remarks;
18 
20  auto Result = StringSwitch<Format>(FormatStr)
21  .Cases("", "yaml", Format::YAML)
22  .Case("yaml-strtab", Format::YAMLStrTab)
23  .Case("bitstream", Format::Bitstream)
25 
26  if (Result == Format::Unknown)
27  return createStringError(std::make_error_code(std::errc::invalid_argument),
28  "Unknown remark format: '%s'",
29  FormatStr.data());
30 
31  return Result;
32 }
This class represents lattice values for constants.
Definition: AllocatorList.h:23
StringSwitch & Case(StringLiteral S, T Value)
Definition: StringSwitch.h:67
LLVM_NODISCARD R Default(T Value)
Definition: StringSwitch.h:181
std::error_code make_error_code(BitcodeError E)
Expected< Format > parseFormat(StringRef FormatStr)
Parse and validate a string for the remark format.
Tagged union holding either a T or a Error.
Definition: yaml2obj.h:21
A switch()-like statement whose cases are string literals.
Definition: StringSwitch.h:42
LLVM_NODISCARD const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition: StringRef.h:136
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Definition: Error.h:1197