[clang] Moves destructor type-trait deduction to a public function (PR #238456)

Corentin Jabot via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 3 11:52:31 PST 2026


================
@@ -16057,6 +16057,38 @@ class Sema final : public SemaBase {
   ///@}
 };
 
+enum class DestructorFormat {
+  // SMF is deleted, private, protected, or otherwise inaccessible.
+  NotAvailable,
+
+  // SMF is trivial.
+  Trivial,
+
+  // SMF is non-trivial and nothrow.
+  NonTrivial,
+};
+
+/// Returns whether a type is trivially-destructible, non-trivially
+/// destructible, or cannot be destroyed in the current context.
+///
+/// It is possible for a type to have a trivial destructor without being
+/// trivially-destructible. For example, `struct S { ~S() = delete; };`
+/// has a trivial destructor: its destructor is non-virtual, all of its
+/// bases have trivial destructors, and all of its members are trivially
+/// destructible. `S` isn't trivially-destructible because its destructor
+/// has been deleted. Similarly, `class C { ~C() = default; }` isn't
+/// trivially-destructible because `~C()`---although trivial for the
+/// same reasons---is private.
+///
+/// This would ideally be placed in `QualType`, but libClangBasic
+/// doesn't include `Sema`.
+DestructorFormat GetDestructorFormat(Sema &S, const ASTContext &C,
----------------
cor3ntin wrote:

```suggestion
DestructorKind GetDestructorKind(Sema &S, const ASTContext &C,
```

Kind is not great but better and I have nothing else

https://github.com/llvm/llvm-project/pull/238456


More information about the cfe-commits mailing list