We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c229f76 commit b2c9f7dCopy full SHA for b2c9f7d
clang-tools-extra/clang-tidy/readability/AvoidReturnWithVoidValueCheck.cpp
@@ -64,8 +64,11 @@ void AvoidReturnWithVoidValueCheck::check(
64
<< BraceInsertionHints.closingBraceFixIt();
65
}
66
Diag << FixItHint::CreateRemoval(VoidReturn->getReturnLoc());
67
- if (!Result.Nodes.getNodeAs<FunctionDecl>("function_parent") ||
68
- SurroundingBlock->body_back() != VoidReturn)
+ const auto *FunctionParent =
+ Result.Nodes.getNodeAs<FunctionDecl>("function_parent");
69
+ if (!FunctionParent ||
70
+ (SurroundingBlock && SurroundingBlock->body_back() != VoidReturn))
71
+ // If this is not the last statement in a function body, we add a `return`.
72
Diag << FixItHint::CreateInsertion(SemicolonPos.getLocWithOffset(1),
73
" return;", true);
74
0 commit comments