[clang] [clang] Implement `__builtin_is_implicit_lifetime()` (PR #101807)

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 14 06:04:08 PDT 2024


================
@@ -5637,6 +5638,38 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, TypeTrait UTT,
     return false;
   case UTT_IsTriviallyEqualityComparable:
     return isTriviallyEqualityComparableType(Self, T, KeyLoc);
+  case UTT_IsImplicitLifetime: {
+    DiagnoseVLAInCXXTypeTrait(Self, TInfo,
+                              tok::kw___builtin_is_implicit_lifetime);
+
+    // [basic.types.general] p9
+    // Scalar types, implicit-lifetime class types ([class.prop]),
+    // array types, and cv-qualified versions of these types
+    // are collectively called implicit-lifetime types.
+    QualType UnqualT = T->getCanonicalTypeUnqualified();
----------------
Endilll wrote:

After an offline discussion, I believe we agreed on not doing anything special for `_Atomic` for the lack of better alternatives. This can result in discrepancies between `__builtin_is_implicit_lifetime(std::atomic<T>)` (that might yield `true` depending on `std::atomic` implementation) and `__builtin_is_implicit_lifetime(_Atomic T)` (which is always `false`), but that's not new (https://godbolt.org/z/7e7954b8c).

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


More information about the cfe-commits mailing list