llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-tools-extra Author: Baranov Victor (vbvictor) <details> <summary>Changes</summary> Fixes https://github.com/llvm/llvm-project/issues/155416. --- Full diff: https://github.com/llvm/llvm-project/pull/190521.diff 3 Files Affected: - (modified) clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp (+2-1) - (modified) clang-tools-extra/docs/ReleaseNotes.rst (+5) - (modified) clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-member-init.cpp (+24) ``````````diff diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp index a259d03724d24..07d71968a07b8 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp @@ -572,7 +572,8 @@ void ProTypeMemberInitCheck::checkMissingBaseClassInitializer( for (const CXXCtorInitializer *Init : Ctor->inits()) if (Init->isBaseInitializer() && Init->isWritten()) - BasesToInit.erase(Init->getBaseClass()->getAsCXXRecordDecl()); + BasesToInit.erase( + Init->getBaseClass()->getAsCXXRecordDecl()->getCanonicalDecl()); } if (BasesToInit.empty()) diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index 69dc5b9633398..5ba16e1f71a10 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -283,6 +283,11 @@ Changes in existing checks <clang-tidy/checks/cppcoreguidelines/missing-std-forward>` check by fixing a false positive for constrained template parameters. +- Improved :doc:`cppcoreguidelines-pro-type-member-init + <clang-tidy/checks/cppcoreguidelines/pro-type-member-init>` check by fixing + a false positive when a base class has a forward declaration before its + definition. + - Improved :doc:`cppcoreguidelines-pro-type-vararg <clang-tidy/checks/cppcoreguidelines/pro-type-vararg>` check by no longer warning on builtins with custom type checking (e.g., type-generic builtins diff --git a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-member-init.cpp b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-member-init.cpp index 890d1d262066b..7468ce04434b0 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-member-init.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-member-init.cpp @@ -611,3 +611,27 @@ namespace PR37250 { const V v; const S s{v}; } + +namespace PR155416 { + struct S; + + struct S { + int a; + }; + + struct C : S { + C() : S{0} {} + }; + + template<typename T> + struct St; + + template<typename T> + struct St{ + T a; + }; + + struct Ct : St<int> { + Ct() : St{0} {} + }; +} `````````` </details> https://github.com/llvm/llvm-project/pull/190521 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
