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 MachO::EncodeKind Kind
= MachO::EncodeKind::GlobalSymbol
;
20 std::string Name
= {};
22 bool ThreadLocalValue
= false;
24 MachO::TargetList Targets
= {};
27 using ExportedSymbolSeq
= std::vector
<ExportedSymbol
>;
28 using TargetToAttr
= std::vector
<std::pair
<llvm::MachO::Target
, std::string
>>;
29 using TBDFile
= std::unique_ptr
<MachO::InterfaceFile
>;
30 using TBDReexportFile
= std::shared_ptr
<MachO::InterfaceFile
>;
32 inline bool operator<(const ExportedSymbol
&LHS
, const ExportedSymbol
&RHS
) {
33 return std::tie(LHS
.Kind
, LHS
.Name
) < std::tie(RHS
.Kind
, RHS
.Name
);
36 inline bool operator==(const ExportedSymbol
&LHS
, const ExportedSymbol
&RHS
) {
37 return std::tie(LHS
.Kind
, LHS
.Name
, LHS
.Weak
, LHS
.ThreadLocalValue
) ==
38 std::tie(RHS
.Kind
, RHS
.Name
, RHS
.Weak
, RHS
.ThreadLocalValue
);
41 inline std::string
stripWhitespace(std::string S
) {
42 S
.erase(std::remove_if(S
.begin(), S
.end(), ::isspace
), S
.end());
46 // This will transform a single InterfaceFile then compare against the other
47 // InterfaceFile then transform the second InterfaceFile in the same way to
50 checkEqualityOnTransform(MachO::InterfaceFile
&FileA
,
51 MachO::InterfaceFile
&FileB
,
52 void (*Transform
)(MachO::InterfaceFile
*)) {
54 // Files should not be equal.
58 // Files should be equal.