summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordan sinclair <dj2@everburning.com>2018-08-01 09:52:16 -0400
committerGitHub <noreply@github.com>2018-08-01 09:52:16 -0400
commit2c5f1b01d8d9f97719b226c3212a1f7706b301df (patch)
treea23f4dca1c182793f4cc37a5d1bf4782056241f3
parent3619de9ad526b2511c657ae7241ac5c3af3dee46 (diff)
Update diag() calls in validate_cfg. (#1760)
This CL updates the diag() calls in validate_cfg to provide the associated instruction. This fixes a couple places where we output the last line of the file instead of the instruction as the disassembly.
-rw-r--r--source/val/validate_cfg.cpp6
-rw-r--r--test/val/val_cfg_test.cpp4
2 files changed, 5 insertions, 5 deletions
diff --git a/source/val/validate_cfg.cpp b/source/val/validate_cfg.cpp
index 97dbcc0f..9ed45046 100644
--- a/source/val/validate_cfg.cpp
+++ b/source/val/validate_cfg.cpp
@@ -193,7 +193,7 @@ spv_result_t FindCaseFallThrough(
continue;
}
- return _.diag(SPV_ERROR_INVALID_CFG)
+ return _.diag(SPV_ERROR_INVALID_CFG, target_block->label())
<< "Case construct that targets "
<< _.getIdName(target_block->id())
<< " has invalid branch to block " << _.getIdName(block->id())
@@ -244,7 +244,7 @@ spv_result_t StructuredSwitchChecks(const ValidationState_t& _,
// OpSwitch must dominate all its case constructs.
if (header->reachable() && target_block->reachable() &&
!header->dominates(*target_block)) {
- return _.diag(SPV_ERROR_INVALID_CFG)
+ return _.diag(SPV_ERROR_INVALID_CFG, header->label())
<< "Selection header " << _.getIdName(header->id())
<< " does not dominate its case construct " << _.getIdName(target);
}
@@ -330,7 +330,7 @@ spv_result_t StructuredControlFlowChecks(
uint32_t header_block;
tie(back_edge_block, header_block) = back_edge;
if (!function->IsBlockType(header_block, kBlockTypeLoop)) {
- return _.diag(SPV_ERROR_INVALID_CFG)
+ return _.diag(SPV_ERROR_INVALID_CFG, _.FindDef(back_edge_block))
<< "Back-edges (" << _.getIdName(back_edge_block) << " -> "
<< _.getIdName(header_block)
<< ") can only be formed between a block and a loop header.";
diff --git a/test/val/val_cfg_test.cpp b/test/val/val_cfg_test.cpp
index e291d939..625a7bc9 100644
--- a/test/val/val_cfg_test.cpp
+++ b/test/val/val_cfg_test.cpp
@@ -963,7 +963,7 @@ TEST_P(ValidateCFG, BranchingToNonLoopHeaderBlockBad) {
getDiagnosticString(),
MatchesRegex("Back-edges \\(.\\[f\\] -> .\\[split\\]\\) can only "
"be formed between a block and a loop header.\n"
- " OpFunctionEnd\n"));
+ " %f = OpLabel\n"));
} else {
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
}
@@ -993,7 +993,7 @@ TEST_P(ValidateCFG, BranchingToSameNonLoopHeaderBlockBad) {
MatchesRegex(
"Back-edges \\(.\\[split\\] -> .\\[split\\]\\) can only be "
"formed between a block and a loop header.\n"
- " OpFunctionEnd\n"));
+ " %split = OpLabel\n"));
} else {
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
}