// If the dependency was not in the error state then add it to
// our list of dependencies.
- assert(OtherJITDylib.MaterializingInfos.count(OtherSymbol) &&
- "No MaterializingInfo for dependency");
auto &OtherMI = OtherJITDylib.MaterializingInfos[OtherSymbol];
if (OtherSymEntry.getState() == SymbolState::Emitted)
SymI->second.setFlags(ResolvedFlags);
SymI->second.setState(SymbolState::Resolved);
- auto &MI = MaterializingInfos[Name];
+ auto MII = MaterializingInfos.find(Name);
+ if (MII == MaterializingInfos.end())
+ continue;
+
+ auto &MI = MII->second;
for (auto &Q : MI.takeQueriesMeeting(SymbolState::Resolved)) {
Q->notifySymbolMetRequiredState(Name, ResolvedSym);
Q->removeQueryDependence(*this, Name);
SymEntry.setState(SymbolState::Emitted);
auto MII = MaterializingInfos.find(Name);
- assert(MII != MaterializingInfos.end() &&
- "Missing MaterializingInfo entry");
+
+ // If this symbol has no MaterializingInfo then it's trivially ready.
+ // Update its state and continue.
+ if (MII == MaterializingInfos.end()) {
+ SymEntry.setState(SymbolState::Ready);
+ continue;
+ }
+
auto &MI = MII->second;
// For each dependant, transfer this node's emitted dependencies to
EXPECT_TRUE(OnCompletionRun) << "OnCompletion was not run for empty query";
}
+TEST_F(CoreAPIsStandardTest, ResolveUnrequestedSymbol) {
+ // Test that all symbols in a MaterializationUnit materialize corretly when
+ // only a subset of symbols is looked up.
+ // The aim here is to ensure that we're not relying on the query to set up
+ // state needed to materialize the unrequested symbols.
+
+ cantFail(JD.define(std::make_unique<SimpleMaterializationUnit>(
+ SymbolFlagsMap({{Foo, FooSym.getFlags()}, {Bar, BarSym.getFlags()}}),
+ [this](MaterializationResponsibility R) {
+ cantFail(R.notifyResolved({{Foo, FooSym}, {Bar, BarSym}}));
+ cantFail(R.notifyEmitted());
+ })));
+
+ auto Result =
+ cantFail(ES.lookup(makeJITDylibSearchOrder(&JD), SymbolLookupSet({Foo})));
+ EXPECT_EQ(Result.size(), 1U) << "Unexpected number of results";
+ EXPECT_TRUE(Result.count(Foo)) << "Expected result for \"Foo\"";
+}
+
TEST_F(CoreAPIsStandardTest, RemoveSymbolsTest) {
// Test that:
// (1) Missing symbols generate a SymbolsNotFound error.