Skip to content

Commit

Permalink
Merge pull request swiftlang#30335 from mikeash/fix-enumtypeinfobuild…
Browse files Browse the repository at this point in the history
…er-dangling-reference
  • Loading branch information
swift-ci authored Mar 10, 2020
2 parents 72fba7d + faa2bf2 commit 7869d94
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions stdlib/public/Reflection/TypeLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ class ExistentialTypeInfoBuilder {
}

if (!isa<ReferenceTypeInfo>(SuperclassTI)) {
DEBUG_LOG(fprintf(stderr, "Superclass not a reference type: ")
DEBUG_LOG(fprintf(stderr, "Superclass not a reference type: ");
SuperclassTI->dump());
Invalid = true;
continue;
Expand Down Expand Up @@ -1134,7 +1134,10 @@ class EnumTypeInfoBuilder {
}

void addCase(const std::string &Name) {
Cases.push_back({Name, /*offset=*/0, /*value=*/-1, nullptr, TypeInfo()});
// FieldInfo's TI field is a reference, so give it a reference to a value
// that stays alive forever.
static TypeInfo emptyTI;
Cases.push_back({Name, /*offset=*/0, /*value=*/-1, nullptr, emptyTI});
}

void addCase(const std::string &Name, const TypeRef *TR,
Expand Down Expand Up @@ -1566,7 +1569,7 @@ const TypeInfo *TypeConverter::getClassInstanceTypeInfo(const TypeRef *TR,
unsigned start) {
auto FD = getBuilder().getFieldTypeInfo(TR);
if (FD == nullptr) {
DEBUG_LOG(fprintf(stderr, "No field descriptor: ";) TR->dump());
DEBUG_LOG(fprintf(stderr, "No field descriptor: "); TR->dump());
return nullptr;
}

Expand Down

0 comments on commit 7869d94

Please sign in to comment.