diff options
Diffstat (limited to 'clang-tools-extra/clang-tidy/cppcoreguidelines')
-rw-r--r-- | clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp index 6e5896a9f49..672d222e595 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp @@ -179,6 +179,11 @@ void ProTypeMemberInitCheck::check(const MatchFinder::MatchResult &Result) { const auto *Ctor = Result.Nodes.getNodeAs<CXXConstructorDecl>("ctor"); const auto &MemberFields = Ctor->getParent()->fields(); + // Skip declarations delayed by late template parsing without a body. + const Stmt *Body = Ctor->getBody(); + if (!Body) + return; + SmallPtrSet<const FieldDecl *, 16> FieldsToInit; fieldsRequiringInit(MemberFields, FieldsToInit); if (FieldsToInit.empty()) @@ -193,8 +198,8 @@ void ProTypeMemberInitCheck::check(const MatchFinder::MatchResult &Result) { continue; FieldsToInit.erase(Init->getMember()); } - removeFieldsInitializedInBody(*Ctor->getBody(), *Result.Context, - FieldsToInit); + removeFieldsInitializedInBody(*Body, *Result.Context, FieldsToInit); + if (FieldsToInit.empty()) return; |