/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 | 41 | XRayInstrMask parseXRayInstrValue(StringRef Value) { |
20 | 41 | XRayInstrMask ParsedKind = |
21 | 41 | llvm::StringSwitch<XRayInstrMask>(Value) |
22 | 41 | .Case("all", XRayInstrKind::All) |
23 | 41 | .Case("custom", XRayInstrKind::Custom) |
24 | 41 | .Case("function", |
25 | 41 | XRayInstrKind::FunctionEntry | XRayInstrKind::FunctionExit) |
26 | 41 | .Case("function-entry", XRayInstrKind::FunctionEntry) |
27 | 41 | .Case("function-exit", XRayInstrKind::FunctionExit) |
28 | 41 | .Case("typed", XRayInstrKind::Typed) |
29 | 41 | .Case("none", XRayInstrKind::None) |
30 | 41 | .Default(XRayInstrKind::None); |
31 | 41 | return ParsedKind; |
32 | 41 | } |
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 |