Remove tint::Namer
Replaced with tint::transform::Rename and was never used.
Bug: tint:273
Change-Id: Icf0b19b389377f3c9a6efcf3ca232ba294775f9b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/43981
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index bda10ba..6a96d84 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -371,8 +371,6 @@
"src/inspector/scalar.h",
"src/intrinsic_table.cc",
"src/intrinsic_table.h",
- "src/namer.cc",
- "src/namer.h",
"src/program.cc",
"src/program.h",
"src/program_builder.cc",
@@ -844,7 +842,6 @@
"src/diagnostic/printer_test.cc",
"src/inspector/inspector_test.cc",
"src/intrinsic_table_test.cc",
- "src/namer_test.cc",
"src/program_builder_test.cc",
"src/program_test.cc",
"src/scope_stack_test.cc",
diff --git a/include/tint/tint.h b/include/tint/tint.h
index 54656c8..551c204 100644
--- a/include/tint/tint.h
+++ b/include/tint/tint.h
@@ -22,7 +22,6 @@
#include "src/demangler.h"
#include "src/diagnostic/printer.h"
#include "src/inspector/inspector.h"
-#include "src/namer.h"
#include "src/reader/reader.h"
#include "src/transform/bound_array_accessors.h"
#include "src/transform/emit_vertex_point_size.h"
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3453117..93ebd19 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -185,8 +185,6 @@
inspector/inspector.h
inspector/scalar.cc
inspector/scalar.h
- namer.cc
- namer.h
program_builder.cc
program_builder.h
program.cc
@@ -473,7 +471,6 @@
diagnostic/printer_test.cc
inspector/inspector_test.cc
intrinsic_table_test.cc
- namer_test.cc
program_test.cc
scope_stack_test.cc
symbol_table_test.cc
diff --git a/src/namer.cc b/src/namer.cc
deleted file mode 100644
index b9009d1..0000000
--- a/src/namer.cc
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2020 The Tint Authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "src/namer.h"
-
-#include <algorithm>
-#include <iomanip>
-#include <sstream>
-
-#include "src/symbol.h"
-
-namespace tint {
-
-Namer::Namer(SymbolTable* symbols) : symbols_(symbols) {}
-
-Namer::~Namer() = default;
-
-bool Namer::IsUsed(const std::string& name) {
- auto it = used_.find(name);
- return it != used_.end();
-}
-
-std::string Namer::GenerateName(const std::string& prefix) {
- std::string name = prefix;
- uint32_t i = 0;
- while (IsUsed(name)) {
- name = prefix + "_" + std::to_string(i);
- ++i;
- }
- used_.insert(name);
- return name;
-}
-
-MangleNamer::MangleNamer(SymbolTable* symbols) : Namer(symbols) {}
-
-MangleNamer::~MangleNamer() = default;
-
-std::string MangleNamer::NameFor(const Symbol& sym) {
- return sym.to_str();
-}
-
-UnsafeNamer::UnsafeNamer(SymbolTable* symbols) : Namer(symbols) {}
-
-UnsafeNamer::~UnsafeNamer() = default;
-
-std::string UnsafeNamer::NameFor(const Symbol& sym) {
- return symbols_->NameFor(sym);
-}
-
-} // namespace tint
diff --git a/src/namer.h b/src/namer.h
deleted file mode 100644
index 2510889..0000000
--- a/src/namer.h
+++ /dev/null
@@ -1,93 +0,0 @@
-// Copyright 2020 The Tint Authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef SRC_NAMER_H_
-#define SRC_NAMER_H_
-
-#include <string>
-#include <unordered_map>
-#include <unordered_set>
-
-#include "src/symbol_table.h"
-
-namespace tint {
-
-/// Base class for the namers.
-class Namer {
- public:
- /// Constructor
- /// @param symbols the symbol table this namer works with
- explicit Namer(SymbolTable* symbols);
- /// Destructor
- virtual ~Namer();
-
- /// Returns the name for `sym`
- /// @param sym the symbol to retrieve the name for
- /// @returns the sanitized version of `name` or "" if not found
- virtual std::string NameFor(const Symbol& sym) = 0;
-
- /// Generates a unique name for `prefix`
- /// @param prefix the prefix name
- /// @returns the unique name string
- std::string GenerateName(const std::string& prefix);
-
- protected:
- /// Checks if `name` has been used
- /// @param name the name to check
- /// @returns true if `name` has already been used
- bool IsUsed(const std::string& name);
-
- /// The symbol table
- SymbolTable* symbols_ = nullptr;
-
- private:
- // The list of names taken by the remapper
- std::unordered_set<std::string> used_;
-};
-
-/// A namer class which mangles the name
-class MangleNamer : public Namer {
- public:
- /// Constructor
- /// @param symbols the symbol table this namer works with
- explicit MangleNamer(SymbolTable* symbols);
- /// Destructor
- ~MangleNamer() override;
-
- /// Returns a mangled name for `sym`
- /// @param sym the symbol to name
- /// @returns the name for `sym` or "" if not found
- std::string NameFor(const Symbol& sym) override;
-};
-
-/// A namer which returns the user provided name. This is unsafe in general as
-/// it passes user provided data through to the backend compiler. It is useful
-/// for development and debugging.
-class UnsafeNamer : public Namer {
- public:
- /// Constructor
- /// @param symbols the symbol table this namer works with
- explicit UnsafeNamer(SymbolTable* symbols);
- /// Destructor
- ~UnsafeNamer() override;
-
- /// Returns `name`
- /// @param sym the symbol
- /// @returns `name` or "" if not found
- std::string NameFor(const Symbol& sym) override;
-};
-
-} // namespace tint
-
-#endif // SRC_NAMER_H_
diff --git a/src/namer_test.cc b/src/namer_test.cc
deleted file mode 100644
index efd863b..0000000
--- a/src/namer_test.cc
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2020 The Tint Authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "src/namer.h"
-
-#include "gtest/gtest.h"
-#include "src/symbol_table.h"
-
-namespace tint {
-namespace {
-
-using NamerTest = testing::Test;
-
-TEST_F(NamerTest, GenerateName) {
- SymbolTable t;
- MangleNamer n(&t);
- EXPECT_EQ("name", n.GenerateName("name"));
- EXPECT_EQ("name_0", n.GenerateName("name"));
- EXPECT_EQ("name_1", n.GenerateName("name"));
-}
-
-using MangleNamerTest = testing::Test;
-
-TEST_F(MangleNamerTest, ReturnsName) {
- SymbolTable t;
- auto s = t.Register("my_sym");
-
- MangleNamer n(&t);
- EXPECT_EQ("tint_symbol_1", n.NameFor(s));
-}
-
-TEST_F(MangleNamerTest, ReturnsSameValueForSameName) {
- SymbolTable t;
- auto s1 = t.Register("my_sym");
- auto s2 = t.Register("my_sym2");
-
- MangleNamer n(&t);
- EXPECT_EQ("tint_symbol_1", n.NameFor(s1));
- EXPECT_EQ("tint_symbol_2", n.NameFor(s2));
- EXPECT_EQ("tint_symbol_1", n.NameFor(s1));
-}
-
-using UnsafeNamerTest = testing::Test;
-TEST_F(UnsafeNamerTest, ReturnsName) {
- SymbolTable t;
- auto s = t.Register("my_sym");
-
- UnsafeNamer n(&t);
- EXPECT_EQ("my_sym", n.NameFor(s));
-}
-
-} // namespace
-} // namespace tint