Add TINT_UNREACHABLE() and TINT_ICE() helper macros

Appends an error message with the tint compiler source location to the
provided diagnositic list, and then calls the global error handler if
one is set.
Tests and the sample app now register an error handler to print the
diagnostic list to stderr and abort when NDEBUG is not defined.

All uses of assert(false) have been fixed up to use these macros.

Change-Id: I2f63e51ed86ac23883301d280070bd1a357c6cb2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41620
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
diff --git a/src/ast/module.cc b/src/ast/module.cc
index a5c19c9..996ecc9 100644
--- a/src/ast/module.cc
+++ b/src/ast/module.cc
@@ -18,6 +18,7 @@
 #include <string>
 #include <utility>
 
+#include "src/debug.h"
 #include "src/program_builder.h"
 #include "src/type/alias_type.h"
 #include "src/type/struct_type.h"
@@ -43,7 +44,8 @@
     } else if (auto* var = decl->As<Variable>()) {
       global_variables_.push_back(var);
     } else {
-      assert(false /* unreachable */);
+      diag::List diagnostics;
+      TINT_ICE(diagnostics, "Unknown global declaration type");
     }
   }
 }
@@ -106,7 +108,7 @@
     } else if (auto* var = decl->As<Variable>()) {
       AddGlobalVariable(ctx->Clone(var));
     } else {
-      assert(false /* unreachable */);
+      TINT_ICE(ctx->dst->Diagnostics(), "Unknown global declaration type");
     }
   }
 }