================
@@ -104,7 +104,12 @@ 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()) {
-      const Expr *Init = VD->getInit()->IgnoreParenCasts();
+      // Initializer matched by hasInitializer() may be attached to a different
+      // redeclaration.
+      const Expr *Init = VD->getInit();
+      if (!Init)
----------------
zeyi2 wrote:

To make things clear, `Init` could already be `NULL` before the regression.

Before:

```cpp
if (T->isDependentType())
  markCanNotBeConst(VD->getInit(), false);
```

and in `NonConstParameterCheck::markCanNotBeConst`

```cpp
void NonConstParameterCheck::markCanNotBeConst(const Expr *E,
                                               bool CanNotBeConst) {
  if (!E)
    return; // early return here

  ...
}
```

So the patch is preserving the old behavior.

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

Reply via email to