mirror of
https://gitee.com/openharmony/third_party_spirv-tools
synced 2024-11-27 09:32:08 +00:00
Fixup line number for OpVectorShuffle ID error.
This CL updates the code to pull a valid instruction for the line number when outputting a component error in OpVectorShuffle. The error line isn't the best at this point as it points at the component, but it's better then a -1 (turning to max<size_t>) that was being output. The error messages has been updated to better reflect what the error is attempting to say. Issue 1719.
This commit is contained in:
parent
208921efe8
commit
8c7dab5caa
@ -1781,9 +1781,9 @@ bool idUsage::isValid<SpvOpVectorShuffle>(const spv_instruction_t* inst,
|
||||
for (size_t i = firstLiteralIndex; i < inst->words.size(); ++i) {
|
||||
auto literal = inst->words[i];
|
||||
if (literal != 0xFFFFFFFF && literal >= N) {
|
||||
DIAG(module_.FindDef(inst->words[0]))
|
||||
<< "Component literal value " << literal << " is greater than "
|
||||
<< N - 1 << ".";
|
||||
DIAG(module_.FindDef(inst->words[2]))
|
||||
<< "Component index " << literal << " is out of range for a result "
|
||||
<< "vector of size " << N << ".";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -3848,8 +3848,10 @@ TEST_F(ValidateIdWithMessage, OpVectorShuffleLiterals) {
|
||||
OpFunctionEnd)";
|
||||
CompileSuccessfully(spirv.c_str());
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("Component literal value 5 is greater than 4."));
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr(
|
||||
"Component index 5 is out of range for a result vector of size 5."));
|
||||
}
|
||||
|
||||
// TODO: OpCompositeConstruct
|
||||
@ -4706,6 +4708,32 @@ OpFunctionEnd
|
||||
EXPECT_EQ(SPV_SUCCESS, ValidateAndRetrieveValidationState());
|
||||
}
|
||||
|
||||
TEST_F(ValidateIdWithMessage, CorrectErrorForShuffle) {
|
||||
string spirv = kGLSL450MemoryModel + R"(
|
||||
%uint = OpTypeInt 32 0
|
||||
%float = OpTypeFloat 32
|
||||
%v4float = OpTypeVector %float 4
|
||||
%v2float = OpTypeVector %float 2
|
||||
%void = OpTypeVoid
|
||||
%548 = OpTypeFunction %void
|
||||
%CS = OpFunction %void None %548
|
||||
%550 = OpLabel
|
||||
%6275 = OpUndef %v2float
|
||||
%6280 = OpUndef %v2float
|
||||
%6282 = OpVectorShuffle %v4float %6275 %6280 0 1 4 5
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
CompileSuccessfully(spirv.c_str());
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr(
|
||||
"Component index 4 is out of range for a result vector of size 4."));
|
||||
EXPECT_EQ(23, getErrorPosition().index);
|
||||
}
|
||||
|
||||
// TODO: OpLifetimeStart
|
||||
// TODO: OpLifetimeStop
|
||||
// TODO: OpAtomicInit
|
||||
|
Loading…
Reference in New Issue
Block a user