Skip to content

Commit 006334e

Browse files
committed
Do not normalize empty FoldExprs?
1 parent bb4e716 commit 006334e

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

clang/lib/Sema/SemaConcept.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,6 +1818,18 @@ substituteParameterMappings(Sema &S, NormalizedConstraint &N,
18181818
return substituteParameterMappings(S, static_cast<AtomicConstraint &>(N),
18191819
MLTAL, ArgsAsWritten);
18201820
case NormalizedConstraint::ConstraintKind::FoldExpanded: {
1821+
auto &FE = static_cast<FoldExpandedConstraint &>(N);
1822+
// FIXME: This is not used.
1823+
ConstraintSatisfaction CS;
1824+
UnsignedOrNone PackSize = EvaluateFoldExpandedConstraintSize(
1825+
S, FE, /*Template=*/nullptr, /*TemplateNameLoc=*/SourceLocation(),
1826+
MLTAL, CS);
1827+
if (!PackSize)
1828+
return true;
1829+
1830+
// Do we need to do something else when pack is empty?
1831+
if (!*PackSize)
1832+
return false;
18211833
Sema::ArgPackSubstIndexRAII _(S, std::nullopt);
18221834
return substituteParameterMappings(
18231835
S, static_cast<FoldExpandedConstraint &>(N).getNormalizedPattern(),

clang/lib/Sema/SemaTemplateInstantiate.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,15 +1896,15 @@ class TemplateInstantiator : public TreeTransform<TemplateInstantiator> {
18961896
return false;
18971897
}
18981898

1899-
TemplateParameterList *
1900-
TransformTemplateParameterList(TemplateParameterList *OrigTPL) {
1901-
if (!OrigTPL || !OrigTPL->size())
1902-
return OrigTPL;
1899+
TemplateParameterList *
1900+
TransformTemplateParameterList(TemplateParameterList *OrigTPL) {
1901+
if (!OrigTPL || !OrigTPL->size())
1902+
return OrigTPL;
19031903

19041904
DeclContext *Owner = OrigTPL->getParam(0)->getDeclContext();
1905-
TemplateDeclInstantiator DeclInstantiator(getSema(),
1906-
/* DeclContext *Owner */ Owner,
1907-
TemplateArgs);
1905+
TemplateDeclInstantiator DeclInstantiator(getSema(),
1906+
/* DeclContext *Owner */ Owner,
1907+
TemplateArgs);
19081908
DeclInstantiator.setEvaluateConstraints(EvaluateConstraints);
19091909
return DeclInstantiator.SubstTemplateParams(OrigTPL);
19101910
}

0 commit comments

Comments
 (0)