summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ExecutionEngine/Orc/LegacyAPIInteropTest.cpp
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2018-01-25 01:43:00 +0000
committerLang Hames <lhames@gmail.com>2018-01-25 01:43:00 +0000
commitc8a74a04489f9cb8d3c40a0455a88b8900185e9e (patch)
tree6d89cca4b92ec7d5f972a6b1f7de3c4295297d26 /llvm/unittests/ExecutionEngine/Orc/LegacyAPIInteropTest.cpp
parenta674a8fd1e1a9db00bb0d43b656b17cf3615601c (diff)
downloadbcm5719-llvm-c8a74a04489f9cb8d3c40a0455a88b8900185e9e.tar.gz
bcm5719-llvm-c8a74a04489f9cb8d3c40a0455a88b8900185e9e.zip
[ORC] Refactor the various lookupFlags methods to return the flags map via the
first argument. This makes lookupFlags more consistent with lookup (which takes the query as the first argument) and composes better in practice, since lookups are usually linearly chained: Each lookupFlags can populate the result map based on the symbols not found in the previous lookup. (If the maps were returned rather than passed by reference there would have to be a merge step at the end). llvm-svn: 323398
Diffstat (limited to 'llvm/unittests/ExecutionEngine/Orc/LegacyAPIInteropTest.cpp')
-rw-r--r--llvm/unittests/ExecutionEngine/Orc/LegacyAPIInteropTest.cpp35
1 files changed, 20 insertions, 15 deletions
diff --git a/llvm/unittests/ExecutionEngine/Orc/LegacyAPIInteropTest.cpp b/llvm/unittests/ExecutionEngine/Orc/LegacyAPIInteropTest.cpp
index 963ce9f50ad..19c194bd166 100644
--- a/llvm/unittests/ExecutionEngine/Orc/LegacyAPIInteropTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/LegacyAPIInteropTest.cpp
@@ -16,15 +16,17 @@ using namespace llvm::orc;
class SimpleORCResolver : public SymbolResolver {
public:
- using LookupFlagsFn = std::function<LookupFlagsResult(const SymbolNameSet &)>;
+ using LookupFlagsFn = std::function<SymbolNameSet(SymbolFlagsMap &SymbolFlags,
+ const SymbolNameSet &)>;
using LookupFn = std::function<SymbolNameSet(AsynchronousSymbolQuery &Q,
SymbolNameSet Symbols)>;
SimpleORCResolver(LookupFlagsFn LookupFlags, LookupFn Lookup)
: LookupFlags(std::move(LookupFlags)), Lookup(std::move(Lookup)) {}
- LookupFlagsResult lookupFlags(const SymbolNameSet &Symbols) override {
- return LookupFlags(Symbols);
+ SymbolNameSet lookupFlags(SymbolFlagsMap &SymbolFlags,
+ const SymbolNameSet &Symbols) override {
+ return LookupFlags(SymbolFlags, Symbols);
}
SymbolNameSet lookup(AsynchronousSymbolQuery &Query,
@@ -51,8 +53,9 @@ TEST(LegacyAPIInteropTest, QueryAgainstVSO) {
Defs[Foo] = FooSym;
cantFail(V.define(std::move(Defs)));
- auto LookupFlags = [&](const SymbolNameSet &Names) {
- return V.lookupFlags(Names);
+ auto LookupFlags = [&](SymbolFlagsMap &SymbolFlags,
+ const SymbolNameSet &Names) {
+ return V.lookupFlags(SymbolFlags, Names);
};
auto Lookup = [&](AsynchronousSymbolQuery &Query, SymbolNameSet Symbols) {
@@ -119,16 +122,18 @@ TEST(LegacyAPIInteropTset, LegacyLookupHelpersFn) {
SymbolNameSet Symbols({Foo, Bar, Baz});
- auto LFR = lookupFlagsWithLegacyFn(Symbols, LegacyLookup);
-
- EXPECT_TRUE(!!LFR) << "lookupFlagsWithLegacy failed unexpectedly";
- EXPECT_EQ(LFR->SymbolFlags.size(), 2U) << "Wrong number of flags returned";
- EXPECT_EQ(LFR->SymbolFlags.count(Foo), 1U) << "Flags for foo missing";
- EXPECT_EQ(LFR->SymbolFlags.count(Bar), 1U) << "Flags for foo missing";
- EXPECT_EQ(LFR->SymbolFlags[Foo], FooFlags) << "Wrong flags for foo";
- EXPECT_EQ(LFR->SymbolFlags[Bar], BarFlags) << "Wrong flags for foo";
- EXPECT_EQ(LFR->SymbolsNotFound.size(), 1U) << "Expected one symbol not found";
- EXPECT_EQ(LFR->SymbolsNotFound.count(Baz), 1U)
+ SymbolFlagsMap SymbolFlags;
+ auto SymbolsNotFound =
+ lookupFlagsWithLegacyFn(SymbolFlags, Symbols, LegacyLookup);
+
+ EXPECT_TRUE(!!SymbolsNotFound) << "lookupFlagsWithLegacy failed unexpectedly";
+ EXPECT_EQ(SymbolFlags.size(), 2U) << "Wrong number of flags returned";
+ EXPECT_EQ(SymbolFlags.count(Foo), 1U) << "Flags for foo missing";
+ EXPECT_EQ(SymbolFlags.count(Bar), 1U) << "Flags for foo missing";
+ EXPECT_EQ(SymbolFlags[Foo], FooFlags) << "Wrong flags for foo";
+ EXPECT_EQ(SymbolFlags[Bar], BarFlags) << "Wrong flags for foo";
+ EXPECT_EQ(SymbolsNotFound->size(), 1U) << "Expected one symbol not found";
+ EXPECT_EQ(SymbolsNotFound->count(Baz), 1U)
<< "Expected symbol baz to be not found";
EXPECT_FALSE(BarMaterialized)
<< "lookupFlags should not have materialized bar";
OpenPOWER on IntegriCloud