[clang] [Sema] Remove unnecessary casts (NFC) (PR #149253)

2025-07-17 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata closed 
https://github.com/llvm/llvm-project/pull/149253
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Sema] Remove unnecessary casts (NFC) (PR #149253)

2025-07-16 Thread Matt Arsenault via cfe-commits

https://github.com/arsenm approved this pull request.


https://github.com/llvm/llvm-project/pull/149253
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Sema] Remove unnecessary casts (NFC) (PR #149253)

2025-07-16 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Kazu Hirata (kazutakahirata)


Changes

getParam already returns NamedDecl *.


---
Full diff: https://github.com/llvm/llvm-project/pull/149253.diff


1 Files Affected:

- (modified) clang/lib/Sema/SemaTemplateDeduction.cpp (+3-5) 


``diff
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(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(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(TPL->getParam(ParamIdx));
+Decl *Param = TPL->getParam(ParamIdx);
 Info.Param = makeTemplateParameter(Param);
 Info.FirstArg = Ps[ArgIdx].getArgument();
 return TemplateDeductionResult::SubstitutionFailure;

``




https://github.com/llvm/llvm-project/pull/149253
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Sema] Remove unnecessary casts (NFC) (PR #149253)

2025-07-16 Thread Kazu Hirata via cfe-commits

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 
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(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(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(TPL->getParam(ParamIdx));
+Decl *Param = TPL->getParam(ParamIdx);
 Info.Param = makeTemplateParameter(Param);
 Info.FirstArg = Ps[ArgIdx].getArgument();
 return TemplateDeductionResult::SubstitutionFailure;

___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits