Skip to content

Conversation

@HerrCai0907
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Dec 6, 2024

@llvm/pr-subscribers-clang-tools-extra

Author: Congcong Cai (HerrCai0907)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/118985.diff

1 Files Affected:

  • (modified) clang-tools-extra/clang-tidy/bugprone/ReturnConstRefFromParameterCheck.cpp (+5-4)
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);
 }
 

@llvmbot
Copy link
Member

llvmbot commented Dec 6, 2024

@llvm/pr-subscribers-clang-tidy

Author: Congcong Cai (HerrCai0907)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/118985.diff

1 Files Affected:

  • (modified) clang-tools-extra/clang-tidy/bugprone/ReturnConstRefFromParameterCheck.cpp (+5-4)
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);
 }
 

@HerrCai0907 HerrCai0907 merged commit 17a7f20 into llvm:main Dec 7, 2024
11 checks passed
@HerrCai0907 HerrCai0907 deleted the refactor-return-const-ref branch December 7, 2024 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants