[PATCH] D19270: Fix a crash in cppcoreguidelines-pro-type-member-init related to missing constructor bodies.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 20 01:34:56 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL266862: Fix a crash in cppcoreguidelines-pro-type-member-init related to missing… (authored by hokein).
Changed prior to commit:
http://reviews.llvm.org/D19270?vs=54210&id=54327#toc
Repository:
rL LLVM
http://reviews.llvm.org/D19270
Files:
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
Index: clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===================================================================
--- clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -331,3 +331,10 @@
int X;
// CHECK-FIXES: int X{};
};
+
+// This check results in a CXXConstructorDecl with no body.
+struct NegativeDeletedConstructor : NegativeAggregateType {
+ NegativeDeletedConstructor() = delete;
+
+ Template<int> F;
+};
Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===================================================================
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -285,6 +285,9 @@
void ProTypeMemberInitCheck::check(const MatchFinder::MatchResult &Result) {
if (const auto *Ctor = Result.Nodes.getNodeAs<CXXConstructorDecl>("ctor")) {
+ // Skip declarations delayed by late template parsing without a body.
+ if (!Ctor->getBody())
+ return;
checkMissingMemberInitializer(*Result.Context, Ctor);
checkMissingBaseClassInitializer(*Result.Context, Ctor);
} else if (const auto *Var = Result.Nodes.getNodeAs<VarDecl>("var")) {
@@ -304,11 +307,6 @@
if (IsUnion && ClassDecl->hasInClassInitializer())
return;
- // Skip declarations delayed by late template parsing without a body.
- const Stmt *Body = Ctor->getBody();
- if (!Body)
- return;
-
SmallPtrSet<const FieldDecl *, 16> FieldsToInit;
fieldsRequiringInit(ClassDecl->fields(), Context, FieldsToInit);
if (FieldsToInit.empty())
@@ -323,7 +321,7 @@
FieldsToInit.erase(Init->getMember());
}
}
- removeFieldsInitializedInBody(*Body, Context, FieldsToInit);
+ removeFieldsInitializedInBody(*Ctor->getBody(), Context, FieldsToInit);
// Collect all fields in order, both direct fields and indirect fields from
// anonmyous record types.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19270.54327.patch
Type: text/x-patch
Size: 2110 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160420/c835a9b5/attachment.bin>
More information about the cfe-commits
mailing list