[clang] [clang][Sema] Allow splat initialization of a sizeless vector in a C++ code (PR #205432)
Benjamin Maxwell via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 1 03:47:49 PDT 2026
================
@@ -8058,7 +8057,14 @@ bool Sema::CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty,
}
ExprResult Sema::prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr) {
- QualType DestElemTy = VectorTy->castAs<VectorType>()->getElementType();
+ QualType DestElemTy =
+ VectorTy->isSizelessVectorType()
+ ? VectorTy->isSveVLSBuiltinType() || VectorTy->isRVVVLSBuiltinType()
+ ? Context
+ .getBuiltinVectorTypeInfo(VectorTy->castAs<BuiltinType>())
+ .ElementType
+ : VectorTy->getSizelessVectorEltType(Context)
+ : VectorTy->castAs<VectorType>()->getElementType();
----------------
MacDue wrote:
This would be much easier to read as a helper like:
```c++
static QualType getVectorElementType(ASTContext &Context, QualType VecTy) {
if (const auto *TyA = VecTy->getAs<VectorType>())
return TyA->getElementType();
if (VecTy->isSizelessVectorType())
return VecTy->getSizelessVectorEltType(Context);
return QualType();
}
```
(which already exists in SemaChecking, so maybe factor this to some common code). Also, getSizelessVectorEltType looks like it already handles SVE and RVV builtins (so does not need additional handling here).
https://github.com/llvm/llvm-project/pull/205432
More information about the cfe-commits
mailing list