================ @@ -289,35 +321,213 @@ static void reorderFieldsInConstructor( Replacements); } +/// Replacement for broken InitListExpr::isExplicit function. +/// TODO: Remove when InitListExpr::isExplicit is fixed. +static bool isImplicitILE(const InitListExpr *ILE, const ASTContext &Context) { + // The ILE is implicit if either: + // - The left brace loc of the ILE matches the start of first init expression + // (for non designated decls) + // - The right brace loc of the ILE matches the end of first init expression + // (for designated decls) + // The first init expression should be taken from the syntactic form, but + // since the ILE could be implicit, there might not be a syntactic form. + // For that reason we have to check against all init expressions. + for (const Expr *Init : ILE->inits()) { + if (ILE->getLBraceLoc() == Init->getBeginLoc() || + ILE->getRBraceLoc() == Init->getEndLoc()) + return true; + } + return false; +} + +/// Compares compatible designators according to the new struct order. +/// Returns a negative value if Lhs < Rhs, positive value if Lhs > Rhs and 0 if +/// they are equal. +static int cmpDesignators(const DesignatorIter &Lhs, const DesignatorIter &Rhs, + const ReorderedStruct &Struct) { + if (Lhs.getTag() == DesignatorIter::STRUCT) { ---------------- legrosbuffle wrote:
a `switch` might make this a bit more readable https://github.com/llvm/llvm-project/pull/142150 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits