diff options
author | Haojian Wu <hokein@google.com> | 2016-10-20 13:15:40 +0000 |
---|---|---|
committer | Haojian Wu <hokein@google.com> | 2016-10-20 13:15:40 +0000 |
commit | 7c870a7e54aed16f4d7dbba5cdb79cc21c4ff9ba (patch) | |
tree | f8e9002a9d64f22bd67638e225a177fd537c4aeb /clang-tools-extra/clang-tidy/cppcoreguidelines | |
parent | 26b2593b24999f394bd4d6cd0871d11230f8a87b (diff) | |
download | bcm5719-llvm-7c870a7e54aed16f4d7dbba5cdb79cc21c4ff9ba.tar.gz bcm5719-llvm-7c870a7e54aed16f4d7dbba5cdb79cc21c4ff9ba.zip |
[clang-tidy] Fix an assertion failure in cppcoreguidelines-pro-type-member-init.
Summary:
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.
Reviewers: aaron.ballman
Subscribers: nemanjai, cfe-commits
Differential Revision: https://reviews.llvm.org/D25747
llvm-svn: 284727
Diffstat (limited to 'clang-tools-extra/clang-tidy/cppcoreguidelines')
-rw-r--r-- | clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp index 548f13fe5dc..272e2dad1be 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp @@ -27,6 +27,10 @@ namespace cppcoreguidelines { 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 @@ void ProTypeMemberInitCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher( cxxRecordDecl( isDefinition(), unless(isInstantiated()), + hasDefaultConstructor(), anyOf(has(cxxConstructorDecl(isDefaultConstructor(), isDefaulted(), unless(isImplicit()))), unless(has(cxxConstructorDecl()))), |