File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -95,8 +95,19 @@ void UseDesignatedInitializersCheck::check(
95
95
diag (InitList->getLBraceLoc (), " use designated initializer list" );
96
96
return ;
97
97
}
98
- for (const auto *InitExpr : UndesignatedComponents) {
99
- diag (InitExpr->getBeginLoc (), " use designated init expression" );
98
+ const auto FieldIterator = Type->fields ().begin ();
99
+ for (const auto *InitExpr : *SyntacticInitList) {
100
+ const auto Field = std::next (FieldIterator);
101
+ if (std::find (UndesignatedComponents.begin (),
102
+ UndesignatedComponents.end (),
103
+ InitExpr) == UndesignatedComponents.end ())
104
+ continue ;
105
+ if (const auto *FieldID = Field->getIdentifier ()) {
106
+ const auto FieldName = FieldID->getName ();
107
+ diag (InitExpr->getBeginLoc (), " use designated init expression" )
108
+ << FixItHint::CreateInsertion (InitExpr->getBeginLoc (),
109
+ " ." + FieldName.str () + " =" );
110
+ }
100
111
}
101
112
}
102
113
}
You can’t perform that action at this time.
0 commit comments