mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-10-18 11:10:05 +00:00
Validate Ids before DataRules. (#1622)
Validate Ids before DataRules. The DataRule validators call FindDefs with the assumption that they definitions being looked at can be found. This may not be true if we have not validated identifiers first. This CL flips the IdPass and DataRulesPass to fix this issue.
This commit is contained in:
parent
ea7239fa73
commit
d3ed998222
@ -174,8 +174,10 @@ spv_result_t ProcessInstruction(void* user_data,
|
||||
|
||||
DebugInstructionPass(_, inst);
|
||||
if (auto error = CapabilityPass(_, inst)) return error;
|
||||
if (auto error = DataRulesPass(_, inst)) return error;
|
||||
// The IdPass check registers instructions and, therefore, must be called
|
||||
// before any instruction lookups are performed.
|
||||
if (auto error = IdPass(_, inst)) return error;
|
||||
if (auto error = DataRulesPass(_, inst)) return error;
|
||||
if (auto error = ModuleLayoutPass(_, inst)) return error;
|
||||
if (auto error = CfgPass(_, inst)) return error;
|
||||
if (auto error = InstructionPass(_, inst)) return error;
|
||||
|
@ -343,6 +343,16 @@ TEST_F(ValidateData, matrix_data_type_float) {
|
||||
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
|
||||
}
|
||||
|
||||
TEST_F(ValidateData, ids_should_be_validated_before_data) {
|
||||
string str = header + R"(
|
||||
%f32 = OpTypeFloat 32
|
||||
%mat33 = OpTypeMatrix %vec3 3
|
||||
)";
|
||||
CompileSuccessfully(str.c_str());
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("ID 3 has not been defined"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateData, matrix_bad_column_type) {
|
||||
string str = header + R"(
|
||||
%f32 = OpTypeFloat 32
|
||||
|
Loading…
Reference in New Issue
Block a user