/src/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 | 0 | XRayInstrMask parseXRayInstrValue(StringRef Value) { |
20 | 0 | XRayInstrMask ParsedKind = |
21 | 0 | llvm::StringSwitch<XRayInstrMask>(Value) |
22 | 0 | .Case("all", XRayInstrKind::All) |
23 | 0 | .Case("custom", XRayInstrKind::Custom) |
24 | 0 | .Case("function", |
25 | 0 | XRayInstrKind::FunctionEntry | XRayInstrKind::FunctionExit) |
26 | 0 | .Case("function-entry", XRayInstrKind::FunctionEntry) |
27 | 0 | .Case("function-exit", XRayInstrKind::FunctionExit) |
28 | 0 | .Case("typed", XRayInstrKind::Typed) |
29 | 0 | .Case("none", XRayInstrKind::None) |
30 | 0 | .Default(XRayInstrKind::None); |
31 | 0 | return ParsedKind; |
32 | 0 | } |
33 | | |
34 | | void serializeXRayInstrValue(XRayInstrSet Set, |
35 | 0 | SmallVectorImpl<StringRef> &Values) { |
36 | 0 | if (Set.Mask == XRayInstrKind::All) { |
37 | 0 | Values.push_back("all"); |
38 | 0 | return; |
39 | 0 | } |
40 | | |
41 | 0 | if (Set.Mask == XRayInstrKind::None) { |
42 | 0 | Values.push_back("none"); |
43 | 0 | return; |
44 | 0 | } |
45 | | |
46 | 0 | if (Set.has(XRayInstrKind::Custom)) |
47 | 0 | Values.push_back("custom"); |
48 | |
|
49 | 0 | if (Set.has(XRayInstrKind::Typed)) |
50 | 0 | Values.push_back("typed"); |
51 | |
|
52 | 0 | if (Set.has(XRayInstrKind::FunctionEntry) && |
53 | 0 | Set.has(XRayInstrKind::FunctionExit)) |
54 | 0 | Values.push_back("function"); |
55 | 0 | else if (Set.has(XRayInstrKind::FunctionEntry)) |
56 | 0 | Values.push_back("function-entry"); |
57 | 0 | else if (Set.has(XRayInstrKind::FunctionExit)) |
58 | 0 | Values.push_back("function-exit"); |
59 | 0 | } |
60 | | } // namespace clang |