From b7afe4e7ae4985e9438f8def337514e25c61e7ff Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Tue, 31 Jul 2018 14:53:10 -0400 Subject: Switch validate to use explicit diag() method. (#1750) This CL changes validate.cpp to use diag providing an explicit instruction. This changes the result of the function end checks to not output a disassembly anymore as printing the last line of the module didn't seem to make sense. --- source/val/validate.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'source/val') diff --git a/source/val/validate.cpp b/source/val/validate.cpp index 9a16ba27..7971a9a3 100644 --- a/source/val/validate.cpp +++ b/source/val/validate.cpp @@ -250,11 +250,11 @@ spv_result_t ValidateBinaryUsingContextAndValidationState( return error; if (!vstate->has_memory_model_specified()) - return vstate->diag(SPV_ERROR_INVALID_LAYOUT) + return vstate->diag(SPV_ERROR_INVALID_LAYOUT, nullptr) << "Missing required OpMemoryModel instruction."; if (vstate->in_function_body()) - return vstate->diag(SPV_ERROR_INVALID_LAYOUT) + return vstate->diag(SPV_ERROR_INVALID_LAYOUT, nullptr) << "Missing OpFunctionEnd at end of module."; // TODO(umar): Add validation checks which require the parsing of the entire @@ -268,7 +268,7 @@ spv_result_t ValidateBinaryUsingContextAndValidationState( bind(&ValidationState_t::getIdName, std::ref(*vstate), _1)); auto id_str = ss.str(); - return vstate->diag(SPV_ERROR_INVALID_ID) + return vstate->diag(SPV_ERROR_INVALID_ID, nullptr) << "The following forward referenced IDs have not been defined:\n" << id_str.substr(0, id_str.size() - 1); } @@ -295,13 +295,14 @@ spv_result_t ValidateBinaryUsingContextAndValidationState( // OpFunctionCall instruction. if (vstate->entry_points().empty() && !vstate->HasCapability(SpvCapabilityLinkage)) { - return vstate->diag(SPV_ERROR_INVALID_BINARY) + return vstate->diag(SPV_ERROR_INVALID_BINARY, nullptr) << "No OpEntryPoint instruction was found. This is only allowed if " "the Linkage capability is being used."; } for (const auto& entry_point : vstate->entry_points()) { if (vstate->IsFunctionCallTarget(entry_point)) { - return vstate->diag(SPV_ERROR_INVALID_BINARY) + return vstate->diag(SPV_ERROR_INVALID_BINARY, + vstate->FindDef(entry_point)) << "A function (" << entry_point << ") may not be targeted by both an OpEntryPoint instruction and " "an OpFunctionCall instruction."; -- cgit v1.2.3