[clang] [Clang][Interp] Diagnose use sizeless vector type as the argument of `__builtin_vectorelements` (PR #99794)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Sat Jul 20 23:23:12 PDT 2024


================
@@ -1698,10 +1698,8 @@ bool Compiler<Emitter>::VisitUnaryExprOrTypeTraitExpr(
   if (Kind == UETT_VectorElements) {
     if (const auto *VT = E->getTypeOfArgument()->getAs<VectorType>())
       return this->emitConst(VT->getNumElements(), E);
-
-    // FIXME: Apparently we need to catch the fact that a sizeless vector type
-    // has been passed and diagnose that (at run time).
-    assert(E->getTypeOfArgument()->isSizelessVectorType());
+    if (E->getTypeOfArgument()->isSizelessVectorType())
+      return this->emitSizelessVectorElementSize(E);
----------------
tbaederr wrote:

```suggestion
    assert(E->getTypeOfArgument()->isSizelessVectorType());
    return this->emitSizelessVectorElementSize(E);
```

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


More information about the cfe-commits mailing list