[clang-tools-extra] [clang-tidy] Fix crash in `cppcoreguidelines-pro-type-member-init` with alias template in constructor initializer (PR #192786)

via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 23 19:14:07 PDT 2026


flovent wrote:

>  The root cause is getAsCXXRecordDecl returns nullptr for dependent types, regardless of whether it is a target base class.


I think this is the thing fixed in this PR, we check `getAsCXXRecordDecl`'s return value before using it.

From:
```
BasesToInit.erase(
            Init->getBaseClass()->getAsCXXRecordDecl()->getCanonicalDecl());
```

To:
```
if (const CXXRecordDecl *CRD =
                Init->getBaseClass()->getAsCXXRecordDecl())
          BasesToInit.erase(CRD->getCanonicalDecl());
      }
```

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


More information about the cfe-commits mailing list