diff --git a/orc-rt/unittests/CMakeLists.txt b/orc-rt/unittests/CMakeLists.txt index 54c453de3a97f..4d3da682d4222 100644 --- a/orc-rt/unittests/CMakeLists.txt +++ b/orc-rt/unittests/CMakeLists.txt @@ -15,7 +15,6 @@ add_orc_rt_unittest(CoreTests AllocActionTest.cpp BitmaskEnumTest.cpp CallableTraitsHelperTest.cpp - CommonTestUtils.cpp ErrorTest.cpp ExecutorAddressTest.cpp IntervalMapTest.cpp diff --git a/orc-rt/unittests/CommonTestUtils.cpp b/orc-rt/unittests/CommonTestUtils.cpp deleted file mode 100644 index d9f9433d167fd..0000000000000 --- a/orc-rt/unittests/CommonTestUtils.cpp +++ /dev/null @@ -1,20 +0,0 @@ -//===- CommonTestUtils.cpp ------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// Common test utilities. -// -//===----------------------------------------------------------------------===// - -#include "CommonTestUtils.h" - -size_t OpCounter::DefaultConstructions = 0; -size_t OpCounter::CopyConstructions = 0; -size_t OpCounter::CopyAssignments = 0; -size_t OpCounter::MoveConstructions = 0; -size_t OpCounter::MoveAssignments = 0; -size_t OpCounter::Destructions = 0; diff --git a/orc-rt/unittests/CommonTestUtils.h b/orc-rt/unittests/CommonTestUtils.h index 5ff2c8e6e8989..1c66bddaf75be 100644 --- a/orc-rt/unittests/CommonTestUtils.h +++ b/orc-rt/unittests/CommonTestUtils.h @@ -11,7 +11,7 @@ #include -class OpCounter { +template class OpCounter { public: OpCounter() { ++DefaultConstructions; } OpCounter(const OpCounter &Other) { ++CopyConstructions; } @@ -57,4 +57,11 @@ class OpCounter { static size_t Destructions; }; +template size_t OpCounter::DefaultConstructions = 0; +template size_t OpCounter::CopyConstructions = 0; +template size_t OpCounter::CopyAssignments = 0; +template size_t OpCounter::MoveConstructions = 0; +template size_t OpCounter::MoveAssignments = 0; +template size_t OpCounter::Destructions = 0; + #endif // ORC_RT_UNITTEST_COMMONTESTUTILS_H diff --git a/orc-rt/unittests/bind-test.cpp b/orc-rt/unittests/bind-test.cpp index bfaef4e9c1ebe..93a61e6387b49 100644 --- a/orc-rt/unittests/bind-test.cpp +++ b/orc-rt/unittests/bind-test.cpp @@ -47,28 +47,28 @@ TEST(BindTest, LambdaCapture) { } TEST(BindTest, MinimalMoves) { - OpCounter::reset(); + OpCounter<>::reset(); { - auto B = bind_front([](OpCounter &O, int) {}, OpCounter()); + auto B = bind_front([](OpCounter<> &O, int) {}, OpCounter<>()); B(0); } - EXPECT_EQ(OpCounter::defaultConstructions(), 1U); - EXPECT_EQ(OpCounter::copies(), 0U); - EXPECT_EQ(OpCounter::moves(), 1U); - EXPECT_EQ(OpCounter::destructions(), 2U); + EXPECT_EQ(OpCounter<>::defaultConstructions(), 1U); + EXPECT_EQ(OpCounter<>::copies(), 0U); + EXPECT_EQ(OpCounter<>::moves(), 1U); + EXPECT_EQ(OpCounter<>::destructions(), 2U); } TEST(BindTest, MinimalCopies) { - OpCounter::reset(); + OpCounter<>::reset(); { - OpCounter O; - auto B = bind_front([](OpCounter &O, int) {}, O); + OpCounter<> O; + auto B = bind_front([](OpCounter<> &O, int) {}, O); B(0); } - EXPECT_EQ(OpCounter::defaultConstructions(), 1U); - EXPECT_EQ(OpCounter::copies(), 1U); - EXPECT_EQ(OpCounter::moves(), 0U); - EXPECT_EQ(OpCounter::destructions(), 2U); + EXPECT_EQ(OpCounter<>::defaultConstructions(), 1U); + EXPECT_EQ(OpCounter<>::copies(), 1U); + EXPECT_EQ(OpCounter<>::moves(), 0U); + EXPECT_EQ(OpCounter<>::destructions(), 2U); } TEST(BindTest, ForwardUnboundArgs) {