[PATCH] D26118: [clang-tidy] Change readability-redundant-member-init to get base type from constructor

Malcolm Parsons via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 15 09:58:54 PST 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL286990: [clang-tidy] Change readability-redundant-member-init to get base type from… (authored by malcolm.parsons).

Changed prior to commit:
  https://reviews.llvm.org/D26118?vs=76797&id=78024#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26118

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


Index: clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.cpp
===================================================================
--- clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.cpp
+++ clang-tools-extra/trunk/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: clang-tools-extra/trunk/test/clang-tidy/readability-redundant-member-init.cpp
===================================================================
--- clang-tools-extra/trunk/test/clang-tidy/readability-redundant-member-init.cpp
+++ clang-tools-extra/trunk/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() {}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26118.78024.patch
Type: text/x-patch
Size: 1392 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161115/96046362/attachment.bin>


More information about the cfe-commits mailing list