diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2023-02-15 10:14:13 +0330 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-02-15 10:14:26 +0100 |
commit | 7f530c075384a7d868736cec67bf6853586a7752 (patch) | |
tree | 3c8adef6c13e92b9dd369c12fc5825c9eeacb915 /Tests/LibRegex | |
parent | af441bb939493671aa89db2f8f1ee6daf6868acc (diff) | |
download | serenity-7f530c075384a7d868736cec67bf6853586a7752.zip |
LibRegex: Bail out of atomic rewrite if a block doesn't contain compares
If a block jumps before performing a compare, we'd need to recursively
find the first of the jumped-to block. While this is doable, it's not
really worth spending the time as most such cases won't actually qualify
for atomic loop rewrite anyway.
Fixes an invalid rewrite when `.+` is followed by an alternation, e.g.
/.+(a|b|c)/.
Diffstat (limited to 'Tests/LibRegex')
-rw-r--r-- | Tests/LibRegex/Regex.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Tests/LibRegex/Regex.cpp b/Tests/LibRegex/Regex.cpp index 82db3cc9c6..3fef06d6d5 100644 --- a/Tests/LibRegex/Regex.cpp +++ b/Tests/LibRegex/Regex.cpp @@ -986,6 +986,8 @@ TEST_CASE(optimizer_atomic_groups) Tuple { "a+"sv, ""sv, false }, // 'y' and [^x] have an overlap ('y'), the loop should not be rewritten here. Tuple { "[^x]+y"sv, "ay"sv, true }, + // .+ should not be rewritten here, as it's followed by something that would be matched by `.`. + Tuple { ".+(a|b|c)"sv, "xxa"sv, true }, }; for (auto& test : tests) { |