SILGen: Attach an OwnershipComponent to weak/unowned member references.

Partially fixes <rdar://problem/16989616>, but exposes an IRGen crash (which is likely <rdar://problem/16979789>) behind it.

Swift SVN r18585
This commit is contained in:
Joe Groff
2014-05-23 04:20:25 +00:00
parent 3a07bdbcf7
commit 0141da1107
3 changed files with 19 additions and 3 deletions

View File

@@ -535,7 +535,7 @@ namespace {
}
};
/// Remap an weak value to Optional<T>*, or unowned pointer to T*.
/// Remap a weak value to Optional<T>*, or unowned pointer to T*.
class OwnershipComponent : public LogicalPathComponent {
public:
OwnershipComponent(LValueTypeData typeData)
@@ -715,6 +715,12 @@ LValue SILGenLValue::visitMemberRefExpr(MemberRefExpr *e) {
} else {
lv.add<StructElementComponent>(var, varStorageType, typeData);
}
// If the member has weak or unowned storage, convert it away.
if (varStorageType.is<ReferenceStorageType>()) {
lv.add<OwnershipComponent>(typeData);
}
return std::move(lv);
}