[clang-tools-extra] [clang-tidy] Add check readability-return-expression-in-void-function (PR #76249)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 22 08:21:17 PST 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 5f254eb05566f5b400a212ae77117a9efd9019a1 579cfd2eec9932aff10bf258811ec772a3503ce0 -- clang-tools-extra/clang-tidy/readability/ReturnExpressionInVoidFunctionCheck.cpp clang-tools-extra/clang-tidy/readability/ReturnExpressionInVoidFunctionCheck.h clang-tools-extra/test/clang-tidy/checkers/readability/return-expression-in-void-function.cpp clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang-tools-extra/clang-tidy/readability/ReturnExpressionInVoidFunctionCheck.cpp b/clang-tools-extra/clang-tidy/readability/ReturnExpressionInVoidFunctionCheck.cpp
index fb6073b60b..2308d0782a 100644
--- a/clang-tools-extra/clang-tidy/readability/ReturnExpressionInVoidFunctionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ReturnExpressionInVoidFunctionCheck.cpp
@@ -15,11 +15,15 @@ using namespace clang::ast_matchers;
namespace clang::tidy::readability {
-void ReturnExpressionInVoidFunctionCheck::registerMatchers(MatchFinder *Finder) {
- Finder->addMatcher(returnStmt(hasReturnValue(hasType(voidType()))).bind("void_return"), this);
+void ReturnExpressionInVoidFunctionCheck::registerMatchers(
+ MatchFinder *Finder) {
+ Finder->addMatcher(
+ returnStmt(hasReturnValue(hasType(voidType()))).bind("void_return"),
+ this);
}
-void ReturnExpressionInVoidFunctionCheck::check(const MatchFinder::MatchResult &Result) {
+void ReturnExpressionInVoidFunctionCheck::check(
+ const MatchFinder::MatchResult &Result) {
const auto *VoidReturn = Result.Nodes.getNodeAs<ReturnStmt>("void_return");
diag(VoidReturn->getBeginLoc(), "return statements should not return void");
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/76249
More information about the cfe-commits
mailing list