[clang-tools-extra] r286990 - [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:49:00 PST 2016


Author: malcolm.parsons
Date: Tue Nov 15 11:49:00 2016
New Revision: 286990

URL: http://llvm.org/viewvc/llvm-project?rev=286990&view=rev
Log:
[clang-tidy] Change readability-redundant-member-init to get base type from constructor

Summary: Fixes PR30835

Reviewers: alexfh, hokein, aaron.ballman

Subscribers: Prazek, cfe-commits

Differential Revision: https://reviews.llvm.org/D26118

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

Modified: clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.cpp?rev=286990&r1=286989&r2=286990&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.cpp Tue Nov 15 11:49:00 2016
@@ -54,7 +54,7 @@ void RedundantMemberInitCheck::check(con
     } else {
       diag(Init->getSourceLocation(),
            "initializer for base class %0 is redundant")
-          << Init->getTypeSourceInfo()->getType()
+          << Construct->getType()
           << FixItHint::CreateRemoval(Init->getSourceRange());
     }
   }

Modified: clang-tools-extra/trunk/test/clang-tidy/readability-redundant-member-init.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-redundant-member-init.cpp?rev=286990&r1=286989&r2=286990&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/readability-redundant-member-init.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/readability-redundant-member-init.cpp Tue Nov 15 11:49:00 2016
@@ -87,6 +87,24 @@ struct F7 : S, T {
   // 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() {}




More information about the cfe-commits mailing list