Jonas Devlieghere | 5810ed5 | 2020-02-13 12:51:19 -0800 | [diff] [blame] | 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/TextAPI/MachO/InterfaceFile.h" |
| 10 | #include <algorithm> |
| 11 | #include <string> |
| 12 | |
| 13 | #ifndef TEXT_STUB_HELPERS_H |
| 14 | #define TEXT_STUB_HELPERS_H |
| 15 | |
| 16 | namespace llvm { |
| 17 | struct ExportedSymbol { |
| 18 | llvm::MachO::SymbolKind Kind; |
| 19 | std::string Name; |
| 20 | bool WeakDefined; |
| 21 | bool ThreadLocalValue; |
| 22 | }; |
| 23 | |
| 24 | using ExportedSymbolSeq = std::vector<ExportedSymbol>; |
| 25 | using UUIDs = std::vector<std::pair<llvm::MachO::Target, std::string>>; |
| 26 | |
| 27 | inline bool operator<(const ExportedSymbol &LHS, const ExportedSymbol &RHS) { |
| 28 | return std::tie(LHS.Kind, LHS.Name) < std::tie(RHS.Kind, RHS.Name); |
| 29 | } |
| 30 | |
| 31 | inline bool operator==(const ExportedSymbol &LHS, const ExportedSymbol &RHS) { |
| 32 | return std::tie(LHS.Kind, LHS.Name, LHS.WeakDefined, LHS.ThreadLocalValue) == |
| 33 | std::tie(RHS.Kind, RHS.Name, RHS.WeakDefined, RHS.ThreadLocalValue); |
| 34 | } |
| 35 | |
| 36 | inline std::string stripWhitespace(std::string S) { |
| 37 | S.erase(std::remove_if(S.begin(), S.end(), ::isspace), S.end()); |
| 38 | return S; |
| 39 | } |
| 40 | } // namespace llvm |
| 41 | #endif |