clang 19.0.0git
XRayInstr.h
Go to the documentation of this file.
1//===--- XRayInstr.h --------------------------------------------*- 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/// \file
10/// Defines the clang::XRayInstrKind enum.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_BASIC_XRAYINSTR_H
15#define LLVM_CLANG_BASIC_XRAYINSTR_H
16
17#include "clang/Basic/LLVM.h"
18#include "llvm/ADT/StringRef.h"
19#include "llvm/Support/MathExtras.h"
20#include <cassert>
21#include <cstdint>
22
23namespace clang {
24
25using XRayInstrMask = uint32_t;
26
27namespace XRayInstrKind {
28
29// TODO: Auto-generate these as we add more instrumentation kinds.
36};
37
38constexpr XRayInstrMask None = 0;
42constexpr XRayInstrMask Typed = 1U << XRIO_Typed;
44
45} // namespace XRayInstrKind
46
48 bool has(XRayInstrMask K) const {
49 assert(llvm::isPowerOf2_32(K));
50 return Mask & K;
51 }
52
53 bool hasOneOf(XRayInstrMask K) const { return Mask & K; }
54
55 void set(XRayInstrMask K, bool Value) {
56 Mask = Value ? (Mask | K) : (Mask & ~K);
57 }
58
60
61 bool empty() const { return Mask == 0; }
62
63 bool full() const { return Mask == XRayInstrKind::All; }
64
66};
67
68/// Parses a command line argument into a mask.
70
71/// Serializes a set into a list of command line arguments.
74
75} // namespace clang
76
77#endif // LLVM_CLANG_BASIC_XRAYINSTR_H
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
constexpr XRayInstrMask Typed
Definition: XRayInstr.h:42
constexpr XRayInstrMask FunctionExit
Definition: XRayInstr.h:40
constexpr XRayInstrMask None
Definition: XRayInstr.h:38
constexpr XRayInstrMask FunctionEntry
Definition: XRayInstr.h:39
constexpr XRayInstrMask All
Definition: XRayInstr.h:43
constexpr XRayInstrMask Custom
Definition: XRayInstr.h:41
The JSON file list parser is used to communicate input to InstallAPI.
uint32_t XRayInstrMask
Definition: XRayInstr.h:25
XRayInstrMask parseXRayInstrValue(StringRef Value)
Parses a command line argument into a mask.
Definition: XRayInstr.cpp:19
void serializeXRayInstrValue(XRayInstrSet Set, SmallVectorImpl< StringRef > &Values)
Serializes a set into a list of command line arguments.
Definition: XRayInstr.cpp:34
bool full() const
Definition: XRayInstr.h:63
XRayInstrMask Mask
Definition: XRayInstr.h:65
void set(XRayInstrMask K, bool Value)
Definition: XRayInstr.h:55
void clear(XRayInstrMask K=XRayInstrKind::All)
Definition: XRayInstr.h:59
bool hasOneOf(XRayInstrMask K) const
Definition: XRayInstr.h:53
bool has(XRayInstrMask K) const
Definition: XRayInstr.h:48
bool empty() const
Definition: XRayInstr.h:61