[clang] [Clang][NFC] Avoid duplication in BuildDeductionGuideForTypeAlias (PR #161948)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 3 22:50:23 PDT 2025
https://github.com/zyn0217 created https://github.com/llvm/llvm-project/pull/161948
This addresses the post-commit review from Shafik.
>From bbb086aa3bd4bfbfa40149084c3cbad08fe5f35e Mon Sep 17 00:00:00 2001
From: Younan Zhang <zyn7109 at gmail.com>
Date: Sat, 4 Oct 2025 13:48:59 +0800
Subject: [PATCH] [Clang][NFC] Avoid duplication in
BuildDeductionGuideForTypeAlias
This addresses the post-commit review from Shafik.
---
clang/lib/Sema/SemaTemplateDeductionGuide.cpp | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
index 9a61888e318b3..8ba23aa334afd 100644
--- a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
+++ b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
@@ -1189,14 +1189,13 @@ BuildDeductionGuideForTypeAlias(Sema &SemaRef,
// parameter list of a synthesized CTAD guide. See also the FIXME in
// test/SemaCXX/cxx20-ctad-type-alias.cpp:test25.
Sema::CheckTemplateArgumentInfo CTAI;
+ for (auto TA : Output.arguments())
+ if (SemaRef.CheckTemplateArgument(
+ TP, TA, F, F->getLocation(), F->getLocation(),
+ /*ArgumentPackIndex=*/-1, CTAI,
+ Sema::CheckTemplateArgumentKind::CTAK_Specified))
+ return nullptr;
if (Input.getArgument().getKind() == TemplateArgument::Pack) {
- for (auto TA : Output.arguments()) {
- if (SemaRef.CheckTemplateArgument(
- TP, TA, F, F->getLocation(), F->getLocation(),
- /*ArgumentPackIndex=*/-1, CTAI,
- Sema::CheckTemplateArgumentKind::CTAK_Specified))
- return nullptr;
- }
// We will substitute the non-deduced template arguments with these
// transformed (unpacked at this point) arguments, where that substitution
// requires a pack for the corresponding parameter packs.
@@ -1204,12 +1203,6 @@ BuildDeductionGuideForTypeAlias(Sema &SemaRef,
TemplateArgument::CreatePackCopy(Context, CTAI.SugaredConverted);
} else {
assert(Output.arguments().size() == 1);
- TemplateArgumentLoc Transformed = Output.arguments()[0];
- if (SemaRef.CheckTemplateArgument(
- TP, Transformed, F, F->getLocation(), F->getLocation(),
- /*ArgumentPackIndex=*/-1, CTAI,
- Sema::CheckTemplateArgumentKind::CTAK_Specified))
- return nullptr;
TemplateArgsForBuildingFPrime[Index] = CTAI.SugaredConverted[0];
}
}
More information about the cfe-commits
mailing list