summaryrefslogtreecommitdiff
path: root/src/theory
diff options
context:
space:
mode:
authorAndres Noetzli <andres.noetzli@gmail.com>2019-03-22 03:48:56 +0000
committerGitHub <noreply@github.com>2019-03-22 03:48:56 +0000
commitb80720f15170b02cbc93a53095ec2dd96bb8029c (patch)
tree3dc2245110cf7f9e149a59e9250bc6ff1f4b66c7 /src/theory
parenta20702bcbb04422ddfcda5a241fd0cc0ec32edc8 (diff)
Fix stripConstantEndpoints in strings rewriter (#2883)
`TheoryStringsRewriter::stripConstantEndpoints()` returns the stripped endpoints in the vectors `nb` and `ne`. These endpoints were not computed correctly if string literal had to be split. For example: ``` stripConstantEndpoints({ "ABC" }, { "C" }, {}, {}, 1) ``` returned `true` and only "A" for `nb` (instead of "AB") because we mistakenly used the amount of overlap between "ABC" and "C" (which is one) for the length of the stripped prefix. This commit fixes the issue and adds several unit tests.
Diffstat (limited to 'src/theory')
-rw-r--r--src/theory/strings/theory_strings_rewriter.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/theory/strings/theory_strings_rewriter.cpp b/src/theory/strings/theory_strings_rewriter.cpp
index 79667b9aa..0763fa7d5 100644
--- a/src/theory/strings/theory_strings_rewriter.cpp
+++ b/src/theory/strings/theory_strings_rewriter.cpp
@@ -3613,6 +3613,8 @@ bool TheoryStringsRewriter::stripConstantEndpoints(std::vector<Node>& n1,
{
Assert(nb.empty());
Assert(ne.empty());
+
+ NodeManager* nm = NodeManager::currentNM();
bool changed = false;
// for ( forwards, backwards ) direction
for (unsigned r = 0; r < 2; r++)
@@ -3693,15 +3695,13 @@ bool TheoryStringsRewriter::stripConstantEndpoints(std::vector<Node>& n1,
// component
if (r == 0)
{
- nb.push_back(
- NodeManager::currentNM()->mkConst(s.prefix(overlap)));
- n1[index0] = NodeManager::currentNM()->mkConst(s.suffix(overlap));
+ nb.push_back(nm->mkConst(s.prefix(s.size() - overlap)));
+ n1[index0] = nm->mkConst(s.suffix(overlap));
}
else
{
- ne.push_back(
- NodeManager::currentNM()->mkConst(s.suffix(overlap)));
- n1[index0] = NodeManager::currentNM()->mkConst(s.prefix(overlap));
+ ne.push_back(nm->mkConst(s.suffix(s.size() - overlap)));
+ n1[index0] = nm->mkConst(s.prefix(overlap));
}
}
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback