aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ByteCode/Compiler.cpp
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2025-08-02 16:18:38 +0200
committerGitHub <noreply@github.com>2025-08-02 16:18:38 +0200
commita1dfcc6e8154bb8c188062f0a50436a27b54f763 (patch)
tree27259d5feffb344945d4eb96341b885c0361c405 /clang/lib/AST/ByteCode/Compiler.cpp
parentacdc01b0392343daa7b91a34ba5d9c45372ed1bf (diff)
downloadllvm-a1dfcc6e8154bb8c188062f0a50436a27b54f763.zip
llvm-a1dfcc6e8154bb8c188062f0a50436a27b54f763.tar.gz
llvm-a1dfcc6e8154bb8c188062f0a50436a27b54f763.tar.bz2
[clang][bytecode] Fix D3DCOLORtoUBYTE4 hlsl test (#151819)
HLSL is using CK_FloatingToIntegral casts to cast to vectors, which we don't support (neither does the current interpreter). Also fix a crash when trying to promote the HLSL bool, which can't be promoted it seems.
Diffstat (limited to 'clang/lib/AST/ByteCode/Compiler.cpp')
-rw-r--r--clang/lib/AST/ByteCode/Compiler.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 8b9e5e0..6e451ac 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -331,6 +331,8 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
}
case CK_FloatingToIntegral: {
+ if (!CE->getType()->isIntegralOrEnumerationType())
+ return false;
if (!this->visit(SubExpr))
return false;
PrimType ToT = classifyPrim(CE);
@@ -1369,10 +1371,15 @@ bool Compiler<Emitter>::VisitVectorBinOp(const BinaryOperator *E) {
// BitAdd/BitOr/BitXor/Shl/Shr doesn't support bool type, we need perform the
// integer promotion.
bool NeedIntPromot = ElemT == PT_Bool && (E->isBitwiseOp() || E->isShiftOp());
- QualType PromotTy =
- Ctx.getASTContext().getPromotedIntegerType(Ctx.getASTContext().BoolTy);
- PrimType PromotT = classifyPrim(PromotTy);
- PrimType OpT = NeedIntPromot ? PromotT : ElemT;
+ QualType PromotTy;
+ PrimType PromotT = PT_Bool;
+ PrimType OpT = ElemT;
+ if (NeedIntPromot) {
+ PromotTy =
+ Ctx.getASTContext().getPromotedIntegerType(Ctx.getASTContext().BoolTy);
+ PromotT = classifyPrim(PromotTy);
+ OpT = PromotT;
+ }
auto getElem = [=](unsigned Offset, PrimType ElemT, unsigned Index) {
if (!this->emitGetLocal(PT_Ptr, Offset, E))