Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang-tidy] performance-noexcept-move-constructor and performance-noexcept-swap do not handle conditional noexcept properly #68101

Closed
jpboivin opened this issue Oct 3, 2023 · 0 comments · Fixed by #68359
Labels
clang-tidy confirmed Verified by a second party

Comments

@jpboivin
Copy link

jpboivin commented Oct 3, 2023

Hello,

I've tested clang-tidy 17 on some codebases, and there seems to be false positives (except if I'm missing something) with performance-noexcept-move-constructor and performance-noexcept-swap checks, at least in templated code that annotates the move constructor or swap with a conditional noexcept (when using traits, otherwise it is properly handled).

I've written an extremely simple piece of code that triggers the issue:
https://godbolt.org/z/59EhaEeda

[<source>:7:37: warning: noexcept specifier on the move constructor evaluates to 'false' [performance-noexcept-move-constructor]]
    7 |     Container(Container&&) noexcept(std::is_nothrow_move_constructible_v<T>);
      |                                     ^
[<source>:8:42: warning: noexcept specifier on swap function evaluates to 'false' [performance-noexcept-swap]]
    8 |     void swap(Container& other) noexcept(std::is_nothrow_swappable_v<T>);
      |                                          ^
2 warnings generated.
@PiotrZSL PiotrZSL added the confirmed Verified by a second party label Oct 3, 2023
AMS21 added a commit to AMS21/llvm-project that referenced this issue Oct 6, 2023
… noexcept expressions

The previous code was pretty messy and treated value dependant
expressions which could not be evaluated the same as if they evaluted to
`false`. Which was obviously not correct.

We now check if we can evaluate the dependant expressions and if not we
truthfully return that we don't know if the function is declared as
`noexcept` or not.

This fixes llvm#68101
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang-tidy confirmed Verified by a second party
Projects
None yet
2 participants