Remove the type field from semantics nodes that don't produce values of that type. (#3049)

For `Assign` and `ReturnExpression`, this field wasn't used for
anything. For `StructTypeField`, we stored the type of the field here,
and now store it as an argument of the node instead.

---------

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
Richard Smith
2023-08-02 17:30:27 +00:00
committed by GitHub
co-authored by Jon Ross-Perkins
parent ab709b4117
commit 0c33dead70
71 changed files with 170 additions and 162 deletions
+5 -4
View File
@@ -149,12 +149,13 @@ auto LoweringContext::BuildType(SemanticsNodeId node_id) -> llvm::Type* {
llvm::SmallVector<llvm::Type*> subtypes;
subtypes.reserve(refs.size());
for (auto ref_id : refs) {
auto type_id = semantics_ir_->GetNode(ref_id).type_id();
auto [field_name_id, field_type_id] =
semantics_ir_->GetNode(ref_id).GetAsStructTypeField();
// TODO: Handle recursive types. The restriction for builtins prevents
// recursion while still letting them cache.
CARBON_CHECK(type_id.index < SemanticsBuiltinKind::ValidCount)
<< type_id;
subtypes.push_back(GetType(type_id));
CARBON_CHECK(field_type_id.index < SemanticsBuiltinKind::ValidCount)
<< field_type_id;
subtypes.push_back(GetType(field_type_id));
}
return llvm::StructType::create(*llvm_context_, subtypes,
"StructLiteralType");