forked from OSchip/llvm-project
[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 llvm-svn: 286990
This commit is contained in:
parent
73d1d35d21
commit
49fe4037a1
|
@ -54,7 +54,7 @@ void RedundantMemberInitCheck::check(const MatchFinder::MatchResult &Result) {
|
||||||
} else {
|
} else {
|
||||||
diag(Init->getSourceLocation(),
|
diag(Init->getSourceLocation(),
|
||||||
"initializer for base class %0 is redundant")
|
"initializer for base class %0 is redundant")
|
||||||
<< Init->getTypeSourceInfo()->getType()
|
<< Construct->getType()
|
||||||
<< FixItHint::CreateRemoval(Init->getSourceRange());
|
<< FixItHint::CreateRemoval(Init->getSourceRange());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,6 +87,24 @@ struct F7 : S, T {
|
||||||
// CHECK-FIXES: F7() {}
|
// 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
|
// Initializer not written
|
||||||
struct NF1 {
|
struct NF1 {
|
||||||
NF1() {}
|
NF1() {}
|
||||||
|
|
Loading…
Reference in New Issue