malcolm.parsons updated this revision to Diff 76797.
malcolm.parsons added a comment.

Add test.


https://reviews.llvm.org/D26118

Files:
  clang-tidy/readability/RedundantMemberInitCheck.cpp
  test/clang-tidy/readability-redundant-member-init.cpp


Index: test/clang-tidy/readability-redundant-member-init.cpp
===================================================================
--- test/clang-tidy/readability-redundant-member-init.cpp
+++ test/clang-tidy/readability-redundant-member-init.cpp
@@ -87,6 +87,24 @@
   // CHECK-FIXES: F7()  {}
 };
 
+namespace Foo {
+inline namespace Bar {
+template <int N>
+struct Template {
+  Template() = default;
+  int i = N;
+};
+}
+}
+
+enum { N_THINGS = 5 };
+
+struct F8 : Foo::Template<N_THINGS> {
+  F8() : Template() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for base class 
'Foo::Template<N_THINGS>' is redundant
+  // CHECK-FIXES: F8()  {}
+};
+
 // Initializer not written
 struct NF1 {
   NF1() {}
Index: clang-tidy/readability/RedundantMemberInitCheck.cpp
===================================================================
--- clang-tidy/readability/RedundantMemberInitCheck.cpp
+++ clang-tidy/readability/RedundantMemberInitCheck.cpp
@@ -54,7 +54,7 @@
     } else {
       diag(Init->getSourceLocation(),
            "initializer for base class %0 is redundant")
-          << Init->getTypeSourceInfo()->getType()
+          << Construct->getType()
           << FixItHint::CreateRemoval(Init->getSourceRange());
     }
   }


Index: test/clang-tidy/readability-redundant-member-init.cpp
===================================================================
--- test/clang-tidy/readability-redundant-member-init.cpp
+++ test/clang-tidy/readability-redundant-member-init.cpp
@@ -87,6 +87,24 @@
   // CHECK-FIXES: F7()  {}
 };
 
+namespace Foo {
+inline namespace Bar {
+template <int N>
+struct Template {
+  Template() = default;
+  int i = N;
+};
+}
+}
+
+enum { N_THINGS = 5 };
+
+struct F8 : Foo::Template<N_THINGS> {
+  F8() : Template() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for base class 'Foo::Template<N_THINGS>' is redundant
+  // CHECK-FIXES: F8()  {}
+};
+
 // Initializer not written
 struct NF1 {
   NF1() {}
Index: clang-tidy/readability/RedundantMemberInitCheck.cpp
===================================================================
--- clang-tidy/readability/RedundantMemberInitCheck.cpp
+++ clang-tidy/readability/RedundantMemberInitCheck.cpp
@@ -54,7 +54,7 @@
     } else {
       diag(Init->getSourceLocation(),
            "initializer for base class %0 is redundant")
-          << Init->getTypeSourceInfo()->getType()
+          << Construct->getType()
           << FixItHint::CreateRemoval(Init->getSourceRange());
     }
   }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to