Skip to content

Commit 9fa0918

Browse files
committed
Fix guard identifier processing
The identifier for guards includes the `\` character. Therefore this commit is needed for allowing smt identifiers to be constructed including this character and converted to string.
1 parent 0a38415 commit 9fa0918

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/solvers/smt2_incremental/smt_terms.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ 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+
static const std::regex valid{R"(^[^\|]*$)"};
5454
return std::regex_match(id2string(identifier), valid);
5555
}
5656

@@ -59,7 +59,7 @@ smt_identifier_termt::smt_identifier_termt(irep_idt identifier, smt_sortt sort)
5959
{
6060
INVARIANT(
6161
is_valid_smt_identifier(identifier),
62-
R"(Identifiers may not contain | or \ characters.)");
62+
R"(Identifiers may not contain | characters.)");
6363
set(ID_identifier, identifier);
6464
}
6565

unit/solvers/smt2_incremental/smt_to_smt2_string.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ TEST_CASE(
3232
CHECK(smt_to_smt2_string(smt_bool_literal_termt{false}) == "false");
3333
}
3434

35+
TEST_CASE(
36+
"Test smt_identifier_termt to string conversion",
37+
"[core][smt2_incremental]")
38+
{
39+
CHECK(
40+
smt_to_smt2_string(smt_identifier_termt{"abc", smt_bool_sortt{}}) ==
41+
"|abc|");
42+
CHECK(
43+
smt_to_smt2_string(smt_identifier_termt{"\\", smt_bool_sortt{}}) ==
44+
"|&92;|");
45+
}
46+
3547
TEST_CASE(
3648
"Test smt_function_application_termt to string conversion",
3749
"[core][smt2_incremental]")

0 commit comments

Comments
 (0)