================ @@ -40,12 +42,35 @@ void AvoidReturnWithVoidValueCheck::registerMatchers(MatchFinder *Finder) { void AvoidReturnWithVoidValueCheck::check( const MatchFinder::MatchResult &Result) { const auto *VoidReturn = Result.Nodes.getNodeAs<ReturnStmt>("void_return"); - if (IgnoreMacros && VoidReturn->getBeginLoc().isMacroID()) + 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; - diag(VoidReturn->getBeginLoc(), "return statement within a void function " - "should not have a specified return value"); + } + DiagnosticBuilder Diag = diag(VoidReturn->getBeginLoc(), + "return statement within a void function " + "should not have a specified return value"); + std::optional<Token> SemicolonPos = + Lexer::findNextToken(VoidReturn->getRetValue()->getEndLoc(), ---------------- PiotrZSL wrote:
May not work for `return foo() /*some comment*/;` Consider just VoidReturn->getEndLoc() and findNextTerminator instead. https://github.com/llvm/llvm-project/pull/81420 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits