https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/149253
getParam already returns NamedDecl *. >From 2f93bbada1bdc3980948fc6e147542af5e937400 Mon Sep 17 00:00:00 2001 From: Kazu Hirata <k...@google.com> Date: Tue, 15 Jul 2025 09:12:18 -0700 Subject: [PATCH] [Sema] Remove unnecessary casts (NFC) getParam already returns NamedDecl *. --- clang/lib/Sema/SemaTemplateDeduction.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp index d09a72b71b805..e1a975bcfb3e1 100644 --- a/clang/lib/Sema/SemaTemplateDeduction.cpp +++ b/clang/lib/Sema/SemaTemplateDeduction.cpp @@ -3083,8 +3083,7 @@ static TemplateDeductionResult ConvertDeducedTemplateArguments( // If there was no default argument, deduction is incomplete. if (DefArg.getArgument().isNull()) { - Info.Param = makeTemplateParameter( - const_cast<NamedDecl *>(TemplateParams->getParam(I))); + Info.Param = makeTemplateParameter(TemplateParams->getParam(I)); Info.reset( TemplateArgumentList::CreateCopy(S.Context, CTAI.SugaredConverted), TemplateArgumentList::CreateCopy(S.Context, CTAI.CanonicalConverted)); @@ -3100,8 +3099,7 @@ static TemplateDeductionResult ConvertDeducedTemplateArguments( if (S.CheckTemplateArgument( Param, DefArg, TD, TD->getLocation(), TD->getSourceRange().getEnd(), /*ArgumentPackIndex=*/0, CTAI, Sema::CTAK_Specified)) { - Info.Param = makeTemplateParameter( - const_cast<NamedDecl *>(TemplateParams->getParam(I))); + Info.Param = makeTemplateParameter(TemplateParams->getParam(I)); // FIXME: These template arguments are temporary. Free them! Info.reset( TemplateArgumentList::CreateCopy(S.Context, CTAI.SugaredConverted), @@ -3227,7 +3225,7 @@ static TemplateDeductionResult FinishTemplateArgumentDeduction( if (ParamIdx >= TPL->size()) ParamIdx = TPL->size() - 1; - Decl *Param = const_cast<NamedDecl *>(TPL->getParam(ParamIdx)); + Decl *Param = TPL->getParam(ParamIdx); Info.Param = makeTemplateParameter(Param); Info.FirstArg = Ps[ArgIdx].getArgument(); return TemplateDeductionResult::SubstitutionFailure; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits