[clang] [clang] Deduplicate FinishTemplateArgumentDeduction helper (PR #173622)

via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 26 01:11:53 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: saumya singh (saumyasingh-111)

<details>
<summary>Changes</summary>

Summary:
This PR removes duplicate implementations of the FinishTemplateArgumentDeduction helper function in SemaTemplateDeduction.cpp.

Changes Made:
- Consolidated three duplicated versions of FinishTemplateArgumentDeduction into a single implementation.
- Updated all call sites to use the unified helper function.
- Ensured semantic behavior remains unchanged.
- I've introduced a single internal helper, `FinishTemplateArgumentDeductionImpl`, which handles the shared logic. I then refactored the existing call sites to use this centralized version.

Testing:
- Ran existing clang/test/SemaCXX/ tests to verify no regressions.
- All relevant tests pass successfully.
- 
Related Issue:
- Resolves Issue #<!-- -->92224 

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


1 Files Affected:

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


``````````diff
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp
index a287319cc4f88..161ff3af895a2 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3353,6 +3353,19 @@ static TemplateDeductionResult FinishTemplateArgumentDeduction(
 
   return TemplateDeductionResult::Success;
 }
+
+static TemplateDeductionResult FinishTemplateArgumentDeductionImpl(
+    Sema &S, NamedDecl *Entity, TemplateParameterList *EntityTPL,
+    TemplateDecl *Template, bool PartialOrdering,
+    ArrayRef<TemplateArgumentLoc> Ps, ArrayRef<TemplateArgument> As,
+    SmallVectorImpl<DeducedTemplateArgument> &Deduced,
+    TemplateDeductionInfo &Info, bool CopyDeducedArgs) {
+  return FinishTemplateArgumentDeduction(
+      S, Entity, EntityTPL, Template,
+      PartialOrdering, Ps, As, Deduced, Info, CopyDeducedArgs);
+}
+
+
 static TemplateDeductionResult FinishTemplateArgumentDeduction(
     Sema &S, NamedDecl *Entity, TemplateParameterList *EntityTPL,
     TemplateDecl *Template, bool PartialOrdering, ArrayRef<TemplateArgument> Ps,

``````````

</details>


https://github.com/llvm/llvm-project/pull/173622


More information about the cfe-commits mailing list