From 828226230486fa92f9ba0a0509754926b047a48b Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Mon, 23 Nov 2020 22:32:55 +0000 Subject: [PATCH] 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 Reviewed-by: David Neto --- src/writer/spirv/builder.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/writer/spirv/builder.h b/src/writer/spirv/builder.h index 7be24c6446..7e6acbbacc 100644 --- a/src/writer/spirv/builder.h +++ b/src/writer/spirv/builder.h @@ -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); }