The threshold option is 'MinTypeNameLength' with default value '5'.
With MinTypeNameLength = 5 'int'/'bool' and 'const int'/'const bool' will not be converted to 'auto',
while 'unsigned' and 'long long int' will be.
Details
- Reviewers
angelgarcia malcolm.parsons alexfh - Commits
- rGe68c7fa1e55a: [clang-tidy] [modernize-use-auto] Add a threshold for minimal type name length…
rCTE329730: [clang-tidy] [modernize-use-auto] Add a threshold for minimal type name length…
rL329730: [clang-tidy] [modernize-use-auto] Add a threshold for minimal type name length…
Diff Detail
- Repository
- rL LLVM
Event Timeline
docs/clang-tidy/checks/modernize-use-auto.rst | ||
---|---|---|
202 ↗ | (On Diff #141561) | nit: document the default value. |
clang-tidy/modernize/UseAutoCheck.cpp | ||
---|---|---|
290 ↗ | (On Diff #141561) | Maybe make the default 5? Or does anyone really want to replace int/long/char/bool/... with auto? |
clang-tidy/modernize/UseAutoCheck.cpp | ||
---|---|---|
290 ↗ | (On Diff #141561) | That might be a bit surprising behavioral change.. |
clang-tidy/modernize/UseAutoCheck.cpp | ||
---|---|---|
290 ↗ | (On Diff #141561) | Maybe we can somehow mention the current option value in a warning message? |
clang-tidy/modernize/UseAutoCheck.cpp | ||
---|---|---|
290 ↗ | (On Diff #141561) | Sure, can be done, but that will only be seen when it does fire, not when it suddenly stops firing... |
clang-tidy/modernize/UseAutoCheck.cpp | ||
---|---|---|
290 ↗ | (On Diff #141561) |
We don't do that for options of other checks (and for the other option here). I don't think this case is substantially different. |
290 ↗ | (On Diff #141561) |
For many it will be a welcome change ;)
No objections here.
You see it, 5 is a better default, otherwise you'd say "0 cent" ;) On a serious note, the style guides I'm more or less familiar with recommend the use of auto for "long/cluttery type names" [1], "if and only if it makes the code more readable or easier to maintain" [2], or to "save writing a longish, hard-to-remember type that the compiler already knows but a programmer could get wrong" [3]. None of these guidelines seem to endorse the use of auto instead of int, bool or the like. From my perspective, the default value of 5 would cover a larger fraction of real-world use cases. [1] https://google.github.io/styleguide/cppguide.html#auto |
420–421 ↗ | (On Diff #141561) | Consider using tooling::fixit::getText(Loc, Context) instead. |
clang-tidy/modernize/UseAutoCheck.cpp | ||
---|---|---|
290 ↗ | (On Diff #141561) | Or even 7 to ignore 'double' too. |
clang-tidy/modernize/UseAutoCheck.cpp | ||
---|---|---|
290 ↗ | (On Diff #141561) | I'd go with 5, which is super-easy to explain: it's the smallest value that will always lead to shorter code. 7 doesn't have this advantage. |
Roman, I see you've fixed them. Thanks a lot!
I did not face with these errors on MSVS'201 so had no chance to fix early.
ср, 11 апр. 2018 г. в 0:02, Roman Lebedev via Phabricator <
reviews@reviews.llvm.org>:
lebedev.ri added a comment.
This change had two different problems.
Please watch the bots?Repository:
rL LLVM
No stress, but as Roman said, please watch the bots after committing a patch: http://lab.llvm.org:8011/console.
ср, 11 апр. 2018 г. в 0:02, Roman Lebedev via Phabricator <
reviews@reviews.llvm.org>:lebedev.ri added a comment.
This change had two different problems.
Please watch the bots?
The build was broken by someone else's commit then. From my side there was
a warning only I fixed immediately.
ср, 11 апр. 2018 г. в 16:26, Alexander Kornienko via Phabricator <
reviews@reviews.llvm.org>:
alexfh added a comment.
In https://reviews.llvm.org/D45405#1063890, @zinovy.nis wrote:
Roman, I see you've fixed them. Thanks a lot!
I did not face with these errors on MSVS'201 so had no chance to fixearly.
No stress, but as Roman said, please watch the bots after committing a
patch: http://lab.llvm.org:8011/console.ср, 11 апр. 2018 г. в 0:02, Roman Lebedev via Phabricator <
reviews@reviews.llvm.org>:lebedev.ri added a comment.
This change had two different problems.
Please watch the bots?Repository:
rL LLVM