Check for valid SPIR-V <id>s by comparing against 0

This change consistently uses if(id != 0) { ... } syntax for choosing
code paths where the SPIR-V <id> is valid. This allows the value()
method to assert that we don't inadvertently use an <id> for an operand
which does not exist. This makes for an elegant syntax when parsing
SPIR-V instructions into structures which store <id>s for operands which
are optional, such as common in image instructions, while catching
mistakes centrally.

Bug: b/205642050
Change-Id: I3e1f1340a56bd3c848fdf3724088660046bf29ed
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/39268
Reviewed-by: Alexis Hétu <sugoi@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Pipeline/SpirvShader.cpp b/src/Pipeline/SpirvShader.cpp
index c56fd38..6239a20 100644
--- a/src/Pipeline/SpirvShader.cpp
+++ b/src/Pipeline/SpirvShader.cpp
@@ -207,7 +207,7 @@
 
 		case spv::OpLabel:
 			{
-				ASSERT(currentBlock.value() == 0);
+				ASSERT(currentBlock == 0);
 				currentBlock = Block::ID(insn.word(1));
 				blockStart = insn;
 			}
@@ -224,8 +224,8 @@
 		case spv::OpKill:
 		case spv::OpUnreachable:
 			{
-				ASSERT(currentBlock.value() != 0);
-				ASSERT(currentFunction.value() != 0);
+				ASSERT(currentBlock != 0);
+				ASSERT(currentFunction != 0);
 
 				auto blockEnd = insn;
 				blockEnd++;