Program: Track what transforms have been applied

Allows transforms to assert their dependencies have been run before they
are.

Also allows the backends to validate that their sanitizers have been run
before they're used.

Change-Id: I1e97afe06f9e7371283bade54bbb2e2c41f87a00
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55442
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/transform/external_texture_transform.cc b/src/transform/external_texture_transform.cc
index 4d48ff7..1ede9b8 100644
--- a/src/transform/external_texture_transform.cc
+++ b/src/transform/external_texture_transform.cc
@@ -18,15 +18,17 @@
 #include "src/sem/call.h"
 #include "src/sem/variable.h"
 
+TINT_INSTANTIATE_TYPEINFO(tint::transform::ExternalTextureTransform);
+
 namespace tint {
 namespace transform {
 
 ExternalTextureTransform::ExternalTextureTransform() = default;
 ExternalTextureTransform::~ExternalTextureTransform() = default;
 
-Output ExternalTextureTransform::Run(const Program* in, const DataMap&) {
-  ProgramBuilder out;
-  CloneContext ctx(&out, in);
+void ExternalTextureTransform::Run(CloneContext& ctx,
+                                   const DataMap&,
+                                   DataMap&) {
   auto& sem = ctx.src->Sem();
 
   // Within this transform, usages of texture_external are replaced with a
@@ -105,7 +107,7 @@
   // Scan the AST nodes for external texture declarations.
   for (auto* node : ctx.src->ASTNodes().Objects()) {
     if (auto* var = node->As<ast::Variable>()) {
-      if (Is<ast::ExternalTexture>(var->type())) {
+      if (::tint::Is<ast::ExternalTexture>(var->type())) {
         // Replace a single-plane external texture with a 2D, f32 sampled
         // texture.
         auto* newType = ctx.dst->ty.sampled_texture(ast::TextureDimension::k2d,
@@ -125,7 +127,6 @@
   }
 
   ctx.Clone();
-  return Output{Program(std::move(out))};
 }
 
 }  // namespace transform