Skip to content

Commit ae926bd

Browse files
committed
[RemoteMirror] Fix getEmptyTypeInfo() not allocating a BuiltinTypeInfo.
Allocate an empty BuiltinTypeInfo. The code previously allocated a TypeInfo but set its kind to Builtin, which led to calling code doing an incorrect cast and reading an invalid value for the Name field. rdar://106563125
1 parent 8ddbc68 commit ae926bd

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

include/swift/RemoteInspection/TypeLowering.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,16 @@ class BuiltinTypeInfo : public TypeInfo {
176176
explicit BuiltinTypeInfo(TypeRefBuilder &builder,
177177
RemoteRef<BuiltinTypeDescriptor> descriptor);
178178

179+
/// Construct an empty builtin type info.
180+
BuiltinTypeInfo()
181+
: TypeInfo(TypeInfoKind::Builtin,
182+
/*Size=*/0,
183+
/*Alignment=*/1,
184+
/*Stride=*/1,
185+
/*ExtraInhabitants=*/0,
186+
/*BitwiseTakable=*/true),
187+
Name("") {}
188+
179189
const std::string &getMangledTypeName() const {
180190
return Name;
181191
}

stdlib/public/RemoteInspection/TypeLowering.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,12 +1683,7 @@ const TypeInfo *TypeConverter::getEmptyTypeInfo() {
16831683
if (EmptyTI != nullptr)
16841684
return EmptyTI;
16851685

1686-
EmptyTI = makeTypeInfo<TypeInfo>(TypeInfoKind::Builtin,
1687-
/*Size=*/0,
1688-
/*Alignment=*/1,
1689-
/*Stride=*/1,
1690-
/*ExtraInhabitants=*/0,
1691-
/*BitwiseTakable=*/true);
1686+
EmptyTI = makeTypeInfo<BuiltinTypeInfo>();
16921687
return EmptyTI;
16931688
}
16941689

0 commit comments

Comments
 (0)