[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / lib / Basic / XRayInstr.cpp
blob822e14bbb622dbb689feeabcb5f8280ebbd4933d
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.
11 //===----------------------------------------------------------------------===//
13 #include "clang/Basic/XRayInstr.h"
14 #include "llvm/ADT/SmallVector.h"
15 #include "llvm/ADT/StringSwitch.h"
17 namespace clang {
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;
34 void serializeXRayInstrValue(XRayInstrSet Set,
35 SmallVectorImpl<StringRef> &Values) {
36 if (Set.Mask == XRayInstrKind::All) {
37 Values.push_back("all");
38 return;
41 if (Set.Mask == XRayInstrKind::None) {
42 Values.push_back("none");
43 return;
46 if (Set.has(XRayInstrKind::Custom))
47 Values.push_back("custom");
49 if (Set.has(XRayInstrKind::Typed))
50 Values.push_back("typed");
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");
60 } // namespace clang