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/ADT/SmallString.h"
10 #include "llvm/Support/MemoryBuffer.h"
11 #include "llvm/TextAPI/InterfaceFile.h"
15 #ifndef TEXT_STUB_HELPERS_H
16 #define TEXT_STUB_HELPERS_H
19 struct ExportedSymbol
{
20 MachO::SymbolKind Kind
= MachO::SymbolKind::GlobalSymbol
;
21 std::string Name
= {};
23 bool ThreadLocalValue
= false;
25 MachO::TargetList Targets
= {};
28 using ExportedSymbolSeq
= std::vector
<ExportedSymbol
>;
29 using TargetToAttr
= std::vector
<std::pair
<llvm::MachO::Target
, std::string
>>;
30 using TBDFile
= std::unique_ptr
<MachO::InterfaceFile
>;
31 using TBDReexportFile
= std::shared_ptr
<MachO::InterfaceFile
>;
33 inline bool operator<(const ExportedSymbol
&LHS
, const ExportedSymbol
&RHS
) {
34 return std::tie(LHS
.Kind
, LHS
.Name
) < std::tie(RHS
.Kind
, RHS
.Name
);
37 inline bool operator==(const ExportedSymbol
&LHS
, const ExportedSymbol
&RHS
) {
38 return std::tie(LHS
.Kind
, LHS
.Name
, LHS
.Weak
, LHS
.ThreadLocalValue
) ==
39 std::tie(RHS
.Kind
, RHS
.Name
, RHS
.Weak
, RHS
.ThreadLocalValue
);
42 inline std::string
stripWhitespace(std::string S
) {
43 S
.erase(std::remove_if(S
.begin(), S
.end(), ::isspace
), S
.end());
47 // This will transform a single InterfaceFile then compare against the other
48 // InterfaceFile then transform the second InterfaceFile in the same way to
51 checkEqualityOnTransform(MachO::InterfaceFile
&FileA
,
52 MachO::InterfaceFile
&FileB
,
53 void (*Transform
)(MachO::InterfaceFile
*)) {
55 // Files should not be equal.
59 // Files should be equal.