Improve support for qualification conversions. (#5999)

* Treat `MaybeUnformed` and `partial` as qualifiers, like `const`.
* Allow pointer conversions to add qualifiers.
* Allow unsafe pointer conversions to remove qualifiers.
* Allow conversions on non-reference expressions to drop `const`.
* Allow unsafe conversions on any expression to drop `const`.
* Allow unsafe conversions on non-initializing expressions to drop
  `partial`. For initializing expressions, we should initialize the
  vptr when dropping `partial`; this is not yet supported so we reject.
* Allow conversions on reference expressions to add `MaybeUnformed`.
* Allow unsafe conversions on reference expressions to drop
  `MaybeUnformed`. For non-reference expressions, additional work is
  required, because the value / initializing representation may not
  match between `T` and `MaybeUnformed(T)`, so those are rejected for
  now.
This commit is contained in:
Richard Smith
2025-09-03 21:00:12 +00:00
committed by GitHub
parent 10fab24451
commit cb5e2e1597
15 changed files with 1285 additions and 100 deletions
+1 -2
View File
@@ -764,8 +764,7 @@ static auto BuildTypeForInst(FileContext& context, SemIR::ClassType inst)
}
template <typename InstT>
requires(InstT::Kind.template IsAnyOf<
SemIR::ConstType, SemIR::MaybeUnformedType, SemIR::PartialType>())
requires(SemIR::Internal::HasInstCategory<SemIR::AnyQualifiedType, InstT>)
static auto BuildTypeForInst(FileContext& context, InstT inst) -> llvm::Type* {
return context.GetType(
context.sem_ir().types().GetTypeIdForTypeInstId(inst.inner_id));