• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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-exception
6 //
7 //===-----------------------------------------------------------------------===/
8 
9 #include "llvm/Support/MemoryBuffer.h"
10 #include "llvm/TextAPI/MachO/InterfaceFile.h"
11 #include <algorithm>
12 #include <string>
13 
14 #ifndef TEXT_STUB_HELPERS_H
15 #define TEXT_STUB_HELPERS_H
16 
17 namespace llvm {
18 struct ExportedSymbol {
19   llvm::MachO::SymbolKind Kind;
20   std::string Name;
21   bool WeakDefined;
22   bool ThreadLocalValue;
23 };
24 
25 using ExportedSymbolSeq = std::vector<ExportedSymbol>;
26 using UUIDs = std::vector<std::pair<llvm::MachO::Target, std::string>>;
27 using TBDFile = std::unique_ptr<MachO::InterfaceFile>;
28 using TBDReexportFile = std::shared_ptr<MachO::InterfaceFile>;
29 
30 inline bool operator<(const ExportedSymbol &LHS, const ExportedSymbol &RHS) {
31   return std::tie(LHS.Kind, LHS.Name) < std::tie(RHS.Kind, RHS.Name);
32 }
33 
34 inline bool operator==(const ExportedSymbol &LHS, const ExportedSymbol &RHS) {
35   return std::tie(LHS.Kind, LHS.Name, LHS.WeakDefined, LHS.ThreadLocalValue) ==
36          std::tie(RHS.Kind, RHS.Name, RHS.WeakDefined, RHS.ThreadLocalValue);
37 }
38 
stripWhitespace(std::string S)39 inline std::string stripWhitespace(std::string S) {
40   S.erase(std::remove_if(S.begin(), S.end(), ::isspace), S.end());
41   return S;
42 }
43 } // namespace llvm
44 #endif
45