================
@@ -103,14 +103,31 @@ void NonConstParameterCheck::check(const 
MatchFinder::MatchResult &Result) {
     }
   } else if (const auto *VD = Result.Nodes.getNodeAs<VarDecl>("Mark")) {
     const QualType T = VD->getType();
-    if (T->isDependentType())
-      markCanNotBeConst(VD->getInit(), false);
-    else if ((T->isPointerType() && !T->getPointeeType().isConstQualified()) ||
-             T->isArrayType() || T->isRecordType())
+    if (T->isDependentType()) {
+      const Expr *Init = VD->getInit()->IgnoreParenCasts();
+      if (const auto *U = dyn_cast<UnaryOperator>(Init);
+          U && U->getOpcode() == UO_Deref) {
+        markCanNotBeConst(U->getSubExpr(), true);
+      } else if (const auto *PLE = dyn_cast<ParenListExpr>(Init)) {
+        for (unsigned I = 0; I < PLE->getNumExprs(); ++I) {
+          const Expr *E = PLE->getExpr(I)->IgnoreParenCasts();
+          if (const auto *U = dyn_cast<UnaryOperator>(E);
+              U && U->getOpcode() == UO_Deref)
----------------
vbvictor wrote:

Deref is `*` IIRC, do we have tests with it?

https://github.com/llvm/llvm-project/pull/186953
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to