Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Remarks/RemarkFormat.cpp
Line
Count
Source
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
13
#include "llvm/Remarks/RemarkFormat.h"
14
#include "llvm/ADT/StringSwitch.h"
15
16
using namespace llvm;
17
using namespace llvm::remarks;
18
19
92
Expected<Format> llvm::remarks::parseFormat(StringRef FormatStr) {
20
92
  auto Result = StringSwitch<Format>(FormatStr)
21
92
                    .Cases("", "yaml", Format::YAML)
22
92
                    .Cases("", "yaml-strtab", Format::YAMLStrTab)
23
92
                    .Default(Format::Unknown);
24
92
25
92
  if (Result == Format::Unknown)
26
1
    return createStringError(std::make_error_code(std::errc::invalid_argument),
27
1
                             "Unknown remark serializer format: '%s'",
28
1
                             FormatStr.data());
29
91
30
91
  return Result;
31
91
}