[clang-tools-extra] [clang-tidy] Fix false positive for generic lambda parameters in readability-non-const-parameter (PR #179051)

Aditya Singh via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 14 19:58:58 PST 2026


================
@@ -95,18 +95,20 @@ void NonConstParameterCheck::check(const MatchFinder::MatchResult &Result) {
         }
       }
     } else if (const auto *CE = dyn_cast<CXXUnresolvedConstructExpr>(S)) {
-      for (const auto *Arg : CE->arguments())
-        markCanNotBeConst(Arg->IgnoreParenCasts(), true);
+      markCanNotBeConst(CE, true);
     } else if (const auto *R = dyn_cast<ReturnStmt>(S)) {
       markCanNotBeConst(R->getRetValue(), true);
     } else if (const auto *U = dyn_cast<UnaryOperator>(S)) {
       markCanNotBeConst(U, true);
     }
   } else if (const auto *VD = Result.Nodes.getNodeAs<VarDecl>("Mark")) {
     const QualType T = VD->getType();
-    if ((T->isPointerType() && !T->getPointeeType().isConstQualified()) ||
-        T->isArrayType() || T->isRecordType())
+    if (T->isDependentType())
+      markCanNotBeConst(VD->getInit(), false);
+    else if ((T->isPointerType() && !T->getPointeeType().isConstQualified()) ||
+             T->isArrayType() || T->isRecordType())
       markCanNotBeConst(VD->getInit(), true);
+
----------------
Aditya26189 wrote:

done

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


More information about the cfe-commits mailing list