Remove unused methods. Cleanup some methods which are no longer necessary. Change-Id: I7f4edc41ba376199f33e306cbdd10cfab0f6c411 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/248774 Reviewed-by: James Price <jrprice@google.com> Commit-Queue: dan sinclair <dsinclair@chromium.org>
diff --git a/src/tint/lang/wgsl/program/program_builder.cc b/src/tint/lang/wgsl/program/program_builder.cc index b8ae5ac..5f5b402 100644 --- a/src/tint/lang/wgsl/program/program_builder.cc +++ b/src/tint/lang/wgsl/program/program_builder.cc
@@ -59,19 +59,6 @@ return *this; } -ProgramBuilder ProgramBuilder::Wrap(const Program& program) { - ProgramBuilder builder; - builder.id_ = program.ID(); - builder.last_ast_node_id_ = program.HighestASTNodeID(); - builder.constants = core::constant::Manager::Wrap(program.Constants()); - builder.ast_ = - builder.create<ast::Module>(program.AST().source, program.AST().GlobalDeclarations()); - builder.sem_ = sem::Info::Wrap(program.Sem()); - builder.symbols_ = SymbolTable::Wrap(program.Symbols()); - builder.diagnostics_ = program.Diagnostics(); - return builder; -} - void ProgramBuilder::AssertNotMoved() const { if (DAWN_UNLIKELY(moved_)) { TINT_ICE() << "Attempting to use ProgramBuilder after it has been moved";
diff --git a/src/tint/lang/wgsl/program/program_builder.h b/src/tint/lang/wgsl/program/program_builder.h index 483c718..dc06a07 100644 --- a/src/tint/lang/wgsl/program/program_builder.h +++ b/src/tint/lang/wgsl/program/program_builder.h
@@ -93,18 +93,6 @@ /// @return this builder ProgramBuilder& operator=(ProgramBuilder&& rhs); - /// Wrap returns a new ProgramBuilder wrapping the Program `program` without - /// making a deep clone of the Program contents. - /// ProgramBuilder returned by Wrap() is intended to temporarily extend an - /// existing immutable program. - /// As the returned ProgramBuilder wraps `program`, `program` must not be - /// destructed or assigned while using the returned ProgramBuilder. - /// TODO(crbug.com/tint/460) - Evaluate whether there are safer alternatives to this - /// function. - /// @param program the immutable Program to wrap - /// @return the ProgramBuilder that wraps `program` - static ProgramBuilder Wrap(const Program& program); - /// @returns a reference to the program's types core::type::Manager& Types() { AssertNotMoved(); @@ -155,10 +143,9 @@ /// @param args the arguments to pass to the constructor /// @returns the node pointer template <typename T, typename... ARGS> - std::enable_if_t<tint::traits::IsTypeOrDerived<T, sem::Node> && - !tint::traits::IsTypeOrDerived<T, core::type::Node>, - T>* - create(ARGS&&... args) { + requires(tint::traits::IsTypeOrDerived<T, sem::Node> && + !tint::traits::IsTypeOrDerived<T, core::type::Node>) + T* create(ARGS&&... args) { AssertNotMoved(); return sem_nodes_.Create<T>(std::forward<ARGS>(args)...); }
diff --git a/src/tint/lang/wgsl/program/program_builder_test.cc b/src/tint/lang/wgsl/program/program_builder_test.cc index e99dfe52..6142792 100644 --- a/src/tint/lang/wgsl/program/program_builder_test.cc +++ b/src/tint/lang/wgsl/program/program_builder_test.cc
@@ -43,43 +43,5 @@ EXPECT_NE(program_c.ID(), program_a.ID()); } -TEST_F(ProgramBuilderTest, WrapDoesntAffectInner) { - Program inner([] { - ProgramBuilder builder; - auto ty = builder.ty.f32(); - builder.Func("a", {}, ty, {}, {}); - return builder; - }()); - - ASSERT_EQ(inner.AST().Functions().Length(), 1u); - ASSERT_TRUE(inner.Symbols().Get("a").IsValid()); - ASSERT_FALSE(inner.Symbols().Get("b").IsValid()); - - ProgramBuilder outer = ProgramBuilder::Wrap(inner); - - ASSERT_EQ(inner.AST().Functions().Length(), 1u); - ASSERT_EQ(outer.AST().Functions().Length(), 1u); - EXPECT_EQ(inner.AST().Functions()[0], outer.AST().Functions()[0]); - EXPECT_TRUE(inner.Symbols().Get("a").IsValid()); - EXPECT_EQ(inner.Symbols().Get("a"), outer.Symbols().Get("a")); - EXPECT_TRUE(inner.Symbols().Get("a").IsValid()); - EXPECT_TRUE(outer.Symbols().Get("a").IsValid()); - EXPECT_FALSE(inner.Symbols().Get("b").IsValid()); - EXPECT_FALSE(outer.Symbols().Get("b").IsValid()); - - auto ty = outer.ty.f32(); - outer.Func("b", {}, ty, {}, {}); - - ASSERT_EQ(inner.AST().Functions().Length(), 1u); - ASSERT_EQ(outer.AST().Functions().Length(), 2u); - EXPECT_EQ(inner.AST().Functions()[0], outer.AST().Functions()[0]); - EXPECT_EQ(outer.AST().Functions()[1]->name->symbol, outer.Symbols().Get("b")); - EXPECT_EQ(inner.Symbols().Get("a"), outer.Symbols().Get("a")); - EXPECT_TRUE(inner.Symbols().Get("a").IsValid()); - EXPECT_TRUE(outer.Symbols().Get("a").IsValid()); - EXPECT_FALSE(inner.Symbols().Get("b").IsValid()); - EXPECT_TRUE(outer.Symbols().Get("b").IsValid()); -} - } // namespace } // namespace tint
diff --git a/src/tint/lang/wgsl/sem/call_target.h b/src/tint/lang/wgsl/sem/call_target.h index 77893df..f64d153 100644 --- a/src/tint/lang/wgsl/sem/call_target.h +++ b/src/tint/lang/wgsl/sem/call_target.h
@@ -67,14 +67,6 @@ /// parameter with the given usage exists. int IndexOf(core::ParameterUsage usage) const; - /// @param usage the parameter usage to find - /// @returns the parameter with the given usage, or nullptr if no parameter with the given - /// usage exists. - inline const sem::Parameter* Parameter(core::ParameterUsage usage) const { - auto idx = IndexOf(usage); - return (idx >= 0) ? parameters[static_cast<size_t>(idx)] : nullptr; - } - /// The type of the call target return value const core::type::Type* return_type = nullptr;
diff --git a/src/tint/lang/wgsl/sem/info.h b/src/tint/lang/wgsl/sem/info.h index bd2daf4..d028695 100644 --- a/src/tint/lang/wgsl/sem/info.h +++ b/src/tint/lang/wgsl/sem/info.h
@@ -127,20 +127,6 @@ nodes_[ast_node->node_id.value] = sem_node; } - /// Wrap returns a new Info created with the contents of `inner`. - /// The Info returned by Wrap is intended to temporarily extend the contents - /// of an existing immutable Info. - /// As the copied contents are owned by `inner`, `inner` must not be - /// destructed or assigned while using the returned Info. - /// @param inner the immutable Info to extend - /// @return the Info that wraps `inner` - static Info Wrap(const Info& inner) { - Info out; - out.nodes_ = inner.nodes_; - out.module_ = inner.module_; - return out; - } - /// Assigns the semantic module. /// @param module the module to assign. void SetModule(sem::Module* module) { module_ = module; }
diff --git a/src/tint/lang/wgsl/sem/variable.cc b/src/tint/lang/wgsl/sem/variable.cc index e056c77..37008d5 100644 --- a/src/tint/lang/wgsl/sem/variable.cc +++ b/src/tint/lang/wgsl/sem/variable.cc
@@ -63,7 +63,7 @@ } Parameter::Parameter(const ast::Parameter* declaration, - uint32_t index /* = 0 */, + uint32_t index, const core::type::Type* type /* = nullptr */, core::ParameterUsage usage /* = core::ParameterUsage::kNone */) : Base(declaration), index_(index), usage_(usage) {
diff --git a/src/tint/lang/wgsl/sem/variable.h b/src/tint/lang/wgsl/sem/variable.h index d8c02f6..5e81f70 100644 --- a/src/tint/lang/wgsl/sem/variable.h +++ b/src/tint/lang/wgsl/sem/variable.h
@@ -211,7 +211,7 @@ /// @param type the variable type /// @param usage the parameter usage Parameter(const ast::Parameter* declaration, - uint32_t index = 0, + uint32_t index, const core::type::Type* type = nullptr, core::ParameterUsage usage = core::ParameterUsage::kNone); @@ -226,9 +226,6 @@ /// @return the index of the parameter in the function uint32_t Index() const { return index_; } - /// @param usage the semantic usage for the parameter - void SetUsage(core::ParameterUsage usage) { usage_ = usage; } - /// @returns the semantic usage for the parameter core::ParameterUsage Usage() const { return usage_; } @@ -286,24 +283,6 @@ const sem::Variable* const variable_; }; -/// A pair of sem::Variables. Can be hashed. -typedef std::pair<const Variable*, const Variable*> VariablePair; - } // namespace tint::sem -namespace std { - -/// Custom std::hash specialization for VariablePair -template <> -class hash<tint::sem::VariablePair> { - public: - /// @param i the variable pair to create a hash for - /// @return the hash value - inline std::size_t operator()(const tint::sem::VariablePair& i) const { - return Hash(i.first, i.second); - } -}; - -} // namespace std - #endif // SRC_TINT_LANG_WGSL_SEM_VARIABLE_H_