Fixes bug 35694
Adds option AutoTypeNameLength, default 0 (keep current behaviour).
Note that the default could be set to 5 in the future
(like for modernize-use-auto.MinTypeNameLength).
I haven't been able to build locally so far -- OOM on my machine, not sure if I can do something lighter than:
cmake -G Ninja -DLLVM_ENABLE_PROJECTS=clang\;clang-tools-extra -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../llvm ninja check-clang-tools
but I 'm still looking for feedback in the meantime.
Frankly, I don't think that length-based criteria is reasonable one. Readability of code is much more important than line/file length.
Please don't use auto unless type is explicitly spelled in same statement or iterator.
See other documentation file for syntax for options.
Please highlight TypeName (option) is single back-ticks and auto (language construct) with double back-ticks.
Please highlight 0 (option value) is single back-ticks and auto (language construct) with double back-ticks.
It provides an added configuration flexibility without being more complex than a boolean. Arguably some people have found the similar modernize-use-auto.MinTypeNameLength useful (the PR has some discussion) -- and I find its default of 5 makes sense as MyTyp can be argued as always better than auto even for people that like auto.
from @alexfh on that thread:
the style guides I'm more or less familiar with recommend the use of auto for "long/cluttery type names" , "if and only if it makes the code more readable or easier to maintain" , or to "save writing a longish, hard-to-remember type that the compiler already knows but a programmer could get wrong" . 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.
That said, I absolutely don't mind changing this PR to define a boolean option UseAuto instead, if requested.
(otherwise I'll address review comments tomorrow. Thanks for the review!)