Regex fuzzer: replace the value of an integer with

a value in the set {INT_MAX, INT_MIN, -1 or 0}.

A mutation that replaces the value of a randomly-chosen integer with a value
in the set {INT_MAX, INT_MIN, -1, 0}.

Fixes: tint:1093.

Change-Id: I5ec69e1813785760ed6e7b06d0cbd9c481f69ade
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60920
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Alastair Donaldson <afdx@google.com>
Commit-Queue: Alastair Donaldson <afdx@google.com>
This commit is contained in:
egj
2021-08-05 22:24:20 +00:00
committed by Tint LUCI CQ
parent a958c89aae
commit 608738d59b
4 changed files with 136 additions and 7 deletions

View File

@@ -35,6 +35,8 @@ enum class MutationKind {
kSwapIntervals,
kDeleteInterval,
kDuplicateInterval,
kReplaceIdentifier,
kReplaceLiteral,
kNumMutationKinds
};
@@ -78,6 +80,18 @@ extern "C" size_t LLVMFuzzerCustomMutator(uint8_t* data,
}
break;
case MutationKind::kReplaceIdentifier:
if (!ReplaceRandomIdentifier(wgsl_code, generator)) {
return 0;
}
break;
case MutationKind::kReplaceLiteral:
if (!ReplaceRandomIntLiteral(wgsl_code, generator)) {
return 0;
}
break;
default:
assert(false && "Unreachable");
return 0;