[clang] [clang] Implement `__builtin_is_implicit_lifetime()` (PR #101807)
Vlad Serebrennikov via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 13 01:58:18 PDT 2024
================
@@ -5637,6 +5638,27 @@ 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);
+ QualType UnqualT = T->getCanonicalTypeUnqualified();
+ if (UnqualT->isScalarType())
----------------
Endilll wrote:
I updated the patch with more tests for FP and extensions. I discovered that vector types are not considered implicit-lifetime, so I made them so. Here are tests I left out, because Clang told me ~~to go away~~ that they are not supported on the target or require special compiler flags (matrix). I took that as going over the board w.r.t. other type traits tests.
```cpp
typedef float m4x4_t __attribute__((matrix_type(4, 4)));
static_assert(__builtin_is_implicit_lifetime(__SVInt8_t));
static_assert(__builtin_is_implicit_lifetime(__rvv_int8mf8_t));
static_assert(__builtin_is_implicit_lifetime(half));
static_assert(__builtin_is_implicit_lifetime(__float128));
static_assert(__builtin_is_implicit_lifetime(__ibm128));
static_assert(__builtin_is_implicit_lifetime(__externref_t));
static_assert(__builtin_is_implicit_lifetime(__externref_t[2]));
static_assert(__builtin_is_implicit_lifetime(m4x4_t));
```
@AaronBallman Let me know if something is surprising to you, or if I forgot anything.
https://github.com/llvm/llvm-project/pull/101807
More information about the cfe-commits
mailing list