[PATCH] D25747: [clang-tidy] Fix an assertion failure in cppcoreguidelines-pro-type-member-init.

2016-10-20 Thread Haojian Wu via cfe-commits
hokein added inline comments.



Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:30
 
+AST_MATCHER(CXXRecordDecl, hasDefaultConstructor) {
+  return Node.hasDefaultConstructor();

aaron.ballman wrote:
> I think this should be a public AST matcher rather than a private one; it 
> seems like it would be generally useful (along with some of the other similar 
> has* functions). However, I think it's fine for this patch.
+1, will do it in a follow-up.


https://reviews.llvm.org/D25747



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25747: [clang-tidy] Fix an assertion failure in cppcoreguidelines-pro-type-member-init.

2016-10-20 Thread Haojian Wu via cfe-commits
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=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  class NoCrash {
+  class B : public NoCrash {
+template  B(U u) {}
+  };
+};


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  class NoCrash {
+  class B : public NoCrash {
+template  B(U u) {}
+  };
+};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25747: [clang-tidy] Fix an assertion failure in cppcoreguidelines-pro-type-member-init.

2016-10-20 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:30
 
+AST_MATCHER(CXXRecordDecl, hasDefaultConstructor) {
+  return Node.hasDefaultConstructor();

I think this should be a public AST matcher rather than a private one; it seems 
like it would be generally useful (along with some of the other similar has* 
functions). However, I think it's fine for this patch.


https://reviews.llvm.org/D25747



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25747: [clang-tidy] Fix an assertion failure in cppcoreguidelines-pro-type-member-init.

2016-10-18 Thread Haojian Wu via cfe-commits
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  class NoCrash {
+  class B : public NoCrash {
+template  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(,


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  class NoCrash {
+  class B : public NoCrash {
+template  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(,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits