[all-commits] [llvm/llvm-project] 2790e6: [clang-tidy] Fix crash in readability-non-const-pa...

Zeyi Xu via All-commits all-commits at lists.llvm.org
Tue Jun 2 06:13:39 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2790e61b41949e4ce61faebdb1faed614ca14416
      https://github.com/llvm/llvm-project/commit/2790e61b41949e4ce61faebdb1faed614ca14416
  Author: Zeyi Xu <mitchell.xu2 at gmail.com>
  Date:   2026-06-02 (Tue, 02 Jun 2026)

  Changed paths:
    M clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp
    M clang-tools-extra/docs/ReleaseNotes.rst
    M clang-tools-extra/test/clang-tidy/checkers/readability/non-const-parameter.cpp

  Log Message:
  -----------
  [clang-tidy] Fix crash in readability-non-const-parameter with redecls (#200178)

The check matches `VarDecls` with `hasInitializer()`, which uses
`getAnyInitializer()` and may therefore match a redeclaration whose
initializer is attached to another declaration. So calling
`IgnoreParenCasts()` on `VD->getInit()` directly would crash when that
redeclaration had no initializer of its own.

This commit fixes the problem by using a new matcher that only matches
VarDecls with an initializer on the current declaration.

Closes https://github.com/llvm/llvm-project/issues/199197



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list