[PATCH] D25747: [clang-tidy] Fix an assertion failure in cppcoreguidelines-pro-type-member-init.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 18 13:37:09 PDT 2016
hokein created this revision.
hokein added a reviewer: aaron.ballman.
hokein added a subscriber: cfe-commits.
Herald added a subscriber: nemanjai.
The matcher for matching "class with default constructor" still match
some classes without default constructor, which trigger an assert at
Line 307. This patch makes the matcher more strict.
https://reviews.llvm.org/D25747
Files:
clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
Index: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===================================================================
--- test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -450,3 +450,9 @@
NegativeIncompleteArrayMember() {}
char e[];
};
+
+template <typename T> class NoCrash {
+ class B : public NoCrash {
+ template <typename U> B(U u) {}
+ };
+};
Index: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===================================================================
--- clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -27,6 +27,10 @@
namespace {
+AST_MATCHER(CXXRecordDecl, hasDefaultConstructor) {
+ return Node.hasDefaultConstructor();
+}
+
// Iterate over all the fields in a record type, both direct and indirect (e.g.
// if the record contains an anonmyous struct). If OneFieldPerUnion is true and
// the record type (or indirect field) is a union, forEachField will stop after
@@ -275,6 +279,7 @@
Finder->addMatcher(
cxxRecordDecl(
isDefinition(), unless(isInstantiated()),
+ hasDefaultConstructor(),
anyOf(has(cxxConstructorDecl(isDefaultConstructor(), isDefaulted(),
unless(isImplicit()))),
unless(has(cxxConstructorDecl()))),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25747.75066.patch
Type: text/x-patch
Size: 1431 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161018/2494e275/attachment.bin>
More information about the cfe-commits
mailing list