clang
15.0.0git
lib
Basic
XRayInstr.cpp
Go to the documentation of this file.
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
XRayInstrMask
parseXRayInstrValue
(StringRef
Value
) {
20
XRayInstrMask
ParsedKind =
21
llvm::StringSwitch<XRayInstrMask>(
Value
)
22
.Case(
"all"
,
XRayInstrKind::All
)
23
.Case(
"custom"
,
XRayInstrKind::Custom
)
24
.Case(
"function"
,
25
XRayInstrKind::FunctionEntry
|
XRayInstrKind::FunctionExit
)
26
.Case(
"function-entry"
,
XRayInstrKind::FunctionEntry
)
27
.Case(
"function-exit"
,
XRayInstrKind::FunctionExit
)
28
.Case(
"typed"
,
XRayInstrKind::Typed
)
29
.Case(
"none"
,
XRayInstrKind::None
)
30
.Default(
XRayInstrKind::None
);
31
return
ParsedKind;
32
}
33
34
void
serializeXRayInstrValue
(
XRayInstrSet
Set,
35
SmallVectorImpl<StringRef>
&Values) {
36
if
(Set.
Mask
==
XRayInstrKind::All
) {
37
Values.push_back(
"all"
);
38
return
;
39
}
40
41
if
(Set.
Mask
==
XRayInstrKind::None
) {
42
Values.push_back(
"none"
);
43
return
;
44
}
45
46
if
(Set.
has
(
XRayInstrKind::Custom
))
47
Values.push_back(
"custom"
);
48
49
if
(Set.
has
(
XRayInstrKind::Typed
))
50
Values.push_back(
"typed"
);
51
52
if
(Set.
has
(
XRayInstrKind::FunctionEntry
) &&
53
Set.
has
(
XRayInstrKind::FunctionExit
))
54
Values.push_back(
"function"
);
55
else
if
(Set.
has
(
XRayInstrKind::FunctionEntry
))
56
Values.push_back(
"function-entry"
);
57
else
if
(Set.
has
(
XRayInstrKind::FunctionExit
))
58
Values.push_back(
"function-exit"
);
59
}
60
}
// namespace clang
clang::XRayInstrKind::FunctionEntry
constexpr XRayInstrMask FunctionEntry
Definition:
XRayInstr.h:39
clang::XRayInstrSet::Mask
XRayInstrMask Mask
Definition:
XRayInstr.h:65
clang::XRayInstrSet
Definition:
XRayInstr.h:47
clang::XRayInstrKind::All
constexpr XRayInstrMask All
Definition:
XRayInstr.h:43
clang::XRayInstrKind::None
constexpr XRayInstrMask None
Definition:
XRayInstr.h:38
clang::parseXRayInstrValue
XRayInstrMask parseXRayInstrValue(StringRef Value)
Parses a command line argument into a mask.
Definition:
XRayInstr.cpp:19
clang::XRayInstrKind::FunctionExit
constexpr XRayInstrMask FunctionExit
Definition:
XRayInstr.h:40
Value
Value
Definition:
UninitializedValues.cpp:102
clang::XRayInstrMask
uint32_t XRayInstrMask
Definition:
XRayInstr.h:25
clang::serializeXRayInstrValue
void serializeXRayInstrValue(XRayInstrSet Set, SmallVectorImpl< StringRef > &Values)
Serializes a set into a list of command line arguments.
Definition:
XRayInstr.cpp:34
clang
Definition:
CalledOnceCheck.h:17
clang::XRayInstrSet::has
bool has(XRayInstrMask K) const
Definition:
XRayInstr.h:48
XRayInstr.h
clang::XRayInstrKind::Custom
constexpr XRayInstrMask Custom
Definition:
XRayInstr.h:41
llvm::SmallVectorImpl
Definition:
Randstruct.h:18
clang::XRayInstrKind::Typed
constexpr XRayInstrMask Typed
Definition:
XRayInstr.h:42
Generated on Tue May 17 2022 09:32:58 for clang by
1.8.17