Skip to content

Commit 797e137

Browse files
committed
fix
1 parent 922fe8c commit 797e137

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/ir/possible-contents.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -893,12 +893,23 @@ struct InfoCollector
893893

894894
// Creates a location for a root of a particular type, creating a RootLocation
895895
// and marking it as a root.
896-
Location getRootLocation(Type type) {
896+
Location getRootLocation(Type type, PossibleContents rootValue) {
897897
auto location = RootLocation{type};
898-
addRoot(location, PossibleContents::literal(Literal::makeZero(type)));
898+
addRoot(location, rootValue);
899899
return location;
900900
}
901901

902+
// Creates a root location, settings its value by the type.
903+
Location getRootLocation(Type type) {
904+
return getRootLocation(type, PossibleContents::fromType(type));
905+
}
906+
907+
// Makes a root location containing a null.
908+
Location getNullLocation(Type type) {
909+
return getRootLocation(type,
910+
PossibleContents::literal(Literal::makeZero(type)));
911+
}
912+
902913
// Iterates over a list of children and adds links from them. The target of
903914
// those link is created using a function that is passed in, which receives
904915
// the index of the child.
@@ -927,7 +938,7 @@ struct InfoCollector
927938
auto& fields = type.getStruct().fields;
928939
for (Index i = 0; i < fields.size(); i++) {
929940
info.links.push_back(
930-
{getRootLocation(fields[i].type), DataLocation{type, i}});
941+
{getNullLocation(fields[i].type), DataLocation{type, i}});
931942
}
932943
} else {
933944
// Link the operands to the struct's fields.
@@ -947,7 +958,7 @@ struct InfoCollector
947958
{ExpressionLocation{curr->init, 0}, DataLocation{type, 0}});
948959
} else {
949960
info.links.push_back(
950-
{getRootLocation(type.getArray().element.type), DataLocation{type, 0}});
961+
{getNullLocation(type.getArray().element.type), DataLocation{type, 0}});
951962
}
952963
addRoot(curr, PossibleContents::exactType(curr->type));
953964
}
@@ -1334,7 +1345,7 @@ struct InfoCollector
13341345
source = ParamLocation{getFunction(), index};
13351346
} else {
13361347
// This is the default value from the function entry, a null.
1337-
source = getRootLocation(type[i]);
1348+
source = getNullLocation(type[i]);
13381349
}
13391350
info.links.push_back({source, ExpressionLocation{get, i}});
13401351
}

0 commit comments

Comments
 (0)