[clang-tools-extra] [clang-tidy] fix false positive in bugprone-return-const-ref-from-parameter (PR #117734)

via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 26 09:03:36 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff f7dc1d0ac83b7c6b691167d8d02561ba0837b631 80e12b2ed1f324181d280cbd2fd242f63642bed6 --extensions cpp -- clang-tools-extra/clang-tidy/bugprone/ReturnConstRefFromParameterCheck.cpp clang-tools-extra/test/clang-tidy/checkers/bugprone/return-const-ref-from-parameter.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang-tools-extra/clang-tidy/bugprone/ReturnConstRefFromParameterCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ReturnConstRefFromParameterCheck.cpp
index 80d1487ba5..64c66ee4ae 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ReturnConstRefFromParameterCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ReturnConstRefFromParameterCheck.cpp
@@ -18,14 +18,17 @@ namespace clang::tidy::bugprone {
 void ReturnConstRefFromParameterCheck::registerMatchers(MatchFinder *Finder) {
   const auto DRef = ignoringParens(
       declRefExpr(
-          to(parmVarDecl(hasType(hasCanonicalType(
-                             qualType(lValueReferenceType(pointee(
-                                          qualType(isConstQualified()))))
-                                 .bind("type"))), parmVarDecl(hasDeclContext(functionDecl().bind("owner"))))
+          to(parmVarDecl(
+                 hasType(hasCanonicalType(
+                     qualType(lValueReferenceType(
+                                  pointee(qualType(isConstQualified()))))
+                         .bind("type"))),
+                 parmVarDecl(hasDeclContext(functionDecl().bind("owner"))))
                  .bind("param")))
           .bind("dref"));
   const auto Func =
-      functionDecl(equalsBoundNode("owner"), hasReturnTypeLoc(loc(
+      functionDecl(equalsBoundNode("owner"),
+                   hasReturnTypeLoc(loc(
                        qualType(hasCanonicalType(equalsBoundNode("type"))))))
           .bind("func");
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/117734


More information about the cfe-commits mailing list