Skip to content

Commit f1c9649

Browse files
committed
Re-reapply r343129 with more fixes.
Fixes order-of-operand-evaluation bugs in the ThreadSafeModule unit tests. llvm-svn: 343162
1 parent 5ad09de commit f1c9649

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

llvm/unittests/ExecutionEngine/Orc/ThreadSafeModuleTest.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,20 @@ TEST(ThreadSafeModuleTest, ContextWhollyOwnedByOneModule) {
2323
// Test that ownership of a context can be transferred to a single
2424
// ThreadSafeModule.
2525
ThreadSafeContext TSCtx(llvm::make_unique<LLVMContext>());
26-
ThreadSafeModule TSM(llvm::make_unique<Module>("M", *TSCtx.getContext()),
27-
std::move(TSCtx));
26+
auto M = llvm::make_unique<Module>("M", *TSCtx.getContext());
27+
ThreadSafeModule TSM(std::move(M), std::move(TSCtx));
2828
}
2929

3030
TEST(ThreadSafeModuleTest, ContextOwnershipSharedByTwoModules) {
3131
// Test that ownership of a context can be shared between more than one
3232
// ThreadSafeModule.
3333
ThreadSafeContext TSCtx(llvm::make_unique<LLVMContext>());
3434

35-
ThreadSafeModule TSM1(llvm::make_unique<Module>("M1", *TSCtx.getContext()),
36-
TSCtx);
37-
ThreadSafeModule TSM2(llvm::make_unique<Module>("M2", *TSCtx.getContext()),
38-
std::move(TSCtx));
35+
auto M1 =llvm::make_unique<Module>("M1", *TSCtx.getContext());
36+
ThreadSafeModule TSM1(std::move(M1), TSCtx);
37+
38+
auto M2 =llvm::make_unique<Module>("M2", *TSCtx.getContext());
39+
ThreadSafeModule TSM2(std::move(M2), std::move(TSCtx));
3940
}
4041

4142
TEST(ThreadSafeModuleTest, ContextOwnershipSharedWithClient) {
@@ -45,30 +46,30 @@ TEST(ThreadSafeModuleTest, ContextOwnershipSharedWithClient) {
4546

4647
{
4748
// Create and destroy a module.
48-
ThreadSafeModule TSM1(llvm::make_unique<Module>("M1", *TSCtx.getContext()),
49-
TSCtx);
49+
auto M1 = llvm::make_unique<Module>("M1", *TSCtx.getContext());
50+
ThreadSafeModule TSM1(std::move(M1), TSCtx);
5051
}
5152

5253
// Verify that the context is still available for re-use.
53-
ThreadSafeModule TSM2(llvm::make_unique<Module>("M2", *TSCtx.getContext()),
54-
std::move(TSCtx));
54+
auto M2 = llvm::make_unique<Module>("M2", *TSCtx.getContext());
55+
ThreadSafeModule TSM2(std::move(M2), std::move(TSCtx));
5556
}
5657

5758
TEST(ThreadSafeModuleTest, ThreadSafeModuleMoveAssignment) {
5859
// Move assignment needs to move the module before the context (opposite
5960
// to the field order) to ensure that overwriting with an empty
6061
// ThreadSafeModule does not destroy the context early.
6162
ThreadSafeContext TSCtx(llvm::make_unique<LLVMContext>());
62-
ThreadSafeModule TSM(llvm::make_unique<Module>("M", *TSCtx.getContext()),
63-
std::move(TSCtx));
63+
auto M = llvm::make_unique<Module>("M", *TSCtx.getContext());
64+
ThreadSafeModule TSM(std::move(M), std::move(TSCtx));
6465
TSM = ThreadSafeModule();
6566
}
6667

6768
TEST(ThreadSafeModuleTest, BasicContextLockAPI) {
6869
// Test that basic lock API calls work.
6970
ThreadSafeContext TSCtx(llvm::make_unique<LLVMContext>());
70-
ThreadSafeModule TSM(llvm::make_unique<Module>("M", *TSCtx.getContext()),
71-
TSCtx);
71+
auto M =llvm::make_unique<Module>("M", *TSCtx.getContext());
72+
ThreadSafeModule TSM(std::move(M), TSCtx);
7273

7374
{ auto L = TSCtx.getLock(); }
7475

0 commit comments

Comments
 (0)