mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-12-25 01:01:04 +00:00
Added missing diagnostic when disassembling empty file.
Added diagnostic messages for what should be an internal failure that never happens. I figure if we return "failed" for something the user cannot control we should print a message for it.
This commit is contained in:
parent
08d89bb7a5
commit
4b4acded77
@ -439,7 +439,9 @@ spv_result_t spvBinaryToText(uint32_t* code,
|
||||
spv_text *pText, spv_diagnostic *pDiagnostic) {
|
||||
spv_binary_t binary = {code, wordCount};
|
||||
|
||||
spv_position_t position = {};
|
||||
spvCheck(!binary.code || !binary.wordCount,
|
||||
DIAGNOSTIC << "Binary stream is empty.";
|
||||
return SPV_ERROR_INVALID_BINARY);
|
||||
spvCheck(!opcodeTable || !operandTable || !extInstTable,
|
||||
return SPV_ERROR_INVALID_TABLE);
|
||||
@ -450,7 +452,6 @@ spv_result_t spvBinaryToText(uint32_t* code,
|
||||
spvCheck(!pDiagnostic, return SPV_ERROR_INVALID_DIAGNOSTIC);
|
||||
|
||||
spv_endianness_t endian;
|
||||
spv_position_t position = {};
|
||||
spvCheck(spvBinaryEndianness(&binary, &endian),
|
||||
DIAGNOSTIC << "Invalid SPIR-V magic number '" << std::hex
|
||||
<< binary.code[0] << "'.";
|
||||
|
@ -437,6 +437,8 @@ spv_result_t spvTextEncodeOperand(
|
||||
DIAGNOSTIC << "Invalid literal '" << textValue << "'.";
|
||||
return SPV_ERROR_INVALID_TEXT);
|
||||
switch (literal.type) {
|
||||
// We do not have to print diagnostics here because spvBinaryEncode*
|
||||
// prints diagnostic messages on failure.
|
||||
case SPV_LITERAL_TYPE_INT_32:
|
||||
spvCheck(spvBinaryEncodeU32(BitwiseCast<uint32_t>(literal.value.i32),
|
||||
pInst, position, pDiagnostic),
|
||||
@ -535,7 +537,7 @@ spv_result_t spvTextEncodeOpcode(
|
||||
spv_position_t nextPosition = {};
|
||||
spv_result_t error =
|
||||
spvTextWordGet(text, position, opcodeName, &nextPosition);
|
||||
spvCheck(error, return error);
|
||||
spvCheck(error, DIAGNOSTIC << "Internal Error"; return error);
|
||||
|
||||
// NOTE: Handle insertion of an immediate integer into the binary stream
|
||||
bool immediate = false;
|
||||
@ -584,7 +586,7 @@ spv_result_t spvTextEncodeOpcode(
|
||||
DIAGNOSTIC << "Expected opcode, found end of stream.";
|
||||
return SPV_ERROR_INVALID_TEXT);
|
||||
error = spvTextWordGet(text, position, opcodeName, &nextPosition);
|
||||
spvCheck(error, return error);
|
||||
spvCheck(error, DIAGNOSTIC << "Internal Error"; return error);
|
||||
spvCheck(!spvStartsWithOp(text, position),
|
||||
DIAGNOSTIC << "Invalid Opcode prefix '" << opcodeName << "'.";
|
||||
return SPV_ERROR_INVALID_TEXT);
|
||||
@ -656,7 +658,7 @@ spv_result_t spvTextEncodeOpcode(
|
||||
|
||||
std::string operandValue;
|
||||
error = spvTextWordGet(text, position, operandValue, &nextPosition);
|
||||
spvCheck(error, return error);
|
||||
spvCheck(error, DIAGNOSTIC << "Internal Error"; return error);
|
||||
|
||||
error = spvTextEncodeOperand(
|
||||
type, operandValue.c_str(),
|
||||
|
Loading…
Reference in New Issue
Block a user