Skip to content

Commit b78ad96

Browse files
committed
IRGen: TypeConverter::convertType() always returns a complete type
1 parent d9d64db commit b78ad96

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

lib/IRGen/GenType.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,15 +1467,7 @@ TypeCacheEntry TypeConverter::getTypeEntry(CanType canonicalTy) {
14671467
}
14681468

14691469
// Convert the type.
1470-
TypeCacheEntry convertedEntry = convertType(exemplarTy);
1471-
auto convertedTI = convertedEntry.dyn_cast<const TypeInfo*>();
1472-
1473-
// If that gives us a forward declaration (which can happen with
1474-
// bound generic types), don't propagate that into the cache here,
1475-
// because we won't know how to clear it later.
1476-
if (!convertedTI) {
1477-
return convertedEntry;
1478-
}
1470+
auto *convertedTI = convertType(exemplarTy);
14791471

14801472
// Cache the entry under the original type and the exemplar type, so that
14811473
// we can avoid relowering equivalent types.
@@ -1600,7 +1592,7 @@ convertPrimitiveBuiltin(IRGenModule &IGM, CanType canTy) {
16001592
}
16011593
}
16021594

1603-
TypeCacheEntry TypeConverter::convertType(CanType ty) {
1595+
const TypeInfo *TypeConverter::convertType(CanType ty) {
16041596
PrettyStackTraceType stackTrace(IGM.Context, "converting", ty);
16051597

16061598
switch (ty->getKind()) {
@@ -1828,8 +1820,8 @@ static bool isIRTypeDependent(IRGenModule &IGM, NominalTypeDecl *decl) {
18281820
}
18291821
}
18301822

1831-
TypeCacheEntry TypeConverter::convertAnyNominalType(CanType type,
1832-
NominalTypeDecl *decl) {
1823+
const TypeInfo *TypeConverter::convertAnyNominalType(CanType type,
1824+
NominalTypeDecl *decl) {
18331825
// By "any", we don't mean existentials.
18341826
assert(!isa<ProtocolDecl>(decl));
18351827

@@ -1871,7 +1863,7 @@ TypeCacheEntry TypeConverter::convertAnyNominalType(CanType type,
18711863
auto &Cache = Types.getCacheFor(/*isDependent*/ false, CompletelyFragile);
18721864
auto entry = Cache.find(key);
18731865
if (entry != Cache.end())
1874-
return entry->second;
1866+
return entry->second.get<const TypeInfo *>();
18751867

18761868
switch (decl->getKind()) {
18771869
#define NOMINAL_TYPE_DECL(ID, PARENT)

lib/IRGen/GenType.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ class TypeConverter {
102102

103103
void addForwardDecl(TypeBase *key, llvm::Type *type);
104104

105-
TypeCacheEntry convertType(CanType T);
106-
TypeCacheEntry convertAnyNominalType(CanType T, NominalTypeDecl *D);
105+
const TypeInfo *convertType(CanType T);
106+
const TypeInfo *convertAnyNominalType(CanType T, NominalTypeDecl *D);
107107
const TypeInfo *convertTupleType(TupleType *T);
108108
const TypeInfo *convertClassType(CanType type, ClassDecl *D);
109109
const TypeInfo *convertEnumType(TypeBase *key, CanType type, EnumDecl *D);

0 commit comments

Comments
 (0)