flx created this revision.
flx added reviewers: alexfh, JVApen.
flx added a subscriber: cfe-commits.
flx set the repository for this revision to rL LLVM.

This fixes bug https://llvm.org/bugs/show_bug.cgi?id=26747

Repository:
  rL LLVM

http://reviews.llvm.org/D18300

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
@@ -86,6 +86,14 @@
   int I;
 };
 
+struct A {};
+template <class> class B;
+template <class T> class NegativeTemplateConstructor {
+  NegativeTemplateConstructor(const B<T> &, A) {}
+  bool Bool{false};
+  // CHECK-FIXES: bool Bool{false};
+};
+
 #define UNINITIALIZED_FIELD_IN_MACRO_BODY(FIELD) \
   struct UninitializedField##FIELD {            \
     UninitializedField##FIELD() {}              \
Index: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===================================================================
--- clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -32,6 +32,8 @@
 fieldsRequiringInit(const RecordDecl::field_range &Fields,
                     SmallPtrSetImpl<const FieldDecl *> &FieldsToInit) {
   for (const FieldDecl *F : Fields) {
+    if (F->hasInClassInitializer())
+      continue;
     QualType Type = F->getType();
     if (Type->isPointerType() || Type->isBuiltinType())
       FieldsToInit.insert(F);


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
@@ -86,6 +86,14 @@
   int I;
 };
 
+struct A {};
+template <class> class B;
+template <class T> class NegativeTemplateConstructor {
+  NegativeTemplateConstructor(const B<T> &, A) {}
+  bool Bool{false};
+  // CHECK-FIXES: bool Bool{false};
+};
+
 #define UNINITIALIZED_FIELD_IN_MACRO_BODY(FIELD) \
   struct UninitializedField##FIELD {		 \
     UninitializedField##FIELD() {}		 \
Index: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===================================================================
--- clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -32,6 +32,8 @@
 fieldsRequiringInit(const RecordDecl::field_range &Fields,
                     SmallPtrSetImpl<const FieldDecl *> &FieldsToInit) {
   for (const FieldDecl *F : Fields) {
+    if (F->hasInClassInitializer())
+      continue;
     QualType Type = F->getType();
     if (Type->isPointerType() || Type->isBuiltinType())
       FieldsToInit.insert(F);
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to