[clang] [analyzer] Fix unary/binary op support for SMT symbolic execution (PR #205078)
Balázs Benics via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 29 03:13:46 PDT 2026
================
@@ -342,6 +342,30 @@ class SMTConv {
Ctx.getTypeSize(FromTy));
}
+ static inline llvm::SMTExprRef convertToBoolExpr(llvm::SMTSolverRef &Solver,
+ ASTContext &Ctx,
+ const llvm::SMTExprRef &Exp,
+ QualType Ty) {
+ if (Ty->isBooleanType())
+ return Exp;
+
+ if (Ty->isRealFloatingType()) {
+ llvm::APFloat Zero =
+ llvm::APFloat::getZero(Ctx.getFloatTypeSemantics(Ty));
+ return fromFloatBinOp(Solver, Exp, BO_NE, Solver->mkFloat(Zero));
+ }
+
+ if (Ty->isIntegralOrEnumerationType() || Ty->isAnyPointerType() ||
+ Ty->isBlockPointerType() || Ty->isReferenceType()) {
+ return fromBinOp(
+ Solver, Exp, BO_NE,
+ Solver->mkBitvector(llvm::APSInt("0"), Ctx.getTypeSize(Ty)),
----------------
steakhal wrote:
I think we could do better than parsing "0" and constructing an APSInt from it. Isn't there some static method that would create you an APSInt of zero with the right bitwidth?
https://github.com/llvm/llvm-project/pull/205078
More information about the cfe-commits
mailing list