mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 07:24:42 +01:00
Support conversion from T* to const T*. (#5971)
Also support conversion from Derived* to const Base*. --------- Co-authored-by: josh11b <15258583+josh11b@users.noreply.github.com>
This commit is contained in:
@@ -136,6 +136,16 @@ auto GetConstType(Context& context, SemIR::TypeInstId inner_type_id)
|
||||
return GetTypeImpl<SemIR::ConstType>(context, inner_type_id);
|
||||
}
|
||||
|
||||
auto GetQualifiedType(Context& context, SemIR::TypeId type_id,
|
||||
SemIR::TypeQualifiers quals) -> SemIR::TypeId {
|
||||
if ((quals & SemIR::TypeQualifiers::Const) != SemIR::TypeQualifiers::None) {
|
||||
type_id = GetConstType(context, context.types().GetInstId(type_id));
|
||||
quals &= ~SemIR::TypeQualifiers::Const;
|
||||
}
|
||||
CARBON_CHECK(quals == SemIR::TypeQualifiers::None);
|
||||
return type_id;
|
||||
}
|
||||
|
||||
auto GetSingletonType(Context& context, SemIR::TypeInstId singleton_id)
|
||||
-> SemIR::TypeId {
|
||||
CARBON_CHECK(SemIR::IsSingletonInstId(singleton_id));
|
||||
|
||||
Reference in New Issue
Block a user