Remove ast::NullLiteral
This isn't in the WGSL spec, nor is it generated by readers.
This was only used inside the SPIR-V writer, but this remaining usage was removed in the parent change.
Change-Id: I1bbfde67dc760b761af010a7a144dccb52369148
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45343
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
diff --git a/src/BUILD.gn b/src/BUILD.gn
index fc82118..80a6f1a 100644
--- a/src/BUILD.gn
+++ b/src/BUILD.gn
@@ -299,8 +299,6 @@
"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 9e5f29e..80b49a5 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -108,8 +108,6 @@
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 @@
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 398ff84..de3a358 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 @@
EXPECT_FALSE(l->Is<FloatLiteral>());
EXPECT_FALSE(l->Is<UintLiteral>());
EXPECT_FALSE(l->Is<IntLiteral>());
- EXPECT_FALSE(l->Is<NullLiteral>());
}
TEST_F(BoolLiteralTest, ToStr) {
diff --git a/src/ast/float_literal_test.cc b/src/ast/float_literal_test.cc
index 4f7572c..0ffeddf 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 @@
EXPECT_FALSE(l->Is<IntLiteral>());
EXPECT_TRUE(l->Is<FloatLiteral>());
EXPECT_FALSE(l->Is<UintLiteral>());
- EXPECT_FALSE(l->Is<NullLiteral>());
}
TEST_F(FloatLiteralTest, ToStr) {
diff --git a/src/ast/null_literal.cc b/src/ast/null_literal.cc
deleted file mode 100644
index 1594789..0000000
--- 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<NullLiteral>(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 c1455a2..0000000
--- 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 <string>
-
-#include "src/ast/literal.h"
-
-namespace tint {
-namespace ast {
-
-/// A null literal
-class NullLiteral : public Castable<NullLiteral, Literal> {
- 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 ae90f3d..0000000
--- 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<NullLiteral>(ty.i32());
- EXPECT_FALSE(l->Is<BoolLiteral>());
- EXPECT_FALSE(l->Is<SintLiteral>());
- EXPECT_FALSE(l->Is<FloatLiteral>());
- EXPECT_FALSE(l->Is<UintLiteral>());
- EXPECT_FALSE(l->Is<IntLiteral>());
- EXPECT_TRUE(l->Is<NullLiteral>());
-}
-
-TEST_F(NullLiteralTest, ToStr) {
- auto* i = create<NullLiteral>(ty.i32());
- EXPECT_EQ(str(i), "null __i32");
-}
-
-TEST_F(NullLiteralTest, Name_I32) {
- auto* i = create<NullLiteral>(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 7d82638..8baa906 100644
--- a/src/ast/scalar_constructor_expression_test.cc
+++ b/src/ast/scalar_constructor_expression_test.cc
@@ -34,15 +34,6 @@
EXPECT_EQ(src.range.begin.column, 2u);
}
-TEST_F(ScalarConstructorExpressionTest, Assert_NullLiteral) {
- EXPECT_FATAL_FAILURE(
- {
- ProgramBuilder b;
- b.create<ScalarConstructorExpression>(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 9ca7b9a..cfd7ec6 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 @@
EXPECT_TRUE(l->Is<SintLiteral>());
EXPECT_FALSE(l->Is<FloatLiteral>());
EXPECT_FALSE(l->Is<UintLiteral>());
- EXPECT_FALSE(l->Is<NullLiteral>());
}
TEST_F(SintLiteralTest, ToStr) {
diff --git a/src/ast/uint_literal_test.cc b/src/ast/uint_literal_test.cc
index a1b09a4..da12f27 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 @@
EXPECT_FALSE(l->Is<SintLiteral>());
EXPECT_FALSE(l->Is<FloatLiteral>());
EXPECT_TRUE(l->Is<UintLiteral>());
- EXPECT_FALSE(l->Is<NullLiteral>());
}
TEST_F(UintLiteralTest, ToStr) {
diff --git a/test/BUILD.gn b/test/BUILD.gn
index b69dd73..735e85c 100644
--- a/test/BUILD.gn
+++ b/test/BUILD.gn
@@ -139,7 +139,6 @@
"../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",