[PATCH] D96082: [clang-tidy] Add 'readability-useless-return-value' check
Eugene Zelenko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 4 17:18:36 PST 2021
Eugene.Zelenko added a comment.
New check must be mentioned in Release Notes.
================
Comment at: clang-tools-extra/clang-tidy/readability/UselessReturnValueCheck.cpp:1
+//===--- UselessReturnValueCheck.cpp - clang-tidy
+//-------------------------------===//
----------------
Please merge two lines. See other files as example.
================
Comment at: clang-tools-extra/clang-tidy/readability/UselessReturnValueCheck.cpp:64
+
+ const auto *ProtoDecl = MatchedDecl->getCanonicalDecl();
+ if (ProtoDecl)
----------------
Please don't use auto unless type is explicitly stated in statement or iterator.
================
Comment at: clang-tools-extra/clang-tidy/readability/UselessReturnValueCheck.cpp:72
+ {
+ auto RemovalStartLocation =
+ MatchedReturn->getBeginLoc().getLocWithOffset(6);
----------------
Please don't use auto unless type is explicitly stated in statement or iterator.
================
Comment at: clang-tools-extra/clang-tidy/readability/UselessReturnValueCheck.cpp:74
+ MatchedReturn->getBeginLoc().getLocWithOffset(6);
+ auto RemovalEndLocation = MatchedReturn->getEndLoc();
+ auto RemovalRange = SourceRange(RemovalStartLocation, RemovalEndLocation);
----------------
Please don't use auto unless type is explicitly stated in statement or iterator.
================
Comment at: clang-tools-extra/clang-tidy/readability/UselessReturnValueCheck.cpp:75
+ auto RemovalEndLocation = MatchedReturn->getEndLoc();
+ auto RemovalRange = SourceRange(RemovalStartLocation, RemovalEndLocation);
+ diag(RemovalStartLocation, "remove return value", DiagnosticIDs::Note)
----------------
Please don't use auto unless type is explicitly stated in statement or iterator.
================
Comment at: clang-tools-extra/docs/clang-tidy/checks/readability-useless-return-value.rst:6
+
+This check looks for functions that always return ``0``.
+Such functions could be ``void``.
----------------
Please use single back-tick for value.
================
Comment at: clang-tools-extra/docs/clang-tidy/checks/readability-useless-return-value.rst:16
+it feels strange to have only 1 possible return value.
+
+
----------------
Please remove one empty line.
================
Comment at: clang-tools-extra/docs/clang-tidy/checks/readability-useless-return-value.rst:20
+
+The following function `f` and `f2` return always ``0``:
+
----------------
Please use single back-tick for value.
================
Comment at: clang-tools-extra/docs/clang-tidy/checks/readability-useless-return-value.rst:38
+ void f() {
+ return;
+ }
----------------
Return is redundant. See readability-redundant-control-flow.
================
Comment at: clang-tools-extra/docs/clang-tidy/checks/readability-useless-return-value.rst:43
+ int ret = 0;
+ return;
+ }
----------------
Return is redundant. See readability-redundant-control-flow.
================
Comment at: clang-tools-extra/docs/clang-tidy/checks/readability-useless-return-value.rst:45
+ }
+
+
----------------
Please remove one empty line.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D96082/new/
https://reviews.llvm.org/D96082
More information about the cfe-commits
mailing list