Coverage Report

Created: 2021-09-21 08:58

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Basic/XRayInstr.cpp
Line
Count
Source (jump to first uncovered line)
1
//===--- XRayInstr.cpp ------------------------------------------*- C++ -*-===//
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
// This is part of XRay, a function call instrumentation system.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "clang/Basic/XRayInstr.h"
14
#include "llvm/ADT/SmallVector.h"
15
#include "llvm/ADT/StringSwitch.h"
16
17
namespace clang {
18
19
43
XRayInstrMask parseXRayInstrValue(StringRef Value) {
20
43
  XRayInstrMask ParsedKind =
21
43
      llvm::StringSwitch<XRayInstrMask>(Value)
22
43
          .Case("all", XRayInstrKind::All)
23
43
          .Case("custom", XRayInstrKind::Custom)
24
43
          .Case("function",
25
43
                XRayInstrKind::FunctionEntry | XRayInstrKind::FunctionExit)
26
43
          .Case("function-entry", XRayInstrKind::FunctionEntry)
27
43
          .Case("function-exit", XRayInstrKind::FunctionExit)
28
43
          .Case("typed", XRayInstrKind::Typed)
29
43
          .Case("none", XRayInstrKind::None)
30
43
          .Default(XRayInstrKind::None);
31
43
  return ParsedKind;
32
43
}
33
34
void serializeXRayInstrValue(XRayInstrSet Set,
35
26
                             SmallVectorImpl<StringRef> &Values) {
36
26
  if (Set.Mask == XRayInstrKind::All) {
37
0
    Values.push_back("all");
38
0
    return;
39
0
  }
40
41
26
  if (Set.Mask == XRayInstrKind::None) {
42
2
    Values.push_back("none");
43
2
    return;
44
2
  }
45
46
24
  if (Set.has(XRayInstrKind::Custom))
47
6
    Values.push_back("custom");
48
49
24
  if (Set.has(XRayInstrKind::Typed))
50
6
    Values.push_back("typed");
51
52
24
  if (Set.has(XRayInstrKind::FunctionEntry) &&
53
24
      
Set.has(XRayInstrKind::FunctionExit)14
)
54
10
    Values.push_back("function");
55
14
  else if (Set.has(XRayInstrKind::FunctionEntry))
56
4
    Values.push_back("function-entry");
57
10
  else if (Set.has(XRayInstrKind::FunctionExit))
58
4
    Values.push_back("function-exit");
59
24
}
60
} // namespace clang