[clang] 7c3d6c8 - [clang][bytecode] Avoid classify()ing logical binary operators (#219943)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 31 06:02:55 PDT 2026
Author: Timm Baeder
Date: 2026-08-31T15:02:49+02:00
New Revision: 7c3d6c86bbd3ac6b43cb74937821ad8b9b39c43d
URL: https://github.com/llvm/llvm-project/commit/7c3d6c86bbd3ac6b43cb74937821ad8b9b39c43d
DIFF: https://github.com/llvm/llvm-project/commit/7c3d6c86bbd3ac6b43cb74937821ad8b9b39c43d.diff
LOG: [clang][bytecode] Avoid classify()ing logical binary operators (#219943)
We can just check `isBooleanType()` instead.
Added:
Modified:
clang/lib/AST/ByteCode/Compiler.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index a65a0441bba62..55abd51659b46 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -1551,7 +1551,6 @@ bool Compiler<Emitter>::VisitLogicalBinOp(const BinaryOperator *E) {
BinaryOperatorKind Op = E->getOpcode();
const Expr *LHS = E->getLHS();
const Expr *RHS = E->getRHS();
- OptPrimType T = classify(E->getType());
if (Op == BO_LOr) {
// Logical OR. Visit LHS and only evaluate RHS if LHS was FALSE.
@@ -1600,9 +1599,10 @@ bool Compiler<Emitter>::VisitLogicalBinOp(const BinaryOperator *E) {
return this->emitPopBool(E);
// For C, cast back to integer type.
- assert(T);
- if (T != PT_Bool)
- return this->emitCast(PT_Bool, *T, E);
+ if (!E->getType()->isBooleanType()) {
+ PrimType T = classifyPrim(E->getType());
+ return this->emitCast(PT_Bool, T, E);
+ }
return true;
}
More information about the cfe-commits
mailing list