Regex fuzzer: Add return statement inside a randomly-chosen function

Adds a return statement in the body of a randomly-chosen function.
The return value is a randomly-chosen identifier or literal from
the WGSL shader.

Fixes: tint:1115.

Change-Id: Icdc4ff669cda343244e158ce791b4085fd52f7b9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61781
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-09-28 14:57:54 +00:00
committed by Tint LUCI CQ
parent 9c7cd9e9c3
commit 2228ad19af
5 changed files with 419 additions and 41 deletions

View File

@@ -37,6 +37,7 @@ enum class MutationKind {
kDuplicateInterval,
kReplaceIdentifier,
kReplaceLiteral,
kInsertReturnStatement,
kNumMutationKinds
};
@@ -95,6 +96,12 @@ extern "C" size_t LLVMFuzzerCustomMutator(uint8_t* data,
}
break;
case MutationKind::kInsertReturnStatement:
if (!InsertReturnStatement(wgsl_code, generator)) {
return 0;
}
break;
default:
assert(false && "Unreachable");
return 0;