[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
Thu Oct 20 06:25:10 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL284727: [clang-tidy] Fix an assertion failure in cppcoreguidelines-pro-type-member-init. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D25747?vs=75066&id=75291#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25747

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/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===================================================================
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tools-extra/trunk/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()))),
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
@@ -450,3 +450,9 @@
   NegativeIncompleteArrayMember() {}
   char e[];
 };
+
+template <typename T> class NoCrash {
+  class B : public NoCrash {
+    template <typename U> B(U u) {}
+  };
+};


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25747.75291.patch
Type: text/x-patch
Size: 1575 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161020/c7000e9e/attachment.bin>


More information about the cfe-commits mailing list