Add missing operator to regex fuzzer
Fixes a problem where the regex fuzzer would identify '==' as a
candidate operator for replacement, but where the replacement code did
not actually handle the '==' case.
Fixes http://crbug.com/1367902
Change-Id: I9a3bda9e7bae5e42872f17427419ab690d477533
Change-Id: If9cbb2db779c6873ff7a02d132981e8ee3410bb1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104200
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Alastair Donaldson <afdx@google.com>
diff --git a/src/tint/fuzzers/tint_regex_fuzzer/wgsl_mutator.cc b/src/tint/fuzzers/tint_regex_fuzzer/wgsl_mutator.cc
index c5125a4..7d16aad 100644
--- a/src/tint/fuzzers/tint_regex_fuzzer/wgsl_mutator.cc
+++ b/src/tint/fuzzers/tint_regex_fuzzer/wgsl_mutator.cc
@@ -416,7 +416,7 @@
"=", "+=", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "<<=", ">>="};
std::vector<std::string> expression_operators{"+", "-", "*", "/", "%", "&&", "||",
"&", "|", "^", "<<", ">>", "<", ">",
- "<=", ">=", "!", "!=", "~"};
+ "<=", ">=", "!", "==", "!=", "~"};
std::vector<std::string> increment_operators{"++", "--"};
for (auto operators : {assignment_operators, expression_operators, increment_operators}) {
auto it = std::find(operators.begin(), operators.end(), existing_operator);
@@ -471,6 +471,12 @@
switch (first_character) {
case '!':
case '^':
+ case '*':
+ case '/':
+ case '%':
+ case '=':
+ // The above cases are all stand-alone operators, and if followed by '=' are also
+ // operators.
switch (second_character) {
case '=':
return {{current_index, 2}};
@@ -481,26 +487,15 @@
case '&':
case '+':
case '-':
+ // The above cases are all stand-alone operators, and if repeated or followed by '='
+ // are also operators.
if (second_character == first_character || second_character == '=') {
return {{current_index, 2}};
}
return {{current_index, 1}};
- case '*':
- case '/':
- case '%':
- switch (second_character) {
- case '=':
- return {{current_index, 2}};
- default:
- return {{current_index, 1}};
- }
- case '=':
- if (second_character == '=') {
- return {{current_index, 2}};
- }
- return {{current_index, 1}};
case '<':
case '>':
+ // The following caters for '<', '<=', '<<', '<<=', '>', '>=', '>>' and '>>='.
if (second_character == '=') {
return {{current_index, 2}};
}