writer/spriv: Add an assert that functions_ is not empty

... before attempting to push instructions to `functions_.back()`

If this fires, we're in an invalid state anyway. At least make the explosion less head scratching.

Change-Id: I7b4a002043de4b55a12d9aba80a0393c630140c2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33664
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
Ben Clayton 2020-11-23 22:32:55 +00:00 committed by Commit Bot service account
parent 1ed92b2a9d
commit 8282262304
1 changed files with 2 additions and 0 deletions

View File

@ -175,11 +175,13 @@ class Builder {
/// @param op the operation
/// @param operands the operands
void push_function_inst(spv::Op op, const OperandList& operands) {
assert(!functions_.empty());
functions_.back().push_inst(op, operands);
}
/// Pushes a variable to the current function
/// @param operands the variable operands
void push_function_var(const OperandList& operands) {
assert(!functions_.empty());
functions_.back().push_var(operands);
}