Skip to content

Commit 6253e8c

Browse files
authored
Merge pull request #6388 from thomasspriggs/tas/comment-regex
Address incremental SMT2 related code review comments from PR6357
2 parents 39685c7 + 200500c commit 6253e8c

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/solvers/smt2_incremental/smt2_incremental_decision_procedure.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void smt2_incremental_decision_proceduret::define_dependent_functions(
4949
return expr_identifier.first;
5050
});
5151
std::stack<exprt> to_be_defined;
52-
const auto dependencies_needed = [&](const exprt &expr) {
52+
const auto push_dependencies_needed = [&](const exprt &expr) {
5353
bool result = false;
5454
for(const auto &dependency : gather_dependent_expressions(expr))
5555
{
@@ -60,11 +60,11 @@ void smt2_incremental_decision_proceduret::define_dependent_functions(
6060
}
6161
return result;
6262
};
63-
dependencies_needed(expr);
63+
push_dependencies_needed(expr);
6464
while(!to_be_defined.empty())
6565
{
6666
const exprt current = to_be_defined.top();
67-
if(dependencies_needed(current))
67+
if(push_dependencies_needed(current))
6868
continue;
6969
if(const auto symbol_expr = expr_try_dynamic_cast<symbol_exprt>(current))
7070
{
@@ -81,7 +81,7 @@ void smt2_incremental_decision_proceduret::define_dependent_functions(
8181
}
8282
else
8383
{
84-
if(dependencies_needed(symbol->value))
84+
if(push_dependencies_needed(symbol->value))
8585
continue;
8686
const smt_define_function_commandt function{
8787
symbol->name, {}, convert_expr_to_smt(symbol->value)};

src/solvers/smt2_incremental/smt_terms.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,19 @@ bool smt_bool_literal_termt::value() const
5050

5151
static bool is_valid_smt_identifier(irep_idt identifier)
5252
{
53-
static const std::regex valid{R"(^[^\|]*$)"};
53+
// The below regex matches a complete string which does not contain the `|`
54+
// character. So it would match the string `foo bar`, but not `|foo bar|`.
55+
static const std::regex valid{"[^\\|]*"};
5456
return std::regex_match(id2string(identifier), valid);
5557
}
5658

5759
smt_identifier_termt::smt_identifier_termt(irep_idt identifier, smt_sortt sort)
5860
: smt_termt(ID_smt_identifier_term, std::move(sort))
5961
{
62+
// The below invariant exists as a sanity check that the string being used for
63+
// the identifier is in unescaped form. This is because the escaping and
64+
// unescaping are implementation details of the printing to string and
65+
// response parsing respectively, not part of the underlying data.
6066
INVARIANT(
6167
is_valid_smt_identifier(identifier),
6268
R"(Identifiers may not contain | characters.)");

0 commit comments

Comments
 (0)