80 changes: 0 additions & 80 deletions compiler-rt/lib/orc/unittests/adt_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,83 +48,3 @@ TEST(ADTTest, SpanConstructFromIteratorAndSize) {
for (unsigned I = 0; I != S.size(); ++I)
EXPECT_EQ(S[I], A[I]) << "Unexpected span element value";
}

TEST(ADTTest, StringViewDefaultConstruction) {
string_view S;
EXPECT_TRUE(S.empty()) << "Default constructed span not empty";
EXPECT_EQ(S.size(), 0U) << "Default constructed span size not zero";
EXPECT_EQ(S.begin(), S.end()) << "Default constructed span begin != end";
}

TEST(ADTTest, StringViewConstructFromCharPtrAndSize) {
const char *Str = "abcdefg";
string_view S(Str, 5);
EXPECT_FALSE(S.empty()) << "string_view should be non-empty";
EXPECT_EQ(S.size(), 5U) << "string_view has unexpected size";
EXPECT_EQ(std::distance(S.begin(), S.end()), 5U)
<< "Unexpected iterator range size";
EXPECT_EQ(S.data(), &Str[0]) << "string_view data has unexpected value";
for (unsigned I = 0; I != S.size(); ++I)
EXPECT_EQ(S[I], Str[I]) << "Unexpected string_view element value";
}

TEST(ADTTest, StringViewConstructFromCharPtr) {
const char *Str = "abcdefg";
size_t StrLen = strlen(Str);
string_view S(Str);

EXPECT_FALSE(S.empty()) << "string_view should be non-empty";
EXPECT_EQ(S.size(), StrLen) << "string_view has unexpected size";
EXPECT_EQ(static_cast<size_t>(std::distance(S.begin(), S.end())), StrLen)
<< "Unexpected iterator range size";
EXPECT_EQ(S.data(), &Str[0]) << "string_view data has unexpected value";
for (unsigned I = 0; I != S.size(); ++I)
EXPECT_EQ(S[I], Str[I]) << "Unexpected string_view element value";
}

TEST(ADTTest, StringViewConstructFromStdString) {
std::string Str("abcdefg");
string_view S(Str);

EXPECT_FALSE(S.empty()) << "string_view should be non-empty";
EXPECT_EQ(S.size(), Str.size()) << "string_view has unexpected size";
EXPECT_EQ(static_cast<size_t>(std::distance(S.begin(), S.end())), Str.size())
<< "Unexpected iterator range size";
EXPECT_EQ(S.data(), &Str[0]) << "string_view data has unexpected value";
for (unsigned I = 0; I != S.size(); ++I)
EXPECT_EQ(S[I], Str[I]) << "Unexpected string_view element value";
}

TEST(ADTTest, StringViewCopyConstructionAndAssignment) {
// Check that string_views are copy-constructible and copy-assignable.
std::string Str("abcdefg");
string_view Orig(Str);
string_view CopyConstructed(Orig);
string_view CopyAssigned = Orig;

EXPECT_EQ(Orig, CopyConstructed);
EXPECT_EQ(Orig, CopyAssigned);
}

TEST(ADTTest, StringViewEquality) {
EXPECT_EQ("", string_view());
EXPECT_FALSE(string_view("aab") == string_view("aac"));
EXPECT_FALSE(string_view("aab") != string_view("aab"));
EXPECT_NE(string_view("aab"), string_view("aac"));
}

TEST(ADTTest, StringViewOStreamOperator) {
std::string Str("abcdefg");
string_view S(Str);
std::ostringstream OSS;
OSS << S;

EXPECT_EQ(OSS.str(), Str);
}

TEST(ADTTest, StringViewHashable) {
std::string Str("abcdefg");
string_view S(Str);

EXPECT_EQ(std::hash<std::string>()(Str), std::hash<string_view>()(S));
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ TEST(SimplePackedSerializationTest, SequenceSerialization) {

TEST(SimplePackedSerializationTest, StringViewCharSequenceSerialization) {
const char *HW = "Hello, world!";
blobSerializationRoundTrip<SPSString, string_view>(string_view(HW));
blobSerializationRoundTrip<SPSString, std::string_view>(std::string_view(HW));
}

TEST(SimplePackedSerializationTest, SpanSerialization) {
Expand Down
22 changes: 4 additions & 18 deletions llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ void JITLinkerBase::linkPhase1(std::unique_ptr<JITLinkerBase> Self) {
Ctx->getMemoryManager().allocate(
Ctx->getJITLinkDylib(), *G,
[S = std::move(Self)](AllocResult AR) mutable {
auto *TmpSelf = S.get();
TmpSelf->linkPhase2(std::move(S), std::move(AR));
S->linkPhase2(std::move(S), std::move(AR));
});
}

Expand Down Expand Up @@ -88,10 +87,7 @@ void JITLinkerBase::linkPhase2(std::unique_ptr<JITLinkerBase> Self,
dbgs() << "No external symbols for " << G->getName()
<< ". Proceeding immediately with link phase 3.\n";
});
// FIXME: Once callee expressions are defined to be sequenced before
// argument expressions (c++17) we can simplify this. See below.
auto &TmpSelf = *Self;
TmpSelf.linkPhase3(std::move(Self), AsyncLookupResult());
Self->linkPhase3(std::move(Self), AsyncLookupResult());
return;
}

Expand All @@ -103,20 +99,11 @@ void JITLinkerBase::linkPhase2(std::unique_ptr<JITLinkerBase> Self,

// We're about to hand off ownership of ourself to the continuation. Grab a
// pointer to the context so that we can call it to initiate the lookup.
//
// FIXME: Once callee expressions are defined to be sequenced before argument
// expressions (c++17) we can simplify all this to:
//
// Ctx->lookup(std::move(UnresolvedExternals),
// [Self=std::move(Self)](Expected<AsyncLookupResult> Result) {
// Self->linkPhase3(std::move(Self), std::move(Result));
// });
Ctx->lookup(std::move(ExternalSymbols),
createLookupContinuation(
[S = std::move(Self)](
Expected<AsyncLookupResult> LookupResult) mutable {
auto &TmpSelf = *S;
TmpSelf.linkPhase3(std::move(S), std::move(LookupResult));
S->linkPhase3(std::move(S), std::move(LookupResult));
}));
}

Expand Down Expand Up @@ -161,8 +148,7 @@ void JITLinkerBase::linkPhase3(std::unique_ptr<JITLinkerBase> Self,
return abandonAllocAndBailOut(std::move(Self), std::move(Err));

Alloc->finalize([S = std::move(Self)](FinalizeResult FR) mutable {
auto *TmpSelf = S.get();
TmpSelf->linkPhase4(std::move(S), std::move(FR));
S->linkPhase4(std::move(S), std::move(FR));
});
}

Expand Down