@@ -3095,7 +3095,7 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity,
30953095 }
30963096
30973097 const auto GenerateDesignatedInitReorderingFixit =
3098- [&](SemaBase::SemaDiagnosticBuilder &Diags ) {
3098+ [&](SemaBase::SemaDiagnosticBuilder &Diag ) {
30993099 struct ReorderInfo {
31003100 int Pos{};
31013101 const Expr *InitExpr{};
@@ -3107,18 +3107,17 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity,
31073107 const auto *CxxRecord =
31083108 IList->getSemanticForm ()->getType ()->getAsCXXRecordDecl ();
31093109
3110- for (const auto & Field : CxxRecord->fields ()) {
3110+ for (const FieldDecl * Field : CxxRecord->fields ())
31113111 MemberNameInx[Field->getIdentifier ()] = Field->getFieldIndex ();
3112- }
31133112
3114- for (const auto *Init : IList->inits ()) {
3113+ for (const Expr *Init : IList->inits ()) {
31153114 if (const auto *DI =
31163115 dyn_cast_if_present<DesignatedInitExpr>(Init)) {
31173116 // We expect only one Designator
31183117 if (DI->size () != 1 )
31193118 return ;
31203119
3121- const auto *const FieldName =
3120+ const IdentifierInfo *const FieldName =
31223121 DI->getDesignator (0 )->getFieldName ();
31233122 // In case we have an unknown initializer in the source, not in
31243123 // the record
@@ -3128,28 +3127,29 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity,
31283127 }
31293128 }
31303129
3131- llvm::sort (ReorderedInitExprs, [](const auto &A, const auto &B) {
3132- return A.Pos < B.Pos ;
3133- });
3130+ llvm::sort (ReorderedInitExprs,
3131+ [](const ReorderInfo &A, const ReorderInfo &B) {
3132+ return A.Pos < B.Pos ;
3133+ });
31343134
31353135 llvm::SmallString<128 > FixedInitList{};
31363136 SourceManager &SM = SemaRef.getSourceManager ();
31373137 const LangOptions &LangOpts = SemaRef.getLangOpts ();
31383138
31393139 // In a derived Record, first n base-classes are initialized first.
31403140 // They do not use designated init, so skip them
3141- const auto IListInits =
3141+ const ArrayRef<clang::Expr *> IListInits =
31423142 IList->inits ().drop_front (CxxRecord->getNumBases ());
31433143 // loop over each existing expressions and apply replacement
31443144 for (const auto &[OrigExpr, Repl] :
31453145 llvm::zip (IListInits, ReorderedInitExprs)) {
31463146 CharSourceRange CharRange = CharSourceRange::getTokenRange (
31473147 Repl.InitExpr ->getSourceRange ());
3148- const auto InitText =
3148+ const StringRef InitText =
31493149 Lexer::getSourceText (CharRange, SM, LangOpts);
31503150
3151- Diags << FixItHint::CreateReplacement (OrigExpr->getSourceRange (),
3152- InitText.str ());
3151+ Diag << FixItHint::CreateReplacement (OrigExpr->getSourceRange (),
3152+ InitText.str ());
31533153 }
31543154 };
31553155
@@ -3162,10 +3162,10 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity,
31623162 unsigned OldIndex = StructuredIndex - 1 ;
31633163 if (StructuredList && OldIndex <= StructuredList->getNumInits ()) {
31643164 if (Expr *PrevInit = StructuredList->getInit (OldIndex)) {
3165- auto Diags = SemaRef.Diag (PrevInit->getBeginLoc (),
3166- diag::note_previous_field_init)
3167- << PrevField << PrevInit->getSourceRange ();
3168- GenerateDesignatedInitReorderingFixit (Diags );
3165+ auto Diag = SemaRef.Diag (PrevInit->getBeginLoc (),
3166+ diag::note_previous_field_init)
3167+ << PrevField << PrevInit->getSourceRange ();
3168+ GenerateDesignatedInitReorderingFixit (Diag );
31693169 }
31703170 }
31713171 }
0 commit comments