Remove deprecated APIs

Remove the Parser classes from the wgsl and spirv namespaces.
These have been replaced with a Parse() method.

Remove the TypeDeterminer::Run() method, this was not called by tint and
the TypeDeterminer is now non-public API.

Change-Id: I5ddb82768da04398ab3958d1647be44f9fe30c21
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41840
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
diff --git a/fuzzers/tint_common_fuzzer.cc b/fuzzers/tint_common_fuzzer.cc
index 93b84fa..cbabde2 100644
--- a/fuzzers/tint_common_fuzzer.cc
+++ b/fuzzers/tint_common_fuzzer.cc
@@ -35,7 +35,8 @@
 CommonFuzzer::~CommonFuzzer() = default;
 
 int CommonFuzzer::Run(const uint8_t* data, size_t size) {
-  std::unique_ptr<reader::Reader> parser;
+  Program program;
+
 #if TINT_BUILD_WGSL_READER
   std::unique_ptr<Source::File> file;
 #endif  // TINT_BUILD_WGSL_READER
@@ -47,7 +48,7 @@
       std::string str(reinterpret_cast<const char*>(data), size);
 
       file = std::make_unique<Source::File>("test.wgsl", str);
-      parser = std::make_unique<reader::wgsl::Parser>(file.get());
+      program = reader::wgsl::Parse(file.get());
     }
 #endif  // TINT_BUILD_WGSL_READER
     break;
@@ -59,7 +60,7 @@
       std::vector<uint32_t> input(u32Data, u32Data + sizeInU32);
 
       if (input.size() != 0) {
-        parser = std::make_unique<reader::spirv::Parser>(input);
+        program = reader::spirv::Parse(input);
       }
     }
 #endif  // TINT_BUILD_WGSL_READER
@@ -68,19 +69,10 @@
       break;
   }
 
-  if (!parser) {
-    return 0;
-  }
-
-  if (!parser->Parse()) {
-    return 0;
-  }
-
   if (output_ == OutputFormat::kNone) {
     return 0;
   }
 
-  auto program = parser->program();
   if (!program.IsValid()) {
     return 0;
   }
diff --git a/src/ast/module_clone_test.cc b/src/ast/module_clone_test.cc
index 8afbf57..7ed6be0 100644
--- a/src/ast/module_clone_test.cc
+++ b/src/ast/module_clone_test.cc
@@ -120,9 +120,7 @@
 )");
 
   // Parse the wgsl, create the src program
-  reader::wgsl::Parser parser(&file);
-  ASSERT_TRUE(parser.Parse()) << parser.error();
-  auto src = parser.program();
+  auto src = reader::wgsl::Parse(&file);
 
   ASSERT_TRUE(src.IsValid()) << diag::Formatter().format(src.Diagnostics());
 
diff --git a/src/reader/spirv/parser.cc b/src/reader/spirv/parser.cc
index 75b6475..d85402e 100644
--- a/src/reader/spirv/parser.cc
+++ b/src/reader/spirv/parser.cc
@@ -22,27 +22,6 @@
 namespace reader {
 namespace spirv {
 
-Parser::Parser(const std::vector<uint32_t>& spv_binary)
-    : Reader(), impl_(std::make_unique<ParserImpl>(spv_binary)) {}
-
-Parser::~Parser() = default;
-
-bool Parser::Parse() {
-  const auto result = impl_->Parse();
-  auto err_msg = impl_->error();
-  if (!err_msg.empty()) {
-    // TODO(bclayton): Migrate spirv::ParserImpl to using diagnostics.
-    diag::List diagnostics;
-    diagnostics.add_error(err_msg);
-    set_diagnostics(std::move(diagnostics));
-  }
-  return result;
-}
-
-Program Parser::program() {
-  return impl_->program();
-}
-
 Program Parse(const std::vector<uint32_t>& input) {
   ParserImpl parser(input);
   bool parsed = parser.Parse();
diff --git a/src/reader/spirv/parser.h b/src/reader/spirv/parser.h
index cf9e53a..d22ad30 100644
--- a/src/reader/spirv/parser.h
+++ b/src/reader/spirv/parser.h
@@ -15,40 +15,14 @@
 #ifndef SRC_READER_SPIRV_PARSER_H_
 #define SRC_READER_SPIRV_PARSER_H_
 
-#include <cstdint>
-#include <memory>
 #include <vector>
 
-#include "src/reader/reader.h"
+#include "src/program.h"
 
 namespace tint {
 namespace reader {
 namespace spirv {
 
-class ParserImpl;
-
-/// Parser for SPIR-V source data
-/// [DEPRECATED] - Use Parse()
-class Parser : public Reader {
- public:
-  /// Creates a new parser
-  /// @param input the input data to parse
-  explicit Parser(const std::vector<uint32_t>& input);
-  /// Destructor
-  ~Parser() override;
-
-  /// Run the parser
-  /// @returns true if the parse was successful, false otherwise.
-  bool Parse() override;
-
-  /// @returns the program. The program builder in the parser will be reset
-  /// after this.
-  Program program() override;
-
- private:
-  std::unique_ptr<ParserImpl> impl_;
-};
-
 /// Parses the SPIR-V source data, returning the parsed program.
 /// If the source data fails to parse then the returned
 /// `program.Diagnostics.contains_errors()` will be true, and the
diff --git a/src/reader/spirv/parser_test.cc b/src/reader/spirv/parser_test.cc
index 8c4d7c1..3da0fbc 100644
--- a/src/reader/spirv/parser_test.cc
+++ b/src/reader/spirv/parser_test.cc
@@ -26,13 +26,6 @@
 
 using ParserTest = testing::Test;
 
-TEST_F(ParserTest, Uint32VecEmptyOld) {
-  std::vector<uint32_t> data;
-  Parser p(data);
-  EXPECT_FALSE(p.Parse());
-  // TODO(dneto): What message?
-}
-
 TEST_F(ParserTest, DataEmpty) {
   std::vector<uint32_t> data;
   auto program = Parse(data);
diff --git a/src/reader/wgsl/parser.cc b/src/reader/wgsl/parser.cc
index 4296e4d..04728ed 100644
--- a/src/reader/wgsl/parser.cc
+++ b/src/reader/wgsl/parser.cc
@@ -22,23 +22,6 @@
 namespace reader {
 namespace wgsl {
 
-Parser::Parser(Source::File const* file)
-    : Reader(), impl_(std::make_unique<ParserImpl>(file)) {}
-
-Parser::~Parser() = default;
-
-bool Parser::Parse() {
-  bool ret = impl_->Parse();
-
-  set_diagnostics(std::move(impl_->diagnostics()));
-
-  return ret;
-}
-
-Program Parser::program() {
-  return impl_->program();
-}
-
 Program Parse(Source::File const* file) {
   ParserImpl parser(file);
   parser.Parse();
diff --git a/src/reader/wgsl/parser.h b/src/reader/wgsl/parser.h
index 1960396..4d83dcb 100644
--- a/src/reader/wgsl/parser.h
+++ b/src/reader/wgsl/parser.h
@@ -15,39 +15,13 @@
 #ifndef SRC_READER_WGSL_PARSER_H_
 #define SRC_READER_WGSL_PARSER_H_
 
-#include <memory>
-#include <string>
-
-#include "src/reader/reader.h"
+#include "src/program.h"
 #include "src/source.h"
 
 namespace tint {
 namespace reader {
 namespace wgsl {
 
-class ParserImpl;
-
-/// Parser for WGSL source data
-/// [DEPRECATED] - Use Parse()
-class Parser : public Reader {
- public:
-  /// Creates a new parser from the given file.
-  /// @param file the input source file to parse
-  explicit Parser(Source::File const* file);
-  ~Parser() override;
-
-  /// Run the parser
-  /// @returns true if the parse was successful, false otherwise.
-  bool Parse() override;
-
-  /// @returns the program. The program builder in the parser will be reset
-  /// after this.
-  Program program() override;
-
- private:
-  std::unique_ptr<ParserImpl> impl_;
-};
-
 /// Parses the WGSL source, returning the parsed program.
 /// If the source fails to parse then the returned
 /// `program.Diagnostics.contains_errors()` will be true, and the
diff --git a/src/reader/wgsl/parser_test.cc b/src/reader/wgsl/parser_test.cc
index 030652e..d75a742 100644
--- a/src/reader/wgsl/parser_test.cc
+++ b/src/reader/wgsl/parser_test.cc
@@ -25,41 +25,6 @@
 
 using ParserTest = testing::Test;
 
-TEST_F(ParserTest, EmptyOld) {
-  Source::File file("test.wgsl", "");
-  Parser p(&file);
-  ASSERT_TRUE(p.Parse()) << p.error();
-}
-
-TEST_F(ParserTest, ParsesOld) {
-  Source::File file("test.wgsl", R"(
-[[location(0)]] var<out> gl_FragColor : vec4<f32>;
-
-[[stage(vertex)]]
-fn main() -> void {
-  gl_FragColor = vec4<f32>(.4, .2, .3, 1);
-}
-)");
-  Parser p(&file);
-  ASSERT_TRUE(p.Parse()) << p.error();
-
-  auto program = p.program();
-  ASSERT_EQ(1u, program.AST().Functions().size());
-  ASSERT_EQ(1u, program.AST().GlobalVariables().size());
-}
-
-TEST_F(ParserTest, HandlesErrorOld) {
-  Source::File file("test.wgsl", R"(
-fn main() ->  {  // missing return type
-  return;
-})");
-  Parser p(&file);
-
-  ASSERT_FALSE(p.Parse());
-  ASSERT_TRUE(p.has_error());
-  EXPECT_EQ(p.error(), "2:15: unable to determine function return type");
-}
-
 TEST_F(ParserTest, Empty) {
   Source::File file("test.wgsl", "");
   auto program = Parse(&file);
@@ -76,7 +41,6 @@
   gl_FragColor = vec4<f32>(.4, .2, .3, 1);
 }
 )");
-  Parser p(&file);
   auto program = Parse(&file);
   auto errs = diag::Formatter().format(program.Diagnostics());
   ASSERT_TRUE(program.IsValid()) << errs;
diff --git a/src/transform/test_helper.h b/src/transform/test_helper.h
index 78c84ac..f52c5e7 100644
--- a/src/transform/test_helper.h
+++ b/src/transform/test_helper.h
@@ -42,16 +42,12 @@
   std::string Transform(
       std::string in,
       std::vector<std::unique_ptr<transform::Transform>> transforms) {
-    Source::File file("test", in);
-    reader::wgsl::Parser parser(&file);
-    if (!parser.Parse()) {
-      return "WGSL reader failed:\n" + parser.error();
-    }
-
     diag::Formatter::Style style;
     style.print_newline_at_end = false;
 
-    auto program = parser.program();
+    Source::File file("test", in);
+    auto program = reader::wgsl::Parse(&file);
+
     if (!program.IsValid()) {
       return diag::Formatter(style).format(program.Diagnostics());
     }
diff --git a/src/type_determiner.cc b/src/type_determiner.cc
index fc49224..5bce843 100644
--- a/src/type_determiner.cc
+++ b/src/type_determiner.cc
@@ -95,18 +95,6 @@
 
 TypeDeterminer::~TypeDeterminer() = default;
 
-diag::List TypeDeterminer::Run(Program* program) {
-  ProgramBuilder builder = program->CloneAsBuilder();
-  TypeDeterminer td(&builder);
-  if (!td.Determine()) {
-    diag::List diagnostics;
-    diagnostics.add_error(td.error());
-    return diagnostics;
-  }
-  *program = Program(std::move(builder));
-  return {};
-}
-
 void TypeDeterminer::set_referenced_from_function_if_needed(VariableInfo* var,
                                                             bool local) {
   if (current_function_ == nullptr) {
diff --git a/src/type_determiner.h b/src/type_determiner.h
index 0a4fb3e..8f0802a 100644
--- a/src/type_determiner.h
+++ b/src/type_determiner.h
@@ -59,14 +59,6 @@
   /// Destructor
   ~TypeDeterminer();
 
-  /// Run the type determiner on `program`, replacing the Program with a new
-  /// program containing type information.
-  /// [TEMPORARY] - Exists for making incremental changes.
-  /// @param program a pointer to the program variable that will be read from
-  /// and assigned to.
-  /// @returns a list of diagnostic messages
-  static diag::List Run(Program* program);
-
   /// @returns error messages from the type determiner
   std::string error() const { return diagnostics_.str(); }