brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · 87ca7e1 Raw
65 lines · c
1//===-- TextStubHelpers.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-exception6//7//===-----------------------------------------------------------------------===/8 9#include "llvm/Support/MemoryBuffer.h"10#include "llvm/TextAPI/InterfaceFile.h"11#include <string>12 13#ifndef TEXT_STUB_HELPERS_H14#define TEXT_STUB_HELPERS_H15 16namespace llvm {17struct ExportedSymbol {18  MachO::EncodeKind Kind = MachO::EncodeKind::GlobalSymbol;19  std::string Name = {};20  bool Weak = false;21  bool ThreadLocalValue = false;22  bool isData = false;23  MachO::TargetList Targets = {};24};25 26using ExportedSymbolSeq = std::vector<ExportedSymbol>;27using TargetToAttr = std::vector<std::pair<llvm::MachO::Target, std::string>>;28using TBDFile = std::unique_ptr<MachO::InterfaceFile>;29using TBDReexportFile = std::shared_ptr<MachO::InterfaceFile>;30 31inline bool operator<(const ExportedSymbol &LHS, const ExportedSymbol &RHS) {32  return std::tie(LHS.Kind, LHS.Name) < std::tie(RHS.Kind, RHS.Name);33}34 35inline bool operator==(const ExportedSymbol &LHS, const ExportedSymbol &RHS) {36  return std::tie(LHS.Kind, LHS.Name, LHS.Weak, LHS.ThreadLocalValue) ==37         std::tie(RHS.Kind, RHS.Name, RHS.Weak, RHS.ThreadLocalValue);38}39 40inline std::string stripWhitespace(std::string S) {41  llvm::erase_if(S, ::isspace);42  return S;43}44 45// This will transform a single InterfaceFile then compare against the other46// InterfaceFile then transform the second InterfaceFile in the same way to47// regain equality.48inline bool49checkEqualityOnTransform(MachO::InterfaceFile &FileA,50                         MachO::InterfaceFile &FileB,51                         void (*Transform)(MachO::InterfaceFile *)) {52  Transform(&FileA);53  // Files should not be equal.54  if (FileA == FileB)55    return false;56  Transform(&FileB);57  // Files should be equal.58  if (FileA != FileB)59    return false;60  return true;61}62 63} // namespace llvm64#endif65