<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/126702>126702</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-tidy] performance-noexcept-move-constructor do not handle conditional noexcept properly
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Nechda
</td>
</tr>
</table>
<pre>
Hi!
It seems that this issue has been discussed in https://github.com/llvm/llvm-project/issues/68101 and partially resolved. The problem is now observed in clang version 19.1.0 and possibly in the trunk as well.
To summarize, I have an external class that does not have a noexcept move constructor. When I try to mark the move constructor for my class using type traits, the check fails.
Previously, a workaround solved the case where the class in question had a template parameter. This allowed the check to allow the use of type traits with noexcept. Maybe the check should only be triggered when the user explicitly specifies noexcept(false)?
```cpp
#include <type_traits>
/* External class */
struct NotMarkedNoexcept {
int x;
NotMarkedNoexcept() = default;
// NOLINTNEXTLINE(performance-noexcept-move-constructor)
NotMarkedNoexcept(NotMarkedNoexcept&& rhs);
};
struct Complicated {
static constexpr bool NOEXCEPT_MOVE = std::is_nothrow_move_constructible_v<NotMarkedNoexcept>;
Complicated() = default;
Complicated(Complicated&&) noexcept(NOEXCEPT_MOVE) = default; // Warning
NotMarkedNoexcept inner;
};
int main() {}
```
```text
[<source>:14:41: warning: noexcept specifier on the move constructor evaluates to 'false' [performance-noexcept-move-constructor]](javascript:;)
14 | Complicated(Complicated&&) noexcept(NOEXCEPT_MOVE) = default; // Warning
| ^
1 warning generated.
Suppressed 1 warnings (1 NOLINT).
```
https://godbolt.org/z/E4E65jdhh
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy0VlFvozgQ_jXOy6gRmADJQx5omugq7WZXuup236oBT4K3xuZsk5T99ScDadPt6lSddBVSYzye-eabbzygc_KoidYsvWXp3Qw7Xxu73lNVC5yVRvTrPyTjMYsKFhX3HhxR48DX6MHX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