From 02a93e9f489523afd3f5fcd4b359c7ab1985d9d2 Mon Sep 17 00:00:00 2001 From: Juergen Ributzka Date: Thu, 29 Nov 2018 02:28:58 +0000 Subject: [PATCH] [TextAPI] TBD Reader/Writer (bot fixes: take 2) Replace the tuple with a struct to work around an explicit constructor bug. llvm-svn: 347827 --- unittests/TextAPI/TextStubV1Tests.cpp | 19 +++++++++++++++---- unittests/TextAPI/TextStubV2Tests.cpp | 19 +++++++++++++++---- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/unittests/TextAPI/TextStubV1Tests.cpp b/unittests/TextAPI/TextStubV1Tests.cpp index 65e9c042fad..d68361d65af 100644 --- a/unittests/TextAPI/TextStubV1Tests.cpp +++ b/unittests/TextAPI/TextStubV1Tests.cpp @@ -16,11 +16,21 @@ using namespace llvm; using namespace llvm::MachO; -using ExportedSymbol = std::tuple; +struct ExportedSymbol { + SymbolKind Kind; + std::string Name; + bool WeakDefined; + bool ThreadLocalValue; +}; using ExportedSymbolSeq = std::vector; inline bool operator<(const ExportedSymbol &lhs, const ExportedSymbol &rhs) { - return std::get<1>(lhs) < std::get<1>(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[] = { @@ -100,8 +110,9 @@ TEST(TBDv1, ReadFile) { for (const auto *Sym : File->symbols()) { EXPECT_FALSE(Sym->isWeakReferenced()); EXPECT_FALSE(Sym->isUndefined()); - Exports.emplace_back(Sym->getKind(), Sym->getName(), Sym->isWeakDefined(), - Sym->isThreadLocalValue()); + Exports.emplace_back(ExportedSymbol{Sym->getKind(), Sym->getName(), + Sym->isWeakDefined(), + Sym->isThreadLocalValue()}); } llvm::sort(Exports.begin(), Exports.end()); diff --git a/unittests/TextAPI/TextStubV2Tests.cpp b/unittests/TextAPI/TextStubV2Tests.cpp index 79d6cac8938..62032422dd7 100644 --- a/unittests/TextAPI/TextStubV2Tests.cpp +++ b/unittests/TextAPI/TextStubV2Tests.cpp @@ -16,11 +16,21 @@ using namespace llvm; using namespace llvm::MachO; -using ExportedSymbol = std::tuple; +struct ExportedSymbol { + SymbolKind Kind; + std::string Name; + bool WeakDefined; + bool ThreadLocalValue; +}; using ExportedSymbolSeq = std::vector; inline bool operator<(const ExportedSymbol &lhs, const ExportedSymbol &rhs) { - return std::get<1>(lhs) < std::get<1>(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[] = { @@ -102,8 +112,9 @@ TEST(TBDv2, ReadFile) { for (const auto *Sym : File->symbols()) { EXPECT_FALSE(Sym->isWeakReferenced()); EXPECT_FALSE(Sym->isUndefined()); - Exports.emplace_back(Sym->getKind(), Sym->getName(), Sym->isWeakDefined(), - Sym->isThreadLocalValue()); + Exports.emplace_back(ExportedSymbol{Sym->getKind(), Sym->getName(), + Sym->isWeakDefined(), + Sym->isThreadLocalValue()}); } llvm::sort(Exports.begin(), Exports.end());