Issue |
126702
|
Summary |
[clang-tidy] performance-noexcept-move-constructor do not handle conditional noexcept properly
|
Labels |
clang-tidy
|
Assignees |
|
Reporter |
Nechda
|
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
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs