Addressed code review comments.
diff --git a/source/fuzz/fuzzer_pass_donate_modules.cpp b/source/fuzz/fuzzer_pass_donate_modules.cpp
index d9176e3..4ba5305 100644
--- a/source/fuzz/fuzzer_pass_donate_modules.cpp
+++ b/source/fuzz/fuzzer_pass_donate_modules.cpp
@@ -397,7 +397,7 @@
} break;
case SpvOpConstantNull: {
if (!original_id_to_donated_id->count(type_or_value.type_id())) {
- // We did not denote the type associated with this null constant, so
+ // We did not donate the type associated with this null constant, so
// we cannot donate the null constant.
continue;
}
diff --git a/source/fuzz/fuzzer_util.cpp b/source/fuzz/fuzzer_util.cpp
index 90cf9fe..4d85984 100644
--- a/source/fuzz/fuzzer_util.cpp
+++ b/source/fuzz/fuzzer_util.cpp
@@ -537,6 +537,13 @@
return 0;
}
+bool IsNullConstantSupported(const opt::analysis::Type& type) {
+ return type.AsBool() || type.AsInteger() || type.AsFloat() ||
+ type.AsMatrix() || type.AsVector() || type.AsArray() ||
+ type.AsStruct() || type.AsPointer() || type.AsEvent() ||
+ type.AsDeviceEvent() || type.AsReserveId() || type.AsQueue();
+}
+
} // namespace fuzzerutil
} // namespace fuzz
diff --git a/source/fuzz/fuzzer_util.h b/source/fuzz/fuzzer_util.h
index 08edfc5..886029a 100644
--- a/source/fuzz/fuzzer_util.h
+++ b/source/fuzz/fuzzer_util.h
@@ -210,6 +210,10 @@
uint32_t MaybeGetPointerType(opt::IRContext* context, uint32_t pointee_type_id,
SpvStorageClass storage_class);
+// Returns true if and only if |type| is one of the types for which it is legal
+// to have an OpConstantNull value.
+bool IsNullConstantSupported(const opt::analysis::Type& type);
+
} // namespace fuzzerutil
} // namespace fuzz
diff --git a/source/fuzz/transformation_add_constant_null.cpp b/source/fuzz/transformation_add_constant_null.cpp
index 489790e..dedbc21 100644
--- a/source/fuzz/transformation_add_constant_null.cpp
+++ b/source/fuzz/transformation_add_constant_null.cpp
@@ -42,10 +42,7 @@
}
// The type must be one of the types for which null constants are allowed,
// according to the SPIR-V spec.
- return type->AsBool() || type->AsInteger() || type->AsFloat() ||
- type->AsMatrix() || type->AsVector() || type->AsArray() ||
- type->AsStruct() || type->AsPointer() || type->AsEvent() ||
- type->AsDeviceEvent() || type->AsReserveId() || type->AsQueue();
+ return fuzzerutil::IsNullConstantSupported(*type);
}
void TransformationAddConstantNull::Apply(