[PATCH] D37014: [clang-tidy] Add a checker to remove useless intermediate variables before return statements with comparisons
Andi via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 3 07:50:30 PST 2018
Abpostelnicu added inline comments.
================
Comment at: clang-tidy/readability/UnnecessaryIntermediateVarCheck.cpp:376
+ // expression wouldn't really benefit readability. Therefore we abort.
+ if (NewReturnLength > MaximumLineLength) {
+ return;
----------------
lebedev.ri wrote:
> Is there really no way to format the fixes, and *then* check the line length?
> ```
> $ clang-tidy --help
> ...
> -format-style=<string> -
> Style for formatting code around applied fixes:
> - 'none' (default) turns off formatting
> - 'file' (literally 'file', not a placeholder)
> uses .clang-format file in the closest parent
> directory
> - '{ <json> }' specifies options inline, e.g.
> -format-style='{BasedOnStyle: llvm, IndentWidth: 8}'
> - 'llvm', 'google', 'webkit', 'mozilla'
> See clang-format documentation for the up-to-date
> information about formatting styles and options.
> This option overrides the 'FormatStyle` option in
> .clang-tidy file, if any.
> ...
> ```
> so `clang-tidy` is at least aware of `clang-format`.
I think this is doable since I see this in the code:
https://code.woboq.org/llvm/clang-tools-extra/clang-tidy/ClangTidy.cpp.html#199
That leads me to think that we can have this before applying the fixes and in case the fix after re-format has a line that violates our rule it gets dropped. I'm gonna update the patch with this new addon.
https://reviews.llvm.org/D37014
More information about the cfe-commits
mailing list