mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-12-26 09:41:03 +00:00
Clarify: Ok to pass null diagnostic to spvBinaryParse
It's a valid use case: I might mostly trust my binaries and I don't care to to collect detailed diagnostic feedback.
This commit is contained in:
parent
5c9080eea8
commit
4e2ed04d6e
@ -430,10 +430,10 @@ typedef spv_result_t (*spv_parsed_instruction_fn_t)(
|
||||
// callback once for each instruction in the stream. The user_data parameter
|
||||
// is supplied as context to the callbacks. Returns SPV_SUCCESS on successful
|
||||
// parse where the callbacks always return SPV_SUCCESS. For an invalid parse,
|
||||
// returns a status code other than SPV_SUCCESS and emits a diagnostic. If a
|
||||
// callback returns anything other than SPV_SUCCESS, then that status code
|
||||
// is returned, no further callbacks are issued, and no additional diagnostics
|
||||
// are emitted.
|
||||
// returns a status code other than SPV_SUCCESS, and if diagnostic is non-null
|
||||
// also emits a diagnostic. If a callback returns anything other than
|
||||
// SPV_SUCCESS, then that status code is returned, no further callbacks are
|
||||
// issued, and no additional diagnostics are emitted.
|
||||
spv_result_t spvBinaryParse(const spv_const_context context, void* user_data,
|
||||
const uint32_t* words, const size_t num_words,
|
||||
spv_parsed_header_fn_t parse_header,
|
||||
|
@ -237,6 +237,27 @@ TEST_F(BinaryParseTest, EmptyModuleHasValidHeaderAndNoInstructionCallbacks) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(BinaryParseTest, NullDiagnosticsIsOkForGoodParse) {
|
||||
const auto words = CompileSuccessfully("");
|
||||
EXPECT_HEADER(1).WillOnce(Return(SPV_SUCCESS));
|
||||
EXPECT_CALL(client_, Instruction(_)).Times(0); // No instruction callback.
|
||||
EXPECT_EQ(
|
||||
SPV_SUCCESS,
|
||||
spvBinaryParse(ScopedContext().context, &client_, words.data(),
|
||||
words.size(), invoke_header, invoke_instruction, nullptr));
|
||||
}
|
||||
|
||||
TEST_F(BinaryParseTest, NullDiagnosticsIsOkForBadParse) {
|
||||
auto words = CompileSuccessfully("");
|
||||
words.push_back(0xffffffff); // Certainly invalid instruction header.
|
||||
EXPECT_HEADER(1).WillOnce(Return(SPV_SUCCESS));
|
||||
EXPECT_CALL(client_, Instruction(_)).Times(0); // No instruction callback.
|
||||
EXPECT_EQ(
|
||||
SPV_ERROR_INVALID_BINARY,
|
||||
spvBinaryParse(ScopedContext().context, &client_, words.data(),
|
||||
words.size(), invoke_header, invoke_instruction, nullptr));
|
||||
}
|
||||
|
||||
TEST_F(BinaryParseTest,
|
||||
ModuleWithSingleInstructionHasValidHeaderAndInstructionCallback) {
|
||||
for (bool endian_swap : kSwapEndians) {
|
||||
|
Loading…
Reference in New Issue
Block a user