--- /dev/null
+//===-- TextStubHelpers.cpp -------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===-----------------------------------------------------------------------===/
+
+#include "llvm/TextAPI/MachO/InterfaceFile.h"
+#include <algorithm>
+#include <string>
+
+#ifndef TEXT_STUB_HELPERS_H
+#define TEXT_STUB_HELPERS_H
+
+namespace llvm {
+struct ExportedSymbol {
+ llvm::MachO::SymbolKind Kind;
+ std::string Name;
+ bool WeakDefined;
+ bool ThreadLocalValue;
+};
+
+using ExportedSymbolSeq = std::vector<ExportedSymbol>;
+using UUIDs = std::vector<std::pair<llvm::MachO::Target, std::string>>;
+
+inline bool operator<(const ExportedSymbol &LHS, const ExportedSymbol &RHS) {
+ return std::tie(LHS.Kind, LHS.Name) < std::tie(RHS.Kind, RHS.Name);
+}
+
+inline bool operator==(const ExportedSymbol &LHS, const ExportedSymbol &RHS) {
+ return std::tie(LHS.Kind, LHS.Name, LHS.WeakDefined, LHS.ThreadLocalValue) ==
+ std::tie(RHS.Kind, RHS.Name, RHS.WeakDefined, RHS.ThreadLocalValue);
+}
+
+inline std::string stripWhitespace(std::string S) {
+ S.erase(std::remove_if(S.begin(), S.end(), ::isspace), S.end());
+ return S;
+}
+} // namespace llvm
+#endif
//
//===-----------------------------------------------------------------------===/
+#include "TextStubHelpers.h"
#include "llvm/TextAPI/MachO/InterfaceFile.h"
#include "llvm/TextAPI/MachO/TextAPIReader.h"
#include "llvm/TextAPI/MachO/TextAPIWriter.h"
using namespace llvm;
using namespace llvm::MachO;
-struct ExportedSymbol {
- SymbolKind Kind;
- std::string Name;
- bool WeakDefined;
- bool ThreadLocalValue;
-};
-using ExportedSymbolSeq = std::vector<ExportedSymbol>;
-
-inline bool operator<(const ExportedSymbol &lhs, const ExportedSymbol &rhs) {
- return std::tie(lhs.Kind, lhs.Name) < std::tie(rhs.Kind, rhs.Name);
-}
-
-inline bool operator==(const ExportedSymbol &lhs, const ExportedSymbol &rhs) {
- return std::tie(lhs.Kind, lhs.Name, lhs.WeakDefined, lhs.ThreadLocalValue) ==
- std::tie(rhs.Kind, rhs.Name, rhs.WeakDefined, rhs.ThreadLocalValue);
-}
-
static ExportedSymbol TBDv1Symbols[] = {
{SymbolKind::GlobalSymbol, "$ld$hide$os9.0$_sym1", false, false},
{SymbolKind::GlobalSymbol, "_sym1", false, false},
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===-----------------------------------------------------------------------===/
-
+#include "TextStubHelpers.h"
#include "llvm/TextAPI/MachO/InterfaceFile.h"
#include "llvm/TextAPI/MachO/TextAPIReader.h"
#include "llvm/TextAPI/MachO/TextAPIWriter.h"
using namespace llvm;
using namespace llvm::MachO;
-struct ExportedSymbol {
- SymbolKind Kind;
- std::string Name;
- bool WeakDefined;
- bool ThreadLocalValue;
-};
-using ExportedSymbolSeq = std::vector<ExportedSymbol>;
-
-inline bool operator<(const ExportedSymbol &lhs, const ExportedSymbol &rhs) {
- return std::tie(lhs.Kind, lhs.Name) < std::tie(rhs.Kind, rhs.Name);
-}
-
-inline bool operator==(const ExportedSymbol &lhs, const ExportedSymbol &rhs) {
- return std::tie(lhs.Kind, lhs.Name, lhs.WeakDefined, lhs.ThreadLocalValue) ==
- std::tie(rhs.Kind, rhs.Name, rhs.WeakDefined, rhs.ThreadLocalValue);
-}
-
static ExportedSymbol TBDv2Symbols[] = {
{SymbolKind::GlobalSymbol, "$ld$hide$os9.0$_sym1", false, false},
{SymbolKind::GlobalSymbol, "_sym1", false, false},
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===-----------------------------------------------------------------------===/
-
+#include "TextStubHelpers.h"
#include "llvm/TextAPI/MachO/InterfaceFile.h"
#include "llvm/TextAPI/MachO/TextAPIReader.h"
#include "llvm/TextAPI/MachO/TextAPIWriter.h"
using namespace llvm;
using namespace llvm::MachO;
-struct ExportedSymbol {
- SymbolKind Kind;
- std::string Name;
- bool WeakDefined;
- bool ThreadLocalValue;
-};
-using ExportedSymbolSeq = std::vector<ExportedSymbol>;
-using UUIDs = std::vector<std::pair<Target, std::string>>;
-
-inline bool operator<(const ExportedSymbol &lhs, const ExportedSymbol &rhs) {
- return std::tie(lhs.Kind, lhs.Name) < std::tie(rhs.Kind, rhs.Name);
-}
-
-inline bool operator==(const ExportedSymbol &lhs, const ExportedSymbol &rhs) {
- return std::tie(lhs.Kind, lhs.Name, lhs.WeakDefined, lhs.ThreadLocalValue) ==
- std::tie(rhs.Kind, rhs.Name, rhs.WeakDefined, rhs.ThreadLocalValue);
-}
-
-inline std::string stripWhitespace(std::string s) {
- s.erase(std::remove_if(s.begin(), s.end(), ::isspace), s.end());
- return s;
-}
-
static ExportedSymbol TBDv3Symbols[] = {
{SymbolKind::GlobalSymbol, "$ld$hide$os9.0$_sym1", false, false},
{SymbolKind::GlobalSymbol, "_sym1", false, false},
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===-----------------------------------------------------------------------===/
+
+#include "TextStubHelpers.h"
#include "llvm/TextAPI/MachO/InterfaceFile.h"
#include "llvm/TextAPI/MachO/TextAPIReader.h"
#include "llvm/TextAPI/MachO/TextAPIWriter.h"
using namespace llvm;
using namespace llvm::MachO;
-struct ExampleSymbol {
- SymbolKind Kind;
- std::string Name;
- bool WeakDefined;
- bool ThreadLocalValue;
-};
-using ExampleSymbolSeq = std::vector<ExampleSymbol>;
-using UUIDs = std::vector<std::pair<Target, std::string>>;
-
-inline bool operator<(const ExampleSymbol &LHS, const ExampleSymbol &RHS) {
- return std::tie(LHS.Kind, LHS.Name) < std::tie(RHS.Kind, RHS.Name);
-}
-
-inline bool operator==(const ExampleSymbol &LHS, const ExampleSymbol &RHS) {
- return std::tie(LHS.Kind, LHS.Name, LHS.WeakDefined, LHS.ThreadLocalValue) ==
- std::tie(RHS.Kind, RHS.Name, RHS.WeakDefined, RHS.ThreadLocalValue);
-}
-
-inline std::string stripWhitespace(std::string s) {
- s.erase(std::remove_if(s.begin(), s.end(), ::isspace), s.end());
- return s;
-}
-
-static ExampleSymbol TBDv4ExportedSymbols[] = {
+static ExportedSymbol TBDv4ExportedSymbols[] = {
{SymbolKind::GlobalSymbol, "_symA", false, false},
{SymbolKind::GlobalSymbol, "_symAB", false, false},
{SymbolKind::GlobalSymbol, "_symB", false, false},
};
-static ExampleSymbol TBDv4ReexportedSymbols[] = {
+static ExportedSymbol TBDv4ReexportedSymbols[] = {
{SymbolKind::GlobalSymbol, "_symC", false, false},
};
-static ExampleSymbol TBDv4UndefinedSymbols[] = {
+static ExportedSymbol TBDv4UndefinedSymbols[] = {
{SymbolKind::GlobalSymbol, "_symD", false, false},
};
EXPECT_EQ(1U, File->reexportedLibraries().size());
EXPECT_EQ(reexport, File->reexportedLibraries().front());
- ExampleSymbolSeq Exports, Reexports, Undefineds;
- ExampleSymbol temp;
+ ExportedSymbolSeq Exports, Reexports, Undefineds;
+ ExportedSymbol temp;
for (const auto *Sym : File->symbols()) {
- temp = ExampleSymbol{Sym->getKind(), std::string(Sym->getName()),
- Sym->isWeakDefined(), Sym->isThreadLocalValue()};
+ temp = ExportedSymbol{Sym->getKind(), std::string(Sym->getName()),
+ Sym->isWeakDefined(), Sym->isThreadLocalValue()};
EXPECT_FALSE(Sym->isWeakReferenced());
if (Sym->isUndefined())
Undefineds.emplace_back(std::move(temp));
llvm::sort(Reexports.begin(), Reexports.end());
llvm::sort(Undefineds.begin(), Undefineds.end());
- EXPECT_EQ(sizeof(TBDv4ExportedSymbols) / sizeof(ExampleSymbol),
+ EXPECT_EQ(sizeof(TBDv4ExportedSymbols) / sizeof(ExportedSymbol),
Exports.size());
- EXPECT_EQ(sizeof(TBDv4ReexportedSymbols) / sizeof(ExampleSymbol),
+ EXPECT_EQ(sizeof(TBDv4ReexportedSymbols) / sizeof(ExportedSymbol),
Reexports.size());
- EXPECT_EQ(sizeof(TBDv4UndefinedSymbols) / sizeof(ExampleSymbol),
+ EXPECT_EQ(sizeof(TBDv4UndefinedSymbols) / sizeof(ExportedSymbol),
Undefineds.size());
EXPECT_TRUE(std::equal(Exports.begin(), Exports.end(),
std::begin(TBDv4ExportedSymbols)));