aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ByteCode/Compiler.cpp
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2025-08-27 14:09:54 +0200
committerGitHub <noreply@github.com>2025-08-27 14:09:54 +0200
commit1eb6c2bd59e3858b6e589a984b4988f5992d61aa (patch)
tree42e301d9eba54fe3dc39cb395263f4e038ec97a8 /clang/lib/AST/ByteCode/Compiler.cpp
parentc5e1ac40f2457eeb47b4555198edf4a49b40675b (diff)
downloadllvm-1eb6c2bd59e3858b6e589a984b4988f5992d61aa.zip
llvm-1eb6c2bd59e3858b6e589a984b4988f5992d61aa.tar.gz
llvm-1eb6c2bd59e3858b6e589a984b4988f5992d61aa.tar.bz2
[clang][bytecode] Reject vectors with non-primitive element types (#155597)
This happens for e.g. arm's float8 types.
Diffstat (limited to 'clang/lib/AST/ByteCode/Compiler.cpp')
-rw-r--r--clang/lib/AST/ByteCode/Compiler.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 8ed9e64..c314f0a 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -1376,11 +1376,17 @@ bool Compiler<Emitter>::VisitComplexBinOp(const BinaryOperator *E) {
template <class Emitter>
bool Compiler<Emitter>::VisitVectorBinOp(const BinaryOperator *E) {
+ const Expr *LHS = E->getLHS();
+ const Expr *RHS = E->getRHS();
assert(!E->isCommaOp() &&
"Comma op should be handled in VisitBinaryOperator");
assert(E->getType()->isVectorType());
- assert(E->getLHS()->getType()->isVectorType());
- assert(E->getRHS()->getType()->isVectorType());
+ assert(LHS->getType()->isVectorType());
+ assert(RHS->getType()->isVectorType());
+
+ // We can only handle vectors with primitive element types.
+ if (!canClassify(LHS->getType()->castAs<VectorType>()->getElementType()))
+ return false;
// Prepare storage for result.
if (!Initializing && !E->isCompoundAssignmentOp() && !E->isAssignmentOp()) {
@@ -1391,8 +1397,6 @@ bool Compiler<Emitter>::VisitVectorBinOp(const BinaryOperator *E) {
return false;
}
- const Expr *LHS = E->getLHS();
- const Expr *RHS = E->getRHS();
const auto *VecTy = E->getType()->getAs<VectorType>();
auto Op = E->isCompoundAssignmentOp()
? BinaryOperator::getOpForCompoundAssignment(E->getOpcode())