Replace asserts with returns

* Changes to satisfy fuzzer
This commit is contained in:
Alan Baker 2018-08-08 13:01:57 -04:00
parent ca7278cff7
commit 983f8f02de

View File

@ -23,10 +23,12 @@ namespace spvtools {
void EmitNumericLiteral(std::ostream* out, const spv_parsed_instruction_t& inst, void EmitNumericLiteral(std::ostream* out, const spv_parsed_instruction_t& inst,
const spv_parsed_operand_t& operand) { const spv_parsed_operand_t& operand) {
assert(operand.type == SPV_OPERAND_TYPE_LITERAL_INTEGER || if (operand.type != SPV_OPERAND_TYPE_LITERAL_INTEGER &&
operand.type == SPV_OPERAND_TYPE_TYPED_LITERAL_NUMBER); operand.type != SPV_OPERAND_TYPE_TYPED_LITERAL_NUMBER)
assert(1 <= operand.num_words); return;
assert(operand.num_words <= 2); if (operand.num_words < 1) return;
// TODO(dneto): Support more than 64-bits at a time.
if (operand.num_words > 2) return;
const uint32_t word = inst.words[operand.offset]; const uint32_t word = inst.words[operand.offset];
if (operand.num_words == 1) { if (operand.num_words == 1) {
@ -47,7 +49,7 @@ void EmitNumericLiteral(std::ostream* out, const spv_parsed_instruction_t& inst,
} }
break; break;
default: default:
assert(false && "Unreachable"); break;
} }
} else if (operand.num_words == 2) { } else if (operand.num_words == 2) {
// Multi-word numbers are presented with lower order words first. // Multi-word numbers are presented with lower order words first.
@ -65,11 +67,8 @@ void EmitNumericLiteral(std::ostream* out, const spv_parsed_instruction_t& inst,
*out << spvtools::utils::FloatProxy<double>(bits); *out << spvtools::utils::FloatProxy<double>(bits);
break; break;
default: default:
assert(false && "Unreachable"); break;
} }
} else {
// TODO(dneto): Support more than 64-bits at a time.
assert(false && "Unhandled");
} }
} }
} // namespace spvtools } // namespace spvtools