Skip to content

Commit df317c0

Browse files
zyn0217cor3ntin
authored andcommitted
Fix CG bug
1 parent a08930e commit df317c0

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

clang/lib/Sema/SemaConcept.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ static ExprResult calculateConstraintSatisfaction(
585585
Sema::ArgPackSubstIndexRAII SubstIndex(S, I);
586586
Satisfaction.IsSatisfied = false;
587587
Satisfaction.ContainsErrors = false;
588+
// FIXME: We can save a substitution if the next constraint is an atomic.
588589
ExprResult Expr = calculateConstraintSatisfaction(
589590
S, FE.getNormalizedPattern(), Template, TemplateNameLoc, MLTAL,
590591
Satisfaction, UnsignedOrNone(I));

clang/lib/Sema/SemaTemplateInstantiate.cpp

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2939,26 +2939,18 @@ TemplateInstantiator::TransformNestedRequirement(
29392939
return Req;
29402940
}
29412941

2942-
#if 0
2943-
if (Req->isDependent() || AlwaysRebuild()) {
2944-
Sema::InstantiatingTemplate ReqInst(
2945-
SemaRef, Constraint->getBeginLoc(), Req,
2946-
Sema::InstantiatingTemplate::ConstraintsCheck{},
2947-
Constraint->getSourceRange());
2948-
2949-
Sema::SFINAETrap Trap(SemaRef);
2950-
2951-
TransConstraint = TransformExpr(const_cast<Expr *>(Constraint));
2952-
if (!TransConstraint.isUsable() || Trap.hasErrorOccurred()) {
2953-
return NestedReqWithDiag(Constraint, std::move(Satisfaction));
2954-
}
2955-
Constraint = TransConstraint.get();
2942+
if (!getEvaluateConstraints()) {
2943+
ExprResult TransConstraint = TransformExpr(Req->getConstraintExpr());
2944+
if (TransConstraint.isInvalid() || !TransConstraint.get())
2945+
return nullptr;
2946+
if (TransConstraint.get()->isInstantiationDependent())
2947+
return new (SemaRef.Context)
2948+
concepts::NestedRequirement(TransConstraint.get());
2949+
ConstraintSatisfaction Satisfaction;
2950+
return new (SemaRef.Context) concepts::NestedRequirement(
2951+
SemaRef.Context, TransConstraint.get(), Satisfaction);
29562952
}
29572953

2958-
if (Constraint->isInstantiationDependent())
2959-
return new (C) concepts::NestedRequirement(Constraint);
2960-
#endif
2961-
29622954
bool Success;
29632955
Expr *NewConstraint;
29642956
TemplateDeductionInfo Info(Constraint->getBeginLoc());
@@ -2991,8 +2983,12 @@ TemplateInstantiator::TransformNestedRequirement(
29912983

29922984
// FIXME: const correctness
29932985
// MLTAL might be dependent.
2994-
if (!NewConstraint)
2986+
if (!NewConstraint) {
2987+
if (!Satisfaction.IsSatisfied)
2988+
return NestedReqWithDiag(Constraint, Satisfaction);
2989+
29952990
NewConstraint = Constraint;
2991+
}
29962992
return new (C) concepts::NestedRequirement(C, NewConstraint, Satisfaction);
29972993
}
29982994

0 commit comments

Comments
 (0)