diff --git a/src/BUILD.gn b/src/BUILD.gn index fc82118034..80a6f1a2c1 100644 --- a/src/BUILD.gn +++ b/src/BUILD.gn @@ -299,8 +299,6 @@ source_set("libtint_core_src") { "ast/module.h", "ast/node.cc", "ast/node.h", - "ast/null_literal.cc", - "ast/null_literal.h", "ast/pipeline_stage.cc", "ast/pipeline_stage.h", "ast/return_statement.cc", diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9e5f29e7f3..80b49a561c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -108,8 +108,6 @@ set(TINT_LIB_SRCS ast/module.h ast/node.cc ast/node.h - ast/null_literal.cc - ast/null_literal.h ast/pipeline_stage.cc ast/pipeline_stage.h ast/return_statement.cc @@ -439,7 +437,6 @@ if(${TINT_BUILD_TESTS}) ast/member_accessor_expression_test.cc ast/module_clone_test.cc ast/module_test.cc - ast/null_literal_test.cc ast/return_statement_test.cc ast/scalar_constructor_expression_test.cc ast/sint_literal_test.cc diff --git a/src/ast/bool_literal_test.cc b/src/ast/bool_literal_test.cc index 398ff84309..de3a358202 100644 --- a/src/ast/bool_literal_test.cc +++ b/src/ast/bool_literal_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/ast/null_literal.h" #include "src/ast/test_helper.h" namespace tint { @@ -45,7 +44,6 @@ TEST_F(BoolLiteralTest, Is) { EXPECT_FALSE(l->Is()); EXPECT_FALSE(l->Is()); EXPECT_FALSE(l->Is()); - EXPECT_FALSE(l->Is()); } TEST_F(BoolLiteralTest, ToStr) { diff --git a/src/ast/float_literal_test.cc b/src/ast/float_literal_test.cc index 4f7572cd83..0ffeddf868 100644 --- a/src/ast/float_literal_test.cc +++ b/src/ast/float_literal_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/ast/null_literal.h" #include "src/ast/test_helper.h" namespace tint { @@ -34,7 +33,6 @@ TEST_F(FloatLiteralTest, Is) { EXPECT_FALSE(l->Is()); EXPECT_TRUE(l->Is()); EXPECT_FALSE(l->Is()); - EXPECT_FALSE(l->Is()); } TEST_F(FloatLiteralTest, ToStr) { diff --git a/src/ast/null_literal.cc b/src/ast/null_literal.cc deleted file mode 100644 index 1594789f51..0000000000 --- a/src/ast/null_literal.cc +++ /dev/null @@ -1,45 +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/ast/null_literal.h" - -#include "src/program_builder.h" - -TINT_INSTANTIATE_TYPEINFO(tint::ast::NullLiteral); - -namespace tint { -namespace ast { - -NullLiteral::NullLiteral(const Source& source, type::Type* type) - : Base(source, type) {} - -NullLiteral::~NullLiteral() = default; - -std::string NullLiteral::to_str(const semantic::Info&) const { - return "null " + type()->type_name(); -} - -std::string NullLiteral::name() const { - return "__null" + type()->type_name(); -} - -NullLiteral* NullLiteral::Clone(CloneContext* ctx) const { - // Clone arguments outside of create() call to have deterministic ordering - auto src = ctx->Clone(source()); - auto* ty = ctx->Clone(type()); - return ctx->dst->create(src, ty); -} - -} // namespace ast -} // namespace tint diff --git a/src/ast/null_literal.h b/src/ast/null_literal.h deleted file mode 100644 index c1455a2168..0000000000 --- a/src/ast/null_literal.h +++ /dev/null @@ -1,51 +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_AST_NULL_LITERAL_H_ -#define SRC_AST_NULL_LITERAL_H_ - -#include - -#include "src/ast/literal.h" - -namespace tint { -namespace ast { - -/// A null literal -class NullLiteral : public Castable { - public: - /// Constructor - /// @param source the input source - /// @param type the type - NullLiteral(const Source& source, type::Type* type); - ~NullLiteral() override; - - /// @returns the name for this literal. This name is unique to this value. - std::string name() const override; - - /// @param sem the semantic info for the program - /// @returns the literal as a string - std::string to_str(const semantic::Info& sem) const override; - - /// Clones this node and all transitive child nodes using the `CloneContext` - /// `ctx`. - /// @param ctx the clone context - /// @return the newly cloned node - NullLiteral* Clone(CloneContext* ctx) const override; -}; - -} // namespace ast -} // namespace tint - -#endif // SRC_AST_NULL_LITERAL_H_ diff --git a/src/ast/null_literal_test.cc b/src/ast/null_literal_test.cc deleted file mode 100644 index ae90f3d7b5..0000000000 --- a/src/ast/null_literal_test.cc +++ /dev/null @@ -1,47 +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/ast/null_literal.h" - -#include "src/ast/test_helper.h" - -namespace tint { -namespace ast { -namespace { - -using NullLiteralTest = TestHelper; - -TEST_F(NullLiteralTest, Is) { - ast::Literal* l = create(ty.i32()); - EXPECT_FALSE(l->Is()); - EXPECT_FALSE(l->Is()); - EXPECT_FALSE(l->Is()); - EXPECT_FALSE(l->Is()); - EXPECT_FALSE(l->Is()); - EXPECT_TRUE(l->Is()); -} - -TEST_F(NullLiteralTest, ToStr) { - auto* i = create(ty.i32()); - EXPECT_EQ(str(i), "null __i32"); -} - -TEST_F(NullLiteralTest, Name_I32) { - auto* i = create(ty.i32()); - EXPECT_EQ("__null__i32", i->name()); -} - -} // namespace -} // namespace ast -} // namespace tint diff --git a/src/ast/scalar_constructor_expression_test.cc b/src/ast/scalar_constructor_expression_test.cc index 7d8263807e..8baa906a8d 100644 --- a/src/ast/scalar_constructor_expression_test.cc +++ b/src/ast/scalar_constructor_expression_test.cc @@ -34,15 +34,6 @@ TEST_F(ScalarConstructorExpressionTest, Creation_WithSource) { EXPECT_EQ(src.range.begin.column, 2u); } -TEST_F(ScalarConstructorExpressionTest, Assert_NullLiteral) { - EXPECT_FATAL_FAILURE( - { - ProgramBuilder b; - b.create(nullptr); - }, - "internal compiler error"); -} - TEST_F(ScalarConstructorExpressionTest, ToStr) { auto* c = Expr(true); EXPECT_EQ(str(c), R"(ScalarConstructor[not set]{true} diff --git a/src/ast/sint_literal_test.cc b/src/ast/sint_literal_test.cc index 9ca7b9a508..cfd7ec62ef 100644 --- a/src/ast/sint_literal_test.cc +++ b/src/ast/sint_literal_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/ast/null_literal.h" #include "src/ast/test_helper.h" namespace tint { @@ -33,7 +32,6 @@ TEST_F(SintLiteralTest, Is) { EXPECT_TRUE(l->Is()); EXPECT_FALSE(l->Is()); EXPECT_FALSE(l->Is()); - EXPECT_FALSE(l->Is()); } TEST_F(SintLiteralTest, ToStr) { diff --git a/src/ast/uint_literal_test.cc b/src/ast/uint_literal_test.cc index a1b09a43cc..da12f27c88 100644 --- a/src/ast/uint_literal_test.cc +++ b/src/ast/uint_literal_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/ast/null_literal.h" #include "src/ast/test_helper.h" namespace tint { @@ -33,7 +32,6 @@ TEST_F(UintLiteralTest, Is) { EXPECT_FALSE(l->Is()); EXPECT_FALSE(l->Is()); EXPECT_TRUE(l->Is()); - EXPECT_FALSE(l->Is()); } TEST_F(UintLiteralTest, ToStr) { diff --git a/test/BUILD.gn b/test/BUILD.gn index b69dd73fb4..735e85cdaf 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -139,7 +139,6 @@ source_set("tint_unittests_core_src") { "../src/ast/member_accessor_expression_test.cc", "../src/ast/module_clone_test.cc", "../src/ast/module_test.cc", - "../src/ast/null_literal_test.cc", "../src/ast/return_statement_test.cc", "../src/ast/scalar_constructor_expression_test.cc", "../src/ast/sint_literal_test.cc",