Skip to content

Commit

Permalink
Enable noexcept-move-ctor check (#16018)
Browse files Browse the repository at this point in the history
### 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
  • Loading branch information
afuller-TT authored Dec 13, 2024
1 parent 49adf12 commit 912e751
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 9 deletions.
3 changes: 0 additions & 3 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tt_metal/impl/allocator/allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down
2 changes: 1 addition & 1 deletion tt_metal/impl/allocator/allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions tt_metal/impl/buffers/semaphore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down
4 changes: 2 additions & 2 deletions tt_metal/impl/buffers/semaphore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_; }

Expand Down

0 comments on commit 912e751

Please sign in to comment.