[clang-tidy] Ignore implicit casts in modernize-use-default-member-init

Summary:
Initialising a pointer from nullptr involves an implicit cast.
Ignore it after getting initialiser from InitListExpr.

Fixes: PR44440

Reviewers: aaron.ballman, alexfh, JonasToth

Reviewed By: JonasToth

Subscribers: xazax.hun, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72630
This commit is contained in:
Malcolm Parsons 2020-01-14 09:54:31 +00:00
parent ec6579fc04
commit 45924eb467
2 changed files with 5 additions and 5 deletions

View File

@ -137,7 +137,7 @@ static const Expr *ignoreUnaryPlus(const Expr *E) {
static const Expr *getInitializer(const Expr *E) {
auto *InitList = dyn_cast<InitListExpr>(E);
if (InitList && InitList->getNumInits() == 1)
return InitList->getInit(0);
return InitList->getInit(0)->IgnoreParenImpCasts();
return E;
}

View File

@ -291,7 +291,7 @@ struct ExistingInt {
int e1{};
int e2 = 0;
int e3 = {5};
int e4 = 5;
int e4{5};
int e5 = -5;
int e6 = +5;
};
@ -315,7 +315,7 @@ struct ExistingDouble {
double e1{};
double e2 = 0.0;
double e3 = 5.0;
double e4 = -5.0;
double e4{-5.0};
double e5 = +5.0;
};
@ -333,7 +333,7 @@ struct ExistingBool {
// CHECK-FIXES: ExistingBool(long) : e1(true), e2(true) {}
bool e1{};
bool e2 = false;
bool e3 = true;
bool e3{true};
};
struct ExistingEnum {
@ -365,7 +365,7 @@ struct ExistingPointer {
// CHECK-FIXES: ExistingPointer(long) : e4(&e2) {}
int *e1{};
int *e2 = 0;
int *e3 = nullptr;
int *e3{nullptr};
int **e4 = &e1;
};