Skip to content

Commit 31b2ffe

Browse files
committed
Improve type hint
1 parent 818762c commit 31b2ffe

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

clang-tools-extra/clang-tidy/modernize/UseDesignatedInitializersCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ void UseDesignatedInitializersCheck::check(
118118
Designator + "=");
119119
}
120120
}
121-
diag(Type->getBeginLoc(), "this is the type to initialize",
121+
diag(Type->getBeginLoc(), "aggregate type is defined here",
122122
DiagnosticIDs::Note);
123123
return;
124124
}

clang-tools-extra/test/clang-tidy/checkers/modernize/use-designated-initializers.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ S2 s21{.i=1, .j =2};
2424

2525
S2 s22 = {1, 2};
2626
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use designated initializer list to initialize 'S2' [modernize-use-designated-initializers]
27-
// CHECK-MESSAGES: :[[@LINE-6]]:1: note: this is the type to initialize
27+
// CHECK-MESSAGES: :[[@LINE-6]]:1: note: aggregate type is defined here
2828
// CHECK-MESSAGES-POD: :[[@LINE-3]]:10: warning: use designated initializer list to initialize 'S2' [modernize-use-designated-initializers]
29-
// CHECK-MESSAGES-POD: :[[@LINE-8]]:1: note: this is the type to initialize
29+
// CHECK-MESSAGES-POD: :[[@LINE-8]]:1: note: aggregate type is defined here
3030
// CHECK-FIXES: S2 s22 = {.i=1, .j=2};
3131

3232
S2 s23{1};
3333
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use designated initializer list to initialize 'S2' [modernize-use-designated-initializers]
34-
// CHECK-MESSAGES: :[[@LINE-13]]:1: note: this is the type to initialize
34+
// CHECK-MESSAGES: :[[@LINE-13]]:1: note: aggregate type is defined here
3535
// CHECK-MESSAGES-POD: :[[@LINE-3]]:7: warning: use designated initializer list to initialize 'S2' [modernize-use-designated-initializers]
36-
// CHECK-MESSAGES-POD: :[[@LINE-15]]:1: note: this is the type to initialize
36+
// CHECK-MESSAGES-POD: :[[@LINE-15]]:1: note: aggregate type is defined here
3737
// CHECK-FIXES: S2 s23{.i=1};
3838

3939
S2 s24{.i = 1};
@@ -58,20 +58,20 @@ S3 s31 = {.s2 = 1, 2, 3.1};
5858

5959
S3 s32 = {{.i = 1, 2}};
6060
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use designated initializer list to initialize 'S3' [modernize-use-designated-initializers]
61-
// CHECK-MESSAGES: :[[@LINE-15]]:1: note: this is the type to initialize
61+
// CHECK-MESSAGES: :[[@LINE-15]]:1: note: aggregate type is defined here
6262
// CHECK-MESSAGES: :[[@LINE-3]]:20: warning: use designated init expression to initialize field 'j' [modernize-use-designated-initializers]
6363
// CHECK-MESSAGES-POD: :[[@LINE-4]]:10: warning: use designated initializer list to initialize 'S3' [modernize-use-designated-initializers]
64-
// CHECK-MESSAGES-POD: :[[@LINE-18]]:1: note: this is the type to initialize
64+
// CHECK-MESSAGES-POD: :[[@LINE-18]]:1: note: aggregate type is defined here
6565
// CHECK-MESSAGES-POD: :[[@LINE-6]]:20: warning: use designated init expression to initialize field 'j' [modernize-use-designated-initializers]
6666
// CHECK-FIXES: S3 s32 = {.s2={.i = 1, .j=2}};
6767

6868
S3 s33 = {{2}, .d=3.1};
6969
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use designated init expression to initialize field 's2' [modernize-use-designated-initializers]
7070
// CHECK-MESSAGES: :[[@LINE-2]]:11: warning: use designated initializer list to initialize 'S2' [modernize-use-designated-initializers]
71-
// CHECK-MESSAGES: :[[@LINE-50]]:1: note: this is the type to initialize
71+
// CHECK-MESSAGES: :[[@LINE-50]]:1: note: aggregate type is defined here
7272
// CHECK-MESSAGES-POD: :[[@LINE-4]]:11: warning: use designated init expression to initialize field 's2' [modernize-use-designated-initializers]
7373
// CHECK-MESSAGES-POD: :[[@LINE-5]]:11: warning: use designated initializer list to initialize 'S2' [modernize-use-designated-initializers]
74-
// CHECK-MESSAGES-POD: :[[@LINE-53]]:1: note: this is the type to initialize
74+
// CHECK-MESSAGES-POD: :[[@LINE-53]]:1: note: aggregate type is defined here
7575
// CHECK-FIXES: S3 s33 = {.s2={.i=2}, .d=3.1};
7676

7777
struct S4 {
@@ -81,12 +81,12 @@ struct S4 {
8181

8282
S4 s41 {2.2};
8383
// CHECK-MESSAGES-SINGLE-ELEMENT: :[[@LINE-1]]:8: warning: use designated initializer list to initialize 'S4' [modernize-use-designated-initializers]
84-
// CHECK-MESSAGES-SINGLE-ELEMENT: :[[@LINE-7]]:1: note: this is the type to initialize
84+
// CHECK-MESSAGES-SINGLE-ELEMENT: :[[@LINE-7]]:1: note: aggregate type is defined here
8585
// CHECK-FIXES-SINGLE-ELEMENT: S4 s41 {.d=2.2};
8686

8787
S4 s42 = {{}};
8888
// CHECK-MESSAGES-SINGLE-ELEMENT: :[[@LINE-1]]:10: warning: use designated initializer list to initialize 'S4' [modernize-use-designated-initializers]
89-
// CHECK-MESSAGES-SINGLE-ELEMENT: :[[@LINE-12]]:1: note: this is the type to initialize
89+
// CHECK-MESSAGES-SINGLE-ELEMENT: :[[@LINE-12]]:1: note: aggregate type is defined here
9090
// CHECK-FIXES-SINGLE-ELEMENT: S4 s42 = {.d={}};
9191

9292
template<typename S> S template1() { return {10, 11}; }
@@ -108,9 +108,9 @@ struct S6 {
108108

109109
S6 s61 {1, 2};
110110
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use designated initializer list to initialize 'S6' [modernize-use-designated-initializers]
111-
// CHECK-MESSAGES: :[[@LINE-7]]:1: note: this is the type to initialize
111+
// CHECK-MESSAGES: :[[@LINE-7]]:1: note: aggregate type is defined here
112112
// CHECK-MESSAGES-POD: :[[@LINE-3]]:8: warning: use designated initializer list to initialize 'S6' [modernize-use-designated-initializers]
113-
// CHECK-MESSAGES-POD: :[[@LINE-9]]:1: note: this is the type to initialize
113+
// CHECK-MESSAGES-POD: :[[@LINE-9]]:1: note: aggregate type is defined here
114114
// CHECK-FIXES: S6 s61 {.i=1, .s.j=2};
115115

116116
struct S7 {
@@ -122,7 +122,7 @@ struct S7 {
122122

123123
S7 s71 {1};
124124
// CHECK-MESSAGES-SINGLE-ELEMENT: :[[@LINE-1]]:8: warning: use designated initializer list to initialize 'S7' [modernize-use-designated-initializers]
125-
// CHECK-MESSAGES-SINGLE-ELEMENT: :[[@LINE-9]]:1: note: this is the type to initialize
125+
// CHECK-MESSAGES-SINGLE-ELEMENT: :[[@LINE-9]]:1: note: aggregate type is defined here
126126
// CHECK-FIXES-SINGLE-ELEMENT: S7 s71 {.u.k=1};
127127

128128
struct S8: S7 { int i; };
@@ -136,7 +136,7 @@ struct S9 {
136136

137137
S9 s91{1, 2};
138138
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use designated initializer list to initialize 'S9' [modernize-use-designated-initializers]
139-
// CHECK-MESSAGES: :[[@LINE-7]]:1: note: this is the type to initialize
139+
// CHECK-MESSAGES: :[[@LINE-7]]:1: note: aggregate type is defined here
140140
// CHECK-FIXES: S9 s91{.i=1, .j=2};
141141

142142
struct S10 { int i = 1, j = 2; };
@@ -150,7 +150,7 @@ struct S11 { int i; S10 s10; };
150150
S11 s111 { .i = 1 };
151151
S11 s112 { 1 };
152152
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use designated initializer list to initialize 'S11' [modernize-use-designated-initializers]
153-
// CHECK-MESSAGES: :[[@LINE-5]]:1: note: this is the type to initialize
153+
// CHECK-MESSAGES: :[[@LINE-5]]:1: note: aggregate type is defined here
154154
// CHECK-FIXES: S11 s112 { .i=1 };
155155

156156
S11 s113 { .i=1, {}};
@@ -168,9 +168,9 @@ struct S12 {
168168

169169
S12 s121 {1, 2};
170170
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use designated initializer list to initialize 'S12' [modernize-use-designated-initializers]
171-
// CHECK-MESSAGES: :[[@LINE-7]]:1: note: this is the type to initialize
171+
// CHECK-MESSAGES: :[[@LINE-7]]:1: note: aggregate type is defined here
172172
// CHECK-MESSAGES-POD: :[[@LINE-3]]:10: warning: use designated initializer list to initialize 'S12' [modernize-use-designated-initializers]
173-
// CHECK-MESSAGES-POD: :[[@LINE-9]]:1: note: this is the type to initialize
173+
// CHECK-MESSAGES-POD: :[[@LINE-9]]:1: note: aggregate type is defined here
174174
// CHECK-FIXES: S12 s121 {.i=1, .j=2};
175175

176176
struct S13 {
@@ -183,9 +183,9 @@ struct S13 {
183183

184184
S13 s131 {1, 2};
185185
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use designated initializer list to initialize 'S13' [modernize-use-designated-initializers]
186-
// CHECK-MESSAGES: :[[@LINE-10]]:1: note: this is the type to initialize
186+
// CHECK-MESSAGES: :[[@LINE-10]]:1: note: aggregate type is defined here
187187
// CHECK-MESSAGES-POD: :[[@LINE-3]]:10: warning: use designated initializer list to initialize 'S13' [modernize-use-designated-initializers]
188-
// CHECK-MESSAGES-POD: :[[@LINE-12]]:1: note: this is the type to initialize
188+
// CHECK-MESSAGES-POD: :[[@LINE-12]]:1: note: aggregate type is defined here
189189
// CHECK-FIXES: S13 s131 {.k=1, .i=2};
190190

191191
#define A (3+2)
@@ -200,4 +200,4 @@ S9 s92 {A, B};
200200
DECLARE_S93;
201201
// CHECK-MESSAGES-MACROS: :[[@LINE-1]]:1: warning: use designated initializer list to initialize 'S9' [modernize-use-designated-initializers]
202202
// CHECK-MESSAGES-MACROS: :[[@LINE-4]]:28: note: expanded from macro 'DECLARE_S93'
203-
// CHECK-MESSAGES-MACROS: :[[@LINE-71]]:1: note: this is the type to initialize
203+
// CHECK-MESSAGES-MACROS: :[[@LINE-71]]:1: note: aggregate type is defined here

0 commit comments

Comments
 (0)