-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Use clang-tidy to add const wherever possible #16543
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
base: develop
Are you sure you want to change the base?
Changes from all commits
8b6503c
4c54db5
591dd8f
259cbb4
1807e77
02456f5
f61fd6c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we are going to use this style,
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point! I updated the best I could. I am not very good at writing markdown. Please review! |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| --- | ||
| Checks: '-*,misc-const-correctness,performance-for-range-copy,readability-make-member-function-const' | ||
| WarningsAsErrors: '' | ||
| CheckOptions: | ||
| - key: misc-const-correctness.AnalyzeValues | ||
| value: true | ||
| - key: misc-const-correctness.AnalyzeReferences | ||
| value: true | ||
| - key: misc-const-correctness.WarnPointersAsValues | ||
| value: false | ||
| - key: misc-const-correctness.TransformValues | ||
| value: true | ||
| - key: misc-const-correctness.TransformReferences | ||
| value: true | ||
| - key: misc-const-correctness.TransformPointersAsValues | ||
| value: false |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How foolproof are these checks? Were there false-positives that you had to correct manually?
Is this reliable enough we could think about adding
run-clang-tidyto thechk_stylejob to enforce this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ZERO false positives in the ENTIRE codebase. ZERO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
straight-up fixed it and recompiled and it was fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notice that the only reason why the compile is failing here is because of a warning, which is that NOW the compiler sees that something could be a
for(const auto& stuff: ...)-- previously, it was copied but there was no const, so the compiler didn't know if it was changed or not and hence could not warn about this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, that sounds pretty good. Can you make a PR to hook it up into CI after we merge this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will!