Skip to content

Commit 7fbfbab

Browse files
authored
[Clang][NFC] Avoid duplication in BuildDeductionGuideForTypeAlias (llvm#161948)
This addresses the post-commit review llvm#161035 (comment) from Shafik
1 parent e95a571 commit 7fbfbab

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

clang/lib/Sema/SemaTemplateDeductionGuide.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,27 +1189,20 @@ BuildDeductionGuideForTypeAlias(Sema &SemaRef,
11891189
// parameter list of a synthesized CTAD guide. See also the FIXME in
11901190
// test/SemaCXX/cxx20-ctad-type-alias.cpp:test25.
11911191
Sema::CheckTemplateArgumentInfo CTAI;
1192+
for (auto TA : Output.arguments())
1193+
if (SemaRef.CheckTemplateArgument(
1194+
TP, TA, F, F->getLocation(), F->getLocation(),
1195+
/*ArgumentPackIndex=*/-1, CTAI,
1196+
Sema::CheckTemplateArgumentKind::CTAK_Specified))
1197+
return nullptr;
11921198
if (Input.getArgument().getKind() == TemplateArgument::Pack) {
1193-
for (auto TA : Output.arguments()) {
1194-
if (SemaRef.CheckTemplateArgument(
1195-
TP, TA, F, F->getLocation(), F->getLocation(),
1196-
/*ArgumentPackIndex=*/-1, CTAI,
1197-
Sema::CheckTemplateArgumentKind::CTAK_Specified))
1198-
return nullptr;
1199-
}
12001199
// We will substitute the non-deduced template arguments with these
12011200
// transformed (unpacked at this point) arguments, where that substitution
12021201
// requires a pack for the corresponding parameter packs.
12031202
TemplateArgsForBuildingFPrime[Index] =
12041203
TemplateArgument::CreatePackCopy(Context, CTAI.SugaredConverted);
12051204
} else {
12061205
assert(Output.arguments().size() == 1);
1207-
TemplateArgumentLoc Transformed = Output.arguments()[0];
1208-
if (SemaRef.CheckTemplateArgument(
1209-
TP, Transformed, F, F->getLocation(), F->getLocation(),
1210-
/*ArgumentPackIndex=*/-1, CTAI,
1211-
Sema::CheckTemplateArgumentKind::CTAK_Specified))
1212-
return nullptr;
12131206
TemplateArgsForBuildingFPrime[Index] = CTAI.SugaredConverted[0];
12141207
}
12151208
}

0 commit comments

Comments
 (0)