Path: blob/main/contrib/llvm-project/clang/lib/Basic/XRayInstr.cpp
35234 views
//===--- XRayInstr.cpp ------------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This is part of XRay, a function call instrumentation system.9//10//===----------------------------------------------------------------------===//1112#include "clang/Basic/XRayInstr.h"13#include "llvm/ADT/SmallVector.h"14#include "llvm/ADT/StringSwitch.h"1516namespace clang {1718XRayInstrMask parseXRayInstrValue(StringRef Value) {19XRayInstrMask ParsedKind =20llvm::StringSwitch<XRayInstrMask>(Value)21.Case("all", XRayInstrKind::All)22.Case("custom", XRayInstrKind::Custom)23.Case("function",24XRayInstrKind::FunctionEntry | XRayInstrKind::FunctionExit)25.Case("function-entry", XRayInstrKind::FunctionEntry)26.Case("function-exit", XRayInstrKind::FunctionExit)27.Case("typed", XRayInstrKind::Typed)28.Case("none", XRayInstrKind::None)29.Default(XRayInstrKind::None);30return ParsedKind;31}3233void serializeXRayInstrValue(XRayInstrSet Set,34SmallVectorImpl<StringRef> &Values) {35if (Set.Mask == XRayInstrKind::All) {36Values.push_back("all");37return;38}3940if (Set.Mask == XRayInstrKind::None) {41Values.push_back("none");42return;43}4445if (Set.has(XRayInstrKind::Custom))46Values.push_back("custom");4748if (Set.has(XRayInstrKind::Typed))49Values.push_back("typed");5051if (Set.has(XRayInstrKind::FunctionEntry) &&52Set.has(XRayInstrKind::FunctionExit))53Values.push_back("function");54else if (Set.has(XRayInstrKind::FunctionEntry))55Values.push_back("function-entry");56else if (Set.has(XRayInstrKind::FunctionExit))57Values.push_back("function-exit");58}59} // namespace clang606162