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

Add clang tidy warning for move constructors and assignments without noexcept #23893

Closed
ned14 mannequin opened this issue May 14, 2015 · 10 comments
Closed

Add clang tidy warning for move constructors and assignments without noexcept #23893

ned14 mannequin opened this issue May 14, 2015 · 10 comments
Labels
bugzilla Issues migrated from bugzilla clang-tidy

Comments

@ned14
Copy link
Mannequin

ned14 mannequin commented May 14, 2015

Bugzilla Link 23519
Resolution FIXED
Resolved on May 23, 2017 11:56
Version unspecified
OS Windows NT
CC @a-n-t-h-o-n-y,@chandlerc

Extended Description

Chandler told me to file a feature request adding a clang tidy check giving warnings for when move constructors or assignment operators are not marked noexcept.

I sometimes forget the noexcept. I am sure so do others.

Niall

@llvmbot
Copy link
Collaborator

llvmbot commented May 18, 2015

Looks like an easy one for a new contributor. Patches are welcome! ;)

@chandlerc
Copy link
Member

Looks like an easy one for a new contributor. Patches are welcome! ;)

I'd like to ask that this is prioritized. I would very strongly like to have this. If no where else, LLVM could benefit heavily from this when using custom types in data structures.

@llvmbot
Copy link
Collaborator

llvmbot commented May 21, 2015

Should we complain about move constructors declared with noexcept(false), or should this be considered a way to silence the warning?

@ned14
Copy link
Mannequin Author

ned14 mannequin commented May 21, 2015

Should we complain about move constructors declared with noexcept(false), or
should this be considered a way to silence the warning?

If it's noexcept(expr) where expr is evaluated to be false then the warning should be issued.

If it's noexcept(false) with a literal false then the warning should not be issued. I would hope there is still a way of suppressing clang tidy warnings in general.

Ideally only types ever used inside STL containers or other places where noexcept move semantics are crucially important should generate these warnings, but I'd prefer a false positive here than no warning at all.

There is also the matter of throw capable code being in a destructor. Under C++ 11 destructors are all default noexcept, and therefore a throw must never reach a destructor edge. A ton of people converting code from C++ 03 fail to adjust their destructors. I'll add another feature request.

Niall

@llvmbot
Copy link
Collaborator

llvmbot commented May 22, 2015

Sent http://reviews.llvm.org/D9933 for review.

@llvmbot
Copy link
Collaborator

llvmbot commented May 27, 2015

The check is there, but no fix-it hints for now.

@a-n-t-h-o-n-y
Copy link
Mannequin

a-n-t-h-o-n-y mannequin commented Dec 15, 2016

Error in the current implementation of this check. The check warns when move constructor/assignment operator is marked noexcept and is explicitly defaulted.

1 similar comment
@a-n-t-h-o-n-y
Copy link
Mannequin

a-n-t-h-o-n-y mannequin commented Dec 15, 2016

Error in the current implementation of this check. The check warns when move constructor/assignment operator is marked noexcept and is explicitly defaulted.

@llvmbot
Copy link
Collaborator

llvmbot commented May 16, 2017

Anthony, please file a separate bug with an example and an explanation of why you think this is a wrong behavior.

@a-n-t-h-o-n-y
Copy link
Mannequin

a-n-t-h-o-n-y mannequin commented May 23, 2017

Looks like Bug 24712 fixes this behavior.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang-tidy
Projects
None yet
Development

No branches or pull requests

2 participants