Merge pull request #6135 from jckarter/use-sil-box-field-accessors-4

Mangle SILBoxTypes with their layout.
This commit is contained in:
Joe Groff
2016-12-08 21:09:31 -08:00
committed by GitHub
13 changed files with 321 additions and 12 deletions

View File

@@ -1217,11 +1217,28 @@ void Mangler::mangleType(Type type, unsigned uncurryLevel) {
return;
}
case TypeKind::SILBox:
Buffer << 'X' << 'b';
mangleType(cast<SILBoxType>(tybase)->getBoxedType(),
uncurryLevel);
case TypeKind::SILBox: {
Buffer << 'X' << 'B';
auto boxTy = cast<SILBoxType>(tybase);
// TODO: Should layouts get substitutions?
auto layout = boxTy->getLayout();
if (auto sig = layout->getGenericSignature()) {
Buffer << 'G';
mangleGenericSignature(sig);
}
for (auto &field : layout->getFields()) {
Buffer << (field.isMutable() ? 'm' : 'i');
mangleType(field.getLoweredType(), 0);
}
Buffer << '_';
if (!boxTy->getGenericArgs().empty()) {
for (auto &arg : boxTy->getGenericArgs()) {
mangleType(arg.getReplacement(), 0);
}
Buffer << '_';
}
return;
}
case TypeKind::SILBlockStorage:
llvm_unreachable("should never be mangled");
@@ -1229,6 +1246,11 @@ void Mangler::mangleType(Type type, unsigned uncurryLevel) {
llvm_unreachable("bad type kind");
}
void Mangler::mangleLegacyBoxType(CanType fieldType) {
Buffer << 'X' << 'b';
mangleType(fieldType, 0);
}
/// Mangle a list of protocols. Each protocol is a substitution
/// candidate.
/// <protocol-list> ::= <protocol-name>+