From 912e751114b848cdbc8542373aa3c649cd7223a8 Mon Sep 17 00:00:00 2001 From: Andrew Fuller Date: Fri, 13 Dec 2024 18:57:38 -0500 Subject: [PATCH] Enable noexcept-move-ctor check (#16018) ### Ticket #15123 ### Problem description Some move c'tors were not marked `noexcept`. They must be or some codepaths will fall back to copies instead. See https://clang.llvm.org/extra/clang-tidy/checks/performance/noexcept-move-constructor.html ### What's changed Marked the detected move c'tors as `noexcept`. ### Checklist - [x] Post commit CI passes https://github.com/tenstorrent/tt-metal/actions/runs/12322285782 --- .clang-tidy | 3 --- tt_metal/impl/allocator/allocator.cpp | 2 +- tt_metal/impl/allocator/allocator.hpp | 2 +- tt_metal/impl/buffers/semaphore.cpp | 4 ++-- tt_metal/impl/buffers/semaphore.hpp | 4 ++-- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 1f8f2b524ab..db075b71b53 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -49,7 +49,6 @@ Checks: > -cppcoreguidelines-macro-usage, -cppcoreguidelines-narrowing-conversions, -cppcoreguidelines-no-malloc, - -cppcoreguidelines-noexcept-move-operations, -cppcoreguidelines-noexcept-swap, -cppcoreguidelines-non-private-member-variables-in-classes, -cppcoreguidelines-owning-memory, @@ -95,7 +94,6 @@ Checks: > -hicpp-named-parameter, -hicpp-no-array-decay, -hicpp-no-malloc, - -hicpp-noexcept-move, -hicpp-signed-bitwise, -hicpp-special-member-functions, -hicpp-uppercase-literal-suffix, @@ -150,7 +148,6 @@ Checks: > -performance-move-const-arg, -performance-move-constructor-init, -performance-no-int-to-ptr, - -performance-noexcept-move-constructor, -performance-noexcept-swap, -performance-unnecessary-copy-initialization, -readability-avoid-const-params-in-decls, diff --git a/tt_metal/impl/allocator/allocator.cpp b/tt_metal/impl/allocator/allocator.cpp index aa43d84043f..ad25e1f3a6f 100644 --- a/tt_metal/impl/allocator/allocator.cpp +++ b/tt_metal/impl/allocator/allocator.cpp @@ -169,7 +169,7 @@ BankManager::~BankManager() { this->allocator_.reset(nullptr); } -BankManager&& BankManager::operator=(BankManager&& that) { +BankManager&& BankManager::operator=(BankManager&& that) noexcept { buffer_type_ = that.buffer_type_; allocated_buffers_ = that.allocated_buffers_; bank_id_to_bank_offset_ = that.bank_id_to_bank_offset_; diff --git a/tt_metal/impl/allocator/allocator.hpp b/tt_metal/impl/allocator/allocator.hpp index 1852e959766..a3eb7f05ed0 100644 --- a/tt_metal/impl/allocator/allocator.hpp +++ b/tt_metal/impl/allocator/allocator.hpp @@ -50,7 +50,7 @@ class BankManager { uint32_t alignment_bytes, DeviceAddr alloc_offset = 0, bool disable_interleaved = false); - BankManager&& operator=(BankManager&& that); + BankManager&& operator=(BankManager&& that) noexcept; ~BankManager(); uint32_t num_banks() const; diff --git a/tt_metal/impl/buffers/semaphore.cpp b/tt_metal/impl/buffers/semaphore.cpp index 5cb19c9fe6a..401c1d53090 100644 --- a/tt_metal/impl/buffers/semaphore.cpp +++ b/tt_metal/impl/buffers/semaphore.cpp @@ -30,13 +30,13 @@ Semaphore& Semaphore::operator=(const Semaphore& other) { return *this; } -Semaphore::Semaphore(Semaphore&& other) : +Semaphore::Semaphore(Semaphore&& other) noexcept : core_range_set_(other.core_range_set_), id_(other.id_), initial_value_(other.initial_value_), core_type_(other.core_type_) {} -Semaphore& Semaphore::operator=(Semaphore&& other) { +Semaphore& Semaphore::operator=(Semaphore&& other) noexcept { if (this != &other) { this->core_range_set_ = other.core_range_set_; this->id_ = other.id_; diff --git a/tt_metal/impl/buffers/semaphore.hpp b/tt_metal/impl/buffers/semaphore.hpp index 22c699aa67d..8df46c00f05 100644 --- a/tt_metal/impl/buffers/semaphore.hpp +++ b/tt_metal/impl/buffers/semaphore.hpp @@ -24,9 +24,9 @@ class Semaphore { Semaphore& operator=(const Semaphore& other); - Semaphore(Semaphore&& other); + Semaphore(Semaphore&& other) noexcept; - Semaphore& operator=(Semaphore&& other); + Semaphore& operator=(Semaphore&& other) noexcept; uint32_t id() const { return id_; }