================ @@ -15,20 +16,24 @@ using namespace clang::ast_matchers; namespace clang::tidy::bugprone { void ReturnConstRefFromParameterCheck::registerMatchers(MatchFinder *Finder) { - Finder->addMatcher( - returnStmt( - hasReturnValue(declRefExpr( - to(parmVarDecl(hasType(hasCanonicalType( - qualType(lValueReferenceType(pointee( - qualType(isConstQualified())))) - .bind("type")))) - .bind("param")))), - hasAncestor( - functionDecl(hasReturnTypeLoc(loc(qualType( - hasCanonicalType(equalsBoundNode("type")))))) - .bind("func"))) - .bind("ret"), - this); + const auto DRef = + declRefExpr( + to(parmVarDecl(hasType(hasCanonicalType( + qualType(lValueReferenceType(pointee( + qualType(isConstQualified())))) + .bind("type")))) + .bind("param"))) + .bind("dref"); + const auto Func = + functionDecl(hasReturnTypeLoc(loc( + qualType(hasCanonicalType(equalsBoundNode("type")))))) + .bind("func"); + + Finder->addMatcher(returnStmt(hasReturnValue(DRef), hasAncestor(Func)), this); + Finder->addMatcher(conditionalOperator(eachOf(hasTrueExpression(DRef), ---------------- 5chmidti wrote:
Done. I've also wrapped the `conditionalOperator` inside an `ignoresParens` https://github.com/llvm/llvm-project/pull/107657 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits