Skip to content

Commit 1633250

Browse files
h-joonjames93
authored andcommitted
[clang-tidy] Enable the use of IgnoreArray flag in pro-type-member-init rule
The `IgnoreArray` flag was not used before while running the rule. Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=47288 | b/47288 ]] Reviewed By: njames93 Differential Revision: https://reviews.llvm.org/D101239
1 parent 0fb364a commit 1633250

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,8 @@ void ProTypeMemberInitCheck::checkMissingMemberInitializer(
402402
// Gather all fields (direct and indirect) that need to be initialized.
403403
SmallPtrSet<const FieldDecl *, 16> FieldsToInit;
404404
forEachField(ClassDecl, ClassDecl.fields(), [&](const FieldDecl *F) {
405+
if (IgnoreArrays && F->getType()->isArrayType())
406+
return;
405407
if (!F->hasInClassInitializer() &&
406408
utils::type_traits::isTriviallyDefaultConstructible(F->getType(),
407409
Context) &&
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %check_clang_tidy %s \
2+
// RUN: cppcoreguidelines-pro-type-member-init %t \
3+
// RUN: -config="{CheckOptions: \
4+
// RUN: [{key: cppcoreguidelines-pro-type-member-init.IgnoreArrays, value: true} ]}"
5+
6+
typedef int TypedefArray[4];
7+
using UsingArray = int[4];
8+
9+
struct HasArrayMember {
10+
HasArrayMember() {}
11+
// CHECK-MESSAGES: warning: constructor does not initialize these fields: Number
12+
UsingArray U;
13+
TypedefArray T;
14+
int RawArray[4];
15+
int Number;
16+
};

0 commit comments

Comments
 (0)