Skip to content

Commit 1ee609a

Browse files
committed
fix libc++ crash
1 parent 4761ace commit 1ee609a

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

clang/include/clang/Sema/SemaConcept.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,23 +131,24 @@ struct NormalizedConstraint {
131131
return *this;
132132
}
133133

134-
CompoundConstraintKind getCompoundKind() const {
135-
assert(!isAtomic() && "getCompoundKind called on atomic constraint.");
136-
return Constraint.get<CompoundConstraint>().getInt();
137-
}
138-
139134
bool isAtomic() const { return Constraint.is<AtomicConstraint *>(); }
140135
bool isFoldExpanded() const {
141136
return Constraint.is<FoldExpandedConstraint *>();
142137
}
138+
bool isCompound() const { return Constraint.is<CompoundConstraint *>(); }
139+
140+
CompoundConstraintKind getCompoundKind() const {
141+
assert(isCompound() && "getCompoundKind on a non-compound constraint..");
142+
return Constraint.get<CompoundConstraint>().getInt();
143+
}
143144

144145
NormalizedConstraint &getLHS() const {
145-
assert(!isAtomic() && "getLHS called on atomic constraint.");
146+
assert(isCompound() && "getLHS called on a non-compound constraint.");
146147
return Constraint.get<CompoundConstraint>().getPointer()->first;
147148
}
148149

149150
NormalizedConstraint &getRHS() const {
150-
assert(!isAtomic() && "getRHS called on atomic constraint.");
151+
assert(isCompound() && "getRHS called on a non-compound constraint.");
151152
return Constraint.get<CompoundConstraint>().getPointer()->second;
152153
}
153154

clang/lib/Sema/SemaConcept.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1397,13 +1397,22 @@ substituteParameterMappings(Sema &S, NormalizedConstraint &N,
13971397
ConceptDecl *Concept,
13981398
const MultiLevelTemplateArgumentList &MLTAL,
13991399
const ASTTemplateArgumentListInfo *ArgsAsWritten) {
1400-
if (!N.isAtomic()) {
1400+
1401+
if (N.isCompound()) {
14011402
if (substituteParameterMappings(S, N.getLHS(), Concept, MLTAL,
14021403
ArgsAsWritten))
14031404
return true;
14041405
return substituteParameterMappings(S, N.getRHS(), Concept, MLTAL,
14051406
ArgsAsWritten);
14061407
}
1408+
1409+
if (N.isFoldExpanded()) {
1410+
Sema::ArgumentPackSubstitutionIndexRAII _(S, -1);
1411+
return substituteParameterMappings(
1412+
S, N.getFoldExpandedConstraint()->Constraint, Concept, MLTAL,
1413+
ArgsAsWritten);
1414+
}
1415+
14071416
TemplateParameterList *TemplateParams = Concept->getTemplateParameters();
14081417

14091418
AtomicConstraint &Atomic = *N.getAtomicConstraint();

0 commit comments

Comments
 (0)