================ @@ -1731,31 +1731,21 @@ namespace { return inherited::TransformLambdaBody(E, Body); } - ExprResult RebuildSizeOfPackExpr(SourceLocation OperatorLoc, - NamedDecl *Pack, SourceLocation PackLoc, - SourceLocation RParenLoc, - std::optional<unsigned> Length, - ArrayRef<TemplateArgument> PartialArgs) { - if (SemaRef.CodeSynthesisContexts.back().Kind != - Sema::CodeSynthesisContext::ConstraintNormalization) - return inherited::RebuildSizeOfPackExpr(OperatorLoc, Pack, PackLoc, - RParenLoc, Length, PartialArgs); - -#ifndef NDEBUG - for (auto *Iter = TemplateArgs.begin(); Iter != TemplateArgs.end(); - ++Iter) - for (const TemplateArgument &TA : Iter->Args) - assert(TA.getKind() != TemplateArgument::Pack || TA.pack_size() == 1); -#endif - Sema::ArgumentPackSubstitutionIndexRAII SubstIndex( - SemaRef, /*NewSubstitutionIndex=*/0); - Decl *NewPack = TransformDecl(PackLoc, Pack); - if (!NewPack) - return ExprError(); - - return inherited::RebuildSizeOfPackExpr(OperatorLoc, - cast<NamedDecl>(NewPack), PackLoc, - RParenLoc, Length, PartialArgs); + ExprResult TransformSizeOfPackExpr(SizeOfPackExpr *E) { + ExprResult Transformed = inherited::TransformSizeOfPackExpr(E); + if (!Transformed.isUsable()) + return Transformed; + auto *TransformedExpr = cast<SizeOfPackExpr>(Transformed.get()); + if (SemaRef.CodeSynthesisContexts.back().Kind == + Sema::CodeSynthesisContext::ConstraintNormalization && + TransformedExpr->getPack() == E->getPack()) { + Decl *NewPack = + TransformDecl(E->getPackLoc(), TransformedExpr->getPack()); + if (!NewPack) + return ExprError(); + TransformedExpr->setPack(cast<NamedDecl>(NewPack)); ---------------- mizvekov wrote:
It looks like there is some dance here that could be avoided if we moved this into the inherited transform function in TreeTransform.h instead. https://github.com/llvm/llvm-project/pull/115120 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits