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

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 23 22:10:59 PST 2026


================
@@ -16112,6 +16112,48 @@ class Sema final : public SemaBase {
   ///@}
 };
 
+/// Evaluates whether a type is trivially-destructible, non-trivially
+/// destructible, or cannot be destroyed in the current context. Caches
+/// the results from evaluation to allow for independently determining
+/// if the type's destructor throws.
+class DestructibleTraits {
+public:
+  /// Indicates whether a type is trivially-destructible, non-trivially
+  /// destructible, or not destructible.
+  enum class Destructibility : std::uint8_t {
+    /// Type is not destructible from this context.
+    NotAvailable,
+
+    /// Type is trivially-destructible.
+    TriviallyDestructible,
+
+    /// Type is destructible, but not trivially-destructible.
+    Destructible,
+  };
+
+  DestructibleTraits(Sema &S, const ASTContext &C, SourceLocation Loc,
+                     QualType T);
+
+  /// Returns the raw destructor kind.
+  Destructibility GetKind() const;
+
+  /// Returns true if, and only if, the type is destructible.
+  bool IsDestructible() const;
+
+  /// Returns true if, and only if, the type is trivially-destructible.
+  bool IsTriviallyDestructible() const;
+
+  /// Returns true if, and only if, the type is destructible, and the chosen
+  /// destructor is non-throwing.
+  bool IsNoThrowDestructible(Sema &S, const ASTContext &C);
----------------
tbaederr wrote:

```suggestion
  bool isNoThrowDestructible(Sema &S, const ASTContext &C);
```

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


More information about the cfe-commits mailing list