forked from OSchip/llvm-project
[clang-tidy] Ignore default arguments in modernize-default-member-init
Summary: Default member initializers cannot refer to constructor parameters, but modernize-default-member-init was trying to when the default constructor had default arguments. Change the check to ignore default arguments to the default constructor. Fixes PR31524. Reviewers: alexfh, aaron.ballman Subscribers: cfe-commits, JDevlieghere, Eugene.Zelenko Differential Revision: https://reviews.llvm.org/D28287 llvm-svn: 290972
This commit is contained in:
parent
6cfb5caf05
commit
b744ce87fc
|
@ -158,7 +158,7 @@ void UseDefaultMemberInitCheck::registerMatchers(MatchFinder *Finder) {
|
|||
unaryOperator(anyOf(hasOperatorName("+"), hasOperatorName("-")),
|
||||
hasUnaryOperand(floatLiteral())),
|
||||
cxxBoolLiteral(), cxxNullPtrLiteralExpr(), implicitValueInitExpr(),
|
||||
declRefExpr());
|
||||
declRefExpr(to(enumConstantDecl())));
|
||||
|
||||
Finder->addMatcher(
|
||||
cxxConstructorDecl(
|
||||
|
|
|
@ -221,6 +221,12 @@ struct NegativeNotDefaultInt
|
|||
int i;
|
||||
};
|
||||
|
||||
struct NegativeDefaultArg
|
||||
{
|
||||
NegativeDefaultArg(int i = 4) : i(i) {}
|
||||
int i;
|
||||
};
|
||||
|
||||
struct ExistingChar {
|
||||
ExistingChar(short) : e1(), e2(), e3(), e4() {}
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: member initializer for 'e1' is redundant [modernize-use-default-member-init]
|
||||
|
|
Loading…
Reference in New Issue