1 //===-- TextStubHelpers.cpp -------------------------------------*- C++ -*-===//
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
7 //===-----------------------------------------------------------------------===/
9 #include "llvm/Support/MemoryBuffer.h"
10 #include "llvm/TextAPI/InterfaceFile.h"
14 #ifndef TEXT_STUB_HELPERS_H
15 #define TEXT_STUB_HELPERS_H
18 struct ExportedSymbol
{
19 llvm::MachO::SymbolKind Kind
;
22 bool ThreadLocalValue
;
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
>;
30 inline bool operator<(const ExportedSymbol
&LHS
, const ExportedSymbol
&RHS
) {
31 return std::tie(LHS
.Kind
, LHS
.Name
) < std::tie(RHS
.Kind
, RHS
.Name
);
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
);
39 inline std::string
stripWhitespace(std::string S
) {
40 S
.erase(std::remove_if(S
.begin(), S
.end(), ::isspace
), S
.end());
44 // This will transform a single InterfaceFile then compare against the other
45 // InterfaceFile then transform the second InterfaceFile in the same way to
48 checkEqualityOnTransform(MachO::InterfaceFile
&FileA
,
49 MachO::InterfaceFile
&FileB
,
50 void (*Transform
)(MachO::InterfaceFile
*)) {
52 // Files should not be equal.
56 // Files should be equal.