Fix empty foreach in if in constraints (#5408)

Signed-off-by: Krzysztof Bieganski <[email protected]>
This commit is contained in:
Krzysztof Bieganski
2024-08-27 15:39:36 +02:00
committed by GitHub
parent e927536099
commit 155dcc5658
2 changed files with 11 additions and 1 deletions
+3 -1
View File
@@ -695,11 +695,13 @@ class ConstraintExprVisitor final : public VNVisitor {
AstNode* const cstmtp = new AstText{fl, "ret += \" \" + "};
cstmtp->addNext(itemp);
cstmtp->addNext(new AstText{fl, ";"});
AstNode* const exprsp = new AstText{fl, "([&]{ std::string ret = \"(bvand\";"};
AstNode* const exprsp = new AstText{fl, "([&]{ std::string ret;"};
exprsp->addNext(new AstBegin{
fl, "",
new AstForeach{fl, nodep->arrayp()->unlinkFrBack(), new AstCStmt{fl, cstmtp}},
false, true});
exprsp->addNext(
new AstText{fl, "return ret.empty() ? \"#b1\" : \"(bvand \" + ret + \")\";"});
exprsp->addNext(new AstText{fl, "return ret + \")\"; })()"});
AstNodeExpr* const newp = new AstCExpr{fl, exprsp};
newp->dtypeSetString();