================ @@ -10918,22 +10944,24 @@ QualType Sema::DeduceTemplateSpecializationFromInitializer( if (!(RD->getDefinition() && RD->isAggregate())) return; QualType Ty = Context.getRecordType(RD); - SmallVector<QualType, 8> ElementTypes; - - InitListChecker CheckInitList(*this, Entity, ListInit, Ty, ElementTypes); - if (!CheckInitList.HadError()) { + auto BuildAggregateDeductionGuide = [&](MutableArrayRef<QualType> + ElementTypes, + bool BracedVersion = false) { + if (ElementTypes.empty()) + return; // C++ [over.match.class.deduct]p1.8: // if e_i is of array type and x_i is a braced-init-list, T_i is an // rvalue reference to the declared type of e_i and // C++ [over.match.class.deduct]p1.9: - // if e_i is of array type and x_i is a bstring-literal, T_i is an + // if e_i is of array type and x_i is a string-literal, T_i is an // lvalue reference to the const-qualified declared type of e_i and // C++ [over.match.class.deduct]p1.10: // otherwise, T_i is the declared type of e_i - for (int I = 0, E = ListInit->getNumInits(); + for (int I = 0, E = BracedVersion ? ElementTypes.size() + : ListInit->getNumInits(); ---------------- hokein wrote:
this loop becomes harder to reason about, the iterator `I` is used to access two containers `ListInit`, `ElementTypes`, can we add some assertions to make sure we don't have out-of-bound issues here? https://github.com/llvm/llvm-project/pull/94889 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits