-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor ReturnTypeInfo
and InitRepr
.
#4169
Refactor ReturnTypeInfo
and InitRepr
.
#4169
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, feel free to merge when you're comfortable (unless you do a big refactor again, I guess)
toolchain/sem_ir/type_info.h
Outdated
}; | ||
|
||
// Returns information about the initializing representation to use for a type. | ||
auto GetInitRepr(const File& file, TypeId type_id) -> InitRepr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be InitRepr::ForType similar to below? (plus, member functions for factories makes sense to me)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
toolchain/sem_ir/function.h
Outdated
auto GetReturnTypeInfo(const File& file, | ||
SpecificId specific_id = SpecificId::Invalid) const | ||
-> ReturnTypeInfo { | ||
return ReturnTypeInfo::ForType(file, | ||
GetDeclaredReturnType(file, specific_id)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, if it worked, maybe ReturnTypeInfo::ForFunction instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Rename `ReturnInfo` to `ReturnTypeInfo`. Move it and `InitRepr` into `type_info.h` alongside `ValueRepr`. Replace `ReturnSlot` with `InitRepr`, and extend `InitRepr` to be able to represent the incomplete-type case instead of CHECK-failing. Remove `has_return_slot` from `InitRepr` and instead only provide that as part of `ReturnTypeInfo`.
Rename
ReturnInfo
toReturnTypeInfo
. Move it andInitRepr
intotype_info.h
alongsideValueRepr
. ReplaceReturnSlot
withInitRepr
, and extendInitRepr
to be able to represent the incomplete-type case instead of CHECK-failing. Removehas_return_slot
fromInitRepr
and instead only provide that as part ofReturnTypeInfo
.