diff options
Diffstat (limited to 'source/text.cpp')
-rw-r--r-- | source/text.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/source/text.cpp b/source/text.cpp index 415c059d..90f69c52 100644 --- a/source/text.cpp +++ b/source/text.cpp @@ -403,9 +403,10 @@ spv_result_t spvTextEncodeOperand(const spvtools::AssemblyGrammar& grammar, case SPV_OPERAND_TYPE_DEBUG_INFO_FLAGS: case SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_INFO_FLAGS: { uint32_t value; - if (grammar.parseMaskOperand(type, textValue, &value)) { - return context->diagnostic() << "Invalid " << spvOperandTypeStr(type) - << " operand '" << textValue << "'."; + if (auto error = grammar.parseMaskOperand(type, textValue, &value)) { + return context->diagnostic(error) + << "Invalid " << spvOperandTypeStr(type) << " operand '" + << textValue << "'."; } if (auto error = context->binaryEncodeU32(value, pInst)) return error; // Prepare to parse the operands for this logical operand. @@ -622,7 +623,8 @@ spv_result_t spvTextEncodeOpcode(const spvtools::AssemblyGrammar& grammar, break; } else { return context->diagnostic() - << "Expected operand, found end of stream."; + << "Expected operand for " << opcodeName + << " instruction, but found the end of the stream."; } } assert(error == SPV_SUCCESS && "Somebody added another way to fail"); @@ -632,7 +634,8 @@ spv_result_t spvTextEncodeOpcode(const spvtools::AssemblyGrammar& grammar, break; } else { return context->diagnostic() - << "Expected operand, found next instruction instead."; + << "Expected operand for " << opcodeName + << " instruction, but found the next instruction instead."; } } @@ -666,7 +669,7 @@ spv_result_t spvTextEncodeOpcode(const spvtools::AssemblyGrammar& grammar, if (pInst->words.size() > SPV_LIMIT_INSTRUCTION_WORD_COUNT_MAX) { return context->diagnostic() - << "Instruction too long: " << pInst->words.size() + << opcodeName << " Instruction too long: " << pInst->words.size() << " words, but the limit is " << SPV_LIMIT_INSTRUCTION_WORD_COUNT_MAX; } @@ -769,8 +772,8 @@ spv_result_t spvTextToBinaryInternal(const spvtools::AssemblyGrammar& grammar, instructions.push_back({}); spv_instruction_t& inst = instructions.back(); - if (spvTextEncodeOpcode(grammar, &context, &inst)) { - return SPV_ERROR_INVALID_TEXT; + if (auto error = spvTextEncodeOpcode(grammar, &context, &inst)) { + return error; } if (context.advance()) break; |