mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-26 02:51:54 +00:00
Determining that a type has trivial destruction requires checking whether all of its subobjects have trivial destruction and whether its type has a custom witness for `Destroy.Op`. This isn't possible when `Destroy` is the custodian for `Destroy.Op` and `SubobjectDestroy.Op`, so we need to make `SubobjectDestroy` its own interface. `Destroy.SelfDestruct` becomes a standalone function because it depends on `SubobjectDestroy` and `Destroy` being implemented, and is also responsible for generating any custom witnesses for both interfaces. Making `SelfDestruct` an interface was experimented with, but this required a blanket impl that caused issues for facet types. `Destroy` depends on `SubobjectDestroy` to be implemented. We'd ideally use `require impls SubobjectDestroy`, but it isn't complete yet, and it also causes problems when `Destroy` is implemented inside the class definition. We work around this by temporarily renaming the `Destroy` interface to `DestroyImpl`, and introducing a constraint called `Destroy` so that user code doesn't need to write `Core.SubobjectDestroy & Core.Destroy`.
49 lines
2.0 KiB
C++
49 lines
2.0 KiB
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
// This is an X-macro header. It does not use `#include` guards, and instead is
|
|
// designed to be `#include`ed after the x-macro is defined in order for its
|
|
// inclusion to expand to the desired output. Macro definitions are cleaned up
|
|
// at the end of this file.
|
|
//
|
|
// Supported x-macro is:
|
|
// - CARBON_SEM_IR_CORE_INTERFACE_KIND(Name)
|
|
// Defines a core interface.
|
|
|
|
#ifndef CARBON_SEM_IR_CORE_INTERFACE_KIND
|
|
#error "Must define CARBON_SEM_IR_CORE_INTERFACE_KIND x-macro to use this file."
|
|
#define CARBON_SEM_IR_CORE_INTERFACE_KIND(Name)
|
|
#endif
|
|
|
|
CARBON_SEM_IR_CORE_INTERFACE_KIND(AddAssignWith)
|
|
CARBON_SEM_IR_CORE_INTERFACE_KIND(AddWith)
|
|
CARBON_SEM_IR_CORE_INTERFACE_KIND(Copy)
|
|
CARBON_SEM_IR_CORE_INTERFACE_KIND(CppRangeForIterate)
|
|
CARBON_SEM_IR_CORE_INTERFACE_KIND(CppUnsafeDeref)
|
|
CARBON_SEM_IR_CORE_INTERFACE_KIND(Dec)
|
|
CARBON_SEM_IR_CORE_INTERFACE_KIND(Default)
|
|
CARBON_SEM_IR_CORE_INTERFACE_KIND(FloatFitsIn)
|
|
CARBON_SEM_IR_CORE_INTERFACE_KIND(DivAssignWith)
|
|
CARBON_SEM_IR_CORE_INTERFACE_KIND(DivWith)
|
|
CARBON_SEM_IR_CORE_INTERFACE_KIND(EqWith)
|
|
CARBON_SEM_IR_CORE_INTERFACE_KIND(Inc)
|
|
CARBON_SEM_IR_CORE_INTERFACE_KIND(IntFitsIn)
|
|
CARBON_SEM_IR_CORE_INTERFACE_KIND(ModAssignWith)
|
|
CARBON_SEM_IR_CORE_INTERFACE_KIND(ModWith)
|
|
CARBON_SEM_IR_CORE_INTERFACE_KIND(MulAssignWith)
|
|
CARBON_SEM_IR_CORE_INTERFACE_KIND(MulWith)
|
|
CARBON_SEM_IR_CORE_INTERFACE_KIND(Negate)
|
|
CARBON_SEM_IR_CORE_INTERFACE_KIND(OrderedWith)
|
|
CARBON_SEM_IR_CORE_INTERFACE_KIND(SubAssignWith)
|
|
CARBON_SEM_IR_CORE_INTERFACE_KIND(SubWith)
|
|
CARBON_SEM_IR_CORE_INTERFACE_KIND(SubobjectDestroy)
|
|
|
|
#ifndef CARBON_SEM_IR_CORE_INTERFACE_EXCLUDE_UNKNOWN
|
|
CARBON_SEM_IR_CORE_INTERFACE_KIND(Unknown)
|
|
#endif // CARBON_SEM_IR_CORE_INTERFACE_EXCLUDE_UNKNOWN
|
|
|
|
#undef CARBON_SEM_IR_CORE_INTERFACE_EXCLUDE_UNKNOWN
|
|
#undef CARBON_SEM_IR_CORE_INTERFACE_KIND
|
|
#undef CARBON_SEM_IR_CORE_INTERFACE_EXCLUDE_UNKNOWN
|