[clang-tools-extra] [clang-tidy][NFC] merge same part matchers in return-const-ref-from-parameter (PR #118985)

Congcong Cai via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 6 07:16:01 PST 2024


https://github.com/HerrCai0907 created https://github.com/llvm/llvm-project/pull/118985

None

>From 7da6b1cef450ab31164bd2f79d7372ffdd66cdd5 Mon Sep 17 00:00:00 2001
From: Congcong Cai <congcongcai0907 at 163.com>
Date: Fri, 6 Dec 2024 23:15:36 +0800
Subject: [PATCH] [clang-tidy][NFC] merge same part matchers in
 return-const-ref-from-parameter

---
 .../bugprone/ReturnConstRefFromParameterCheck.cpp        | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/bugprone/ReturnConstRefFromParameterCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ReturnConstRefFromParameterCheck.cpp
index 1bd7abbad66d27..a35fcd99d494af 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ReturnConstRefFromParameterCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ReturnConstRefFromParameterCheck.cpp
@@ -41,11 +41,12 @@ void ReturnConstRefFromParameterCheck::registerMatchers(MatchFinder *Finder) {
                        qualType(hasCanonicalType(equalsBoundNode("type"))))))
           .bind("func");
 
-  Finder->addMatcher(returnStmt(hasReturnValue(DRef), hasAncestor(Func)), this);
   Finder->addMatcher(
-      returnStmt(hasReturnValue(ignoringParens(conditionalOperator(
-          eachOf(hasTrueExpression(DRef), hasFalseExpression(DRef)),
-          hasAncestor(Func))))),
+      returnStmt(
+          hasReturnValue(anyOf(
+              DRef, ignoringParens(conditionalOperator(eachOf(
+                        hasTrueExpression(DRef), hasFalseExpression(DRef)))))),
+          hasAncestor(Func)),
       this);
 }
 



More information about the cfe-commits mailing list