|
|
@@ -164,45 +164,6 @@ struct InitRepr : Printable<InitRepr> {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-// Information about a function's return type.
|
|
|
-struct ReturnTypeInfo : public Printable<ReturnTypeInfo> {
|
|
|
- // Builds return type information for a given function.
|
|
|
- static auto ForFunction(const File& file, const Function& function,
|
|
|
- SpecificId specific_id = SpecificId::None)
|
|
|
- -> ReturnTypeInfo {
|
|
|
- auto type_id = function.GetDeclaredReturnType(file, specific_id);
|
|
|
- return {.type_id = type_id,
|
|
|
- .init_repr = type_id.has_value()
|
|
|
- ? InitRepr::ForType(file, type_id)
|
|
|
- : InitRepr{.kind = InitRepr::None}};
|
|
|
- }
|
|
|
-
|
|
|
- // Builds return type information for the function corresponding to callee_id
|
|
|
- // in caller_specific_id.
|
|
|
- static auto ForCallee(const File& file, InstId callee_id,
|
|
|
- SpecificId caller_specific_id = SemIR::SpecificId::None)
|
|
|
- -> ReturnTypeInfo;
|
|
|
-
|
|
|
- // Returns whether the return information could be fully computed.
|
|
|
- auto is_valid() const -> bool { return init_repr.is_valid(); }
|
|
|
-
|
|
|
- // Returns whether a function with this return type has a return slot. Can
|
|
|
- // only be called for valid return info.
|
|
|
- auto has_return_slot() const -> bool {
|
|
|
- CARBON_CHECK(is_valid());
|
|
|
- return init_repr.MightBeInPlace();
|
|
|
- }
|
|
|
-
|
|
|
- auto Print(llvm::raw_ostream& out) const -> void {
|
|
|
- out << "{type_id: " << type_id << ", init_repr: " << init_repr << "}";
|
|
|
- }
|
|
|
-
|
|
|
- // The declared return type. `None` if no return type was specified.
|
|
|
- TypeId type_id;
|
|
|
- // The initializing representation for the return type.
|
|
|
- InitRepr init_repr;
|
|
|
-};
|
|
|
-
|
|
|
// Information about the numeric type literal that corresponds to a type.
|
|
|
struct NumericTypeLiteralInfo {
|
|
|
// The kind of a numeric type literal, as determined by the letter that
|