Skip to content

Commit 7b317dd

Browse files
authored
Merge pull request #16955 from xedin/make-asan-happy-about-generic-reqs
[CSSolver] NFC: Refactor `openGenericRequirements` to fix ASAN failure
2 parents 7f59937 + 7445a96 commit 7b317dd

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,13 +1172,10 @@ void ConstraintSystem::openGenericRequirements(
11721172
for (unsigned pos = 0, n = requirements.size(); pos != n; ++pos) {
11731173
const auto &req = requirements[pos];
11741174

1175-
auto firstType = substFn(req.getFirstType());
1175+
Optional<Requirement> openedReq;
1176+
auto openedFirst = substFn(req.getFirstType());
11761177

11771178
auto kind = req.getKind();
1178-
auto requirementLoc =
1179-
locator.withPathElement(ConstraintLocator::OpenedGeneric)
1180-
.withPathElement(LocatorPathElt::getTypeRequirementComponent(pos));
1181-
11821179
switch (kind) {
11831180
case RequirementKind::Conformance: {
11841181
auto proto = req.getSecondType()->castTo<ProtocolType>();
@@ -1188,19 +1185,22 @@ void ConstraintSystem::openGenericRequirements(
11881185
if (skipProtocolSelfConstraint && protoDecl == outerDC &&
11891186
protoDecl->getSelfInterfaceType()->isEqual(req.getFirstType()))
11901187
continue;
1191-
addConstraint(Requirement(kind, firstType, proto), requirementLoc);
1188+
openedReq = Requirement(kind, openedFirst, proto);
11921189
break;
11931190
}
11941191
case RequirementKind::Superclass:
11951192
case RequirementKind::SameType:
1196-
addConstraint(Requirement(kind, firstType, substFn(req.getSecondType())),
1197-
requirementLoc);
1193+
openedReq = Requirement(kind, openedFirst, substFn(req.getSecondType()));
11981194
break;
11991195
case RequirementKind::Layout:
1200-
addConstraint(Requirement(kind, firstType, req.getLayoutConstraint()),
1201-
requirementLoc);
1196+
openedReq = Requirement(kind, openedFirst, req.getLayoutConstraint());
12021197
break;
12031198
}
1199+
1200+
addConstraint(
1201+
*openedReq,
1202+
locator.withPathElement(ConstraintLocator::OpenedGeneric)
1203+
.withPathElement(LocatorPathElt::getTypeRequirementComponent(pos)));
12041204
}
12051205
}
12061206

0 commit comments

Comments
 (0)