[clang-tools-extra] [clang-tidy] Add fix-its to `avoid-return-with-void-value` check (PR #81420)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 11 08:21:30 PST 2024
================
@@ -42,10 +43,28 @@ void AvoidReturnWithVoidValueCheck::check(
const auto *VoidReturn = Result.Nodes.getNodeAs<ReturnStmt>("void_return");
if (IgnoreMacros && VoidReturn->getBeginLoc().isMacroID())
return;
- if (!StrictMode && !Result.Nodes.getNodeAs<CompoundStmt>("compound_parent"))
+ const auto *SurroundingBlock =
+ Result.Nodes.getNodeAs<CompoundStmt>("compound_parent");
+ if (!StrictMode && !SurroundingBlock)
return;
+ const auto ReturnExpr =
+ Lexer::getSourceText(CharSourceRange::getTokenRange(
+ VoidReturn->getRetValue()->getSourceRange()),
+ *Result.SourceManager, getLangOpts());
+ SourceLocation SemicolonPos;
+ if (const auto NextToken =
----------------
EugeneZelenko wrote:
Please don't use `auto` unless type is explicitly stated in same statement or iterator.
https://github.com/llvm/llvm-project/pull/81420
More information about the cfe-commits
mailing list