Skip to content

Commit 6dca32d

Browse files
author
Daniel Kroening
committed
format_expr: no parentheses if subexpression isn't an infix operator
1 parent c3cefb2 commit 6dca32d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/util/format_expr.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ static bool bracket_subexpression(const exprt &sub_expr, const exprt &expr)
6363
if(!sub_expr.has_operands())
6464
return false;
6565

66+
// no need if subexpression isn't an infix operator
67+
if(infix_map.find(sub_expr.id()) == infix_map.end())
68+
return false;
69+
6670
// * and / bind stronger than + and -
6771
if(
6872
(sub_expr.id() == ID_mult || sub_expr.id() == ID_div) &&

unit/solvers/miniBDD/miniBDD.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ SCENARIO("miniBDD", "[core][solver][miniBDD]")
347347
{
348348
std::ostringstream oss;
349349
oss << format(o);
350-
REQUIRE(oss.str() == "(a ∧ b) ∨ (¬a)");
350+
REQUIRE(oss.str() == "(a ∧ b) ∨ ¬a");
351351
}
352352

353353
bdd_exprt t(ns);
@@ -356,7 +356,7 @@ SCENARIO("miniBDD", "[core][solver][miniBDD]")
356356
{
357357
std::ostringstream oss;
358358
oss << format(t.as_expr());
359-
REQUIRE(oss.str() == "(¬a) ∨ b");
359+
REQUIRE(oss.str() == "¬a ∨ b");
360360
}
361361
}
362362
}

0 commit comments

Comments
 (0)