From 140532f8b6ab68c91523b344ba62fc55849eb326 Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Wed, 15 Nov 2023 15:16:21 +0000 Subject: [PATCH] fix: fix issues with clang-tidy on Windows Signed-off-by: Mateusz Jablonski --- .../source/tracing/tracing_imp.cpp | 2 +- opencl/source/helpers/task_information.h | 2 +- opencl/source/platform/platform.cpp | 2 +- shared/source/program/print_formatter.cpp | 2 +- shared/source/utilities/iflist.h | 5 ++- .../unit_test/utilities/containers_tests.cpp | 44 +++++++++++-------- 6 files changed, 32 insertions(+), 25 deletions(-) diff --git a/level_zero/experimental/source/tracing/tracing_imp.cpp b/level_zero/experimental/source/tracing/tracing_imp.cpp index 0165c9376a..1f1d026316 100644 --- a/level_zero/experimental/source/tracing/tracing_imp.cpp +++ b/level_zero/experimental/source/tracing/tracing_imp.cpp @@ -212,7 +212,7 @@ size_t APITracerContextImp::updateTracerArrays() { // from this thread to the tracing threads. // activeTracerArray.store(newTracerArray, std::memory_order_release); - return testAndFreeRetiredTracers(); + return testAndFreeRetiredTracers(); // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks) } ze_result_t APITracerContextImp::enableTracingImp(struct APITracerImp *tracerImp, ze_bool_t enable) { diff --git a/opencl/source/helpers/task_information.h b/opencl/source/helpers/task_information.h index 311bff11d4..1f78cade9d 100644 --- a/opencl/source/helpers/task_information.h +++ b/opencl/source/helpers/task_information.h @@ -89,7 +89,7 @@ class Command : public IFNode { Command(CommandQueue &commandQueue); Command(CommandQueue &commandQueue, std::unique_ptr &kernelOperation); - virtual ~Command(); + ~Command() override; virtual LinearStream *getCommandStream() { return nullptr; } diff --git a/opencl/source/platform/platform.cpp b/opencl/source/platform/platform.cpp index bcabc0da0d..e2c275e626 100644 --- a/opencl/source/platform/platform.cpp +++ b/opencl/source/platform/platform.cpp @@ -268,7 +268,7 @@ std::vector Platform::groupDevices(DeviceVector devices) { outDevices[platformId].push_back(std::move(device)); } std::sort(outDevices.begin(), outDevices.end(), [](DeviceVector &lhs, DeviceVector &rhs) -> bool { - return lhs[0]->getHardwareInfo().platform.eProductFamily > rhs[0]->getHardwareInfo().platform.eProductFamily; + return lhs[0]->getHardwareInfo().platform.eProductFamily > rhs[0]->getHardwareInfo().platform.eProductFamily; // NOLINT(clang-analyzer-cplusplus.Move) }); return outDevices; } diff --git a/shared/source/program/print_formatter.cpp b/shared/source/program/print_formatter.cpp index ad1972bda6..d932223f77 100644 --- a/shared/source/program/print_formatter.cpp +++ b/shared/source/program/print_formatter.cpp @@ -93,7 +93,7 @@ void PrintFormatter::printString(const char *formatString, const std::function, ThreadSafe, OwnsNodes auto up = std::unique_ptr>(new IFNodeRef(&node)); this->pushFrontOne(*up); up.release(); - } + } // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks) }; } // namespace NEO diff --git a/shared/test/unit_test/utilities/containers_tests.cpp b/shared/test/unit_test/utilities/containers_tests.cpp index 778e0a7f13..f9fd0b593b 100644 --- a/shared/test/unit_test/utilities/containers_tests.cpp +++ b/shared/test/unit_test/utilities/containers_tests.cpp @@ -26,7 +26,7 @@ struct DummyFNode : IFNode { DummyFNode(uint32_t *destructorsCounter = nullptr) : destructorsCounter(destructorsCounter) { } - ~DummyFNode() { + ~DummyFNode() override { if (destructorsCounter != nullptr) { ++(*destructorsCounter); } @@ -35,7 +35,7 @@ struct DummyFNode : IFNode { void setPrev(DummyFNode *) { } - uint32_t *destructorsCounter; + uint32_t *destructorsCounter = nullptr; }; struct DummyDNode : IDNode { @@ -284,27 +284,33 @@ TEST(IFList, WhenExchangingHeadThenResultIsCorrect) { template void iFRefListTestPushFrontOne() { - auto list = std::unique_ptr>(new IFRefList()); - ASSERT_TRUE(list->peekIsEmpty()); + uint32_t destructorCounter = 0; + { + auto list = std::unique_ptr>(new IFRefList()); + ASSERT_TRUE(list->peekIsEmpty()); - DummyFNode node1; - node1.next = nullptr; // garbage - list->pushRefFrontOne(node1); - ASSERT_FALSE(list->peekIsEmpty()); - ASSERT_EQ(&node1, list->peekHead()->ref); - ASSERT_EQ(nullptr, node1.next); + DummyFNode node1(&destructorCounter); + node1.next = nullptr; // garbage + list->pushRefFrontOne(node1); + ASSERT_FALSE(list->peekIsEmpty()); + ASSERT_EQ(&node1, list->peekHead()->ref); + ASSERT_EQ(nullptr, node1.next); - DummyFNode node2; - node2.next = nullptr; // garbage - list->pushRefFrontOne(node2); - ASSERT_FALSE(list->peekIsEmpty()); - ASSERT_EQ(&node2, list->peekHead()->ref); - ASSERT_EQ(nullptr, node2.next); + DummyFNode node2(&destructorCounter); + node2.next = nullptr; // garbage + list->pushRefFrontOne(node2); + ASSERT_FALSE(list->peekIsEmpty()); + ASSERT_EQ(&node2, list->peekHead()->ref); + ASSERT_EQ(nullptr, node2.next); - ASSERT_EQ(&node2, list->peekHead()->ref); - ASSERT_EQ(&node1, list->peekHead()->next->ref); + ASSERT_EQ(&node2, list->peekHead()->ref); + ASSERT_EQ(&node1, list->peekHead()->next->ref); - list.reset(); + EXPECT_EQ(0u, destructorCounter); + list.reset(); + EXPECT_EQ(0u, destructorCounter); + } + EXPECT_EQ(2u, destructorCounter); } TEST(IFRefList, GivenThreadSafeWhenPushingFrontOneThenResultIsCorrect) {