ast: Remove no-arg constructor for ast::CastStatement
In a near-future change, AST nodes, such as ast::BlockStatement will no longer be std::unique_ptrs, and will have to be constructed and owned by an external class. This means AST nodes can no longer allocate default child nodes. Bug: tint:322 Change-Id: I2a571d0a4727d6dc3d6c38e8b6602e131292f49c Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32676 Reviewed-by: dan sinclair <dsinclair@chromium.org> Commit-Queue: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
e5e9617220
commit
4ad0019df0
|
@ -17,9 +17,6 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
CaseStatement::CaseStatement()
|
||||
: Statement(), body_(std::make_unique<BlockStatement>()) {}
|
||||
|
||||
CaseStatement::CaseStatement(std::unique_ptr<BlockStatement> body)
|
||||
: Statement(), body_(std::move(body)) {}
|
||||
|
||||
|
|
|
@ -33,8 +33,6 @@ using CaseSelectorList = std::vector<std::unique_ptr<ast::IntLiteral>>;
|
|||
/// A case statement
|
||||
class CaseStatement : public Statement {
|
||||
public:
|
||||
/// Constructor
|
||||
CaseStatement();
|
||||
/// Constructor
|
||||
/// Creates a default case statement
|
||||
/// @param body the case body
|
||||
|
|
|
@ -85,7 +85,7 @@ TEST_F(CaseStatementTest, IsDefault_WithoutSelectors) {
|
|||
auto body = create<BlockStatement>();
|
||||
body->append(create<DiscardStatement>());
|
||||
|
||||
CaseStatement c;
|
||||
CaseStatement c(create<ast::BlockStatement>());
|
||||
c.set_body(std::move(body));
|
||||
EXPECT_TRUE(c.IsDefault());
|
||||
}
|
||||
|
@ -95,18 +95,18 @@ TEST_F(CaseStatementTest, IsDefault_WithSelectors) {
|
|||
CaseSelectorList b;
|
||||
b.push_back(create<SintLiteral>(&i32, 2));
|
||||
|
||||
CaseStatement c;
|
||||
CaseStatement c(create<ast::BlockStatement>());
|
||||
c.set_selectors(std::move(b));
|
||||
EXPECT_FALSE(c.IsDefault());
|
||||
}
|
||||
|
||||
TEST_F(CaseStatementTest, IsCase) {
|
||||
CaseStatement c;
|
||||
CaseStatement c(create<ast::BlockStatement>());
|
||||
EXPECT_TRUE(c.IsCase());
|
||||
}
|
||||
|
||||
TEST_F(CaseStatementTest, IsValid) {
|
||||
CaseStatement c;
|
||||
CaseStatement c(create<ast::BlockStatement>());
|
||||
EXPECT_TRUE(c.IsValid());
|
||||
}
|
||||
|
||||
|
|
|
@ -2150,7 +2150,8 @@ bool FunctionEmitter::EmitSwitchStart(const BlockInfo& block_info) {
|
|||
for (size_t i = last_clause_index;; --i) {
|
||||
// Create the case clause. Temporarily put it in the wrong order
|
||||
// on the case statement list.
|
||||
cases->emplace_back(std::make_unique<ast::CaseStatement>());
|
||||
cases->emplace_back(std::make_unique<ast::CaseStatement>(
|
||||
std::make_unique<ast::BlockStatement>()));
|
||||
auto* clause = cases->back().get();
|
||||
|
||||
// Create a list of integer literals for the selector values leading to
|
||||
|
@ -2189,8 +2190,7 @@ bool FunctionEmitter::EmitSwitchStart(const BlockInfo& block_info) {
|
|||
// Generate a default clause with a just fallthrough.
|
||||
auto stmts = std::make_unique<ast::BlockStatement>();
|
||||
stmts->append(std::make_unique<ast::FallthroughStatement>());
|
||||
auto case_stmt = std::make_unique<ast::CaseStatement>();
|
||||
case_stmt->set_body(std::move(stmts));
|
||||
auto case_stmt = std::make_unique<ast::CaseStatement>(std::move(stmts));
|
||||
cases->emplace_back(std::move(case_stmt));
|
||||
}
|
||||
|
||||
|
|
|
@ -1653,7 +1653,8 @@ Maybe<std::unique_ptr<ast::CaseStatement>> ParserImpl::switch_body() {
|
|||
auto source = t.source();
|
||||
next(); // Consume the peek
|
||||
|
||||
auto stmt = std::make_unique<ast::CaseStatement>();
|
||||
auto stmt = std::make_unique<ast::CaseStatement>(
|
||||
std::make_unique<ast::BlockStatement>());
|
||||
stmt->set_source(source);
|
||||
if (t.IsCase()) {
|
||||
auto selectors = expect_case_selectors();
|
||||
|
|
|
@ -106,11 +106,9 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case_MultipleSelectors) {
|
|||
}
|
||||
|
||||
TEST_F(HlslGeneratorImplTest_Case, Emit_Case_Default) {
|
||||
ast::CaseStatement c;
|
||||
|
||||
auto body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::BreakStatement>());
|
||||
c.set_body(std::move(body));
|
||||
ast::CaseStatement c(std::move(body));
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
|
|
|
@ -31,10 +31,9 @@ namespace {
|
|||
using HlslGeneratorImplTest_Switch = TestHelper;
|
||||
|
||||
TEST_F(HlslGeneratorImplTest_Switch, Emit_Switch) {
|
||||
auto def = create<ast::CaseStatement>();
|
||||
auto def_body = create<ast::BlockStatement>();
|
||||
def_body->append(create<ast::BreakStatement>());
|
||||
def->set_body(std::move(def_body));
|
||||
auto def = create<ast::CaseStatement>(std::move(def_body));
|
||||
|
||||
ast::type::I32Type i32;
|
||||
ast::CaseSelectorList case_val;
|
||||
|
|
|
@ -108,11 +108,9 @@ TEST_F(MslGeneratorImplTest, Emit_Case_MultipleSelectors) {
|
|||
}
|
||||
|
||||
TEST_F(MslGeneratorImplTest, Emit_Case_Default) {
|
||||
ast::CaseStatement c;
|
||||
|
||||
auto body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::BreakStatement>());
|
||||
c.set_body(std::move(body));
|
||||
ast::CaseStatement c(std::move(body));
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
|
|
|
@ -33,10 +33,9 @@ namespace {
|
|||
using MslGeneratorImplTest = TestHelper;
|
||||
|
||||
TEST_F(MslGeneratorImplTest, Emit_Switch) {
|
||||
auto def = create<ast::CaseStatement>();
|
||||
auto def_body = create<ast::BlockStatement>();
|
||||
def_body->append(create<ast::BreakStatement>());
|
||||
def->set_body(std::move(def_body));
|
||||
auto def = create<ast::CaseStatement>(std::move(def_body));
|
||||
|
||||
ast::type::I32Type i32;
|
||||
ast::CaseSelectorList case_val;
|
||||
|
|
|
@ -70,11 +70,9 @@ TEST_F(WgslGeneratorImplTest, Emit_Case_MultipleSelectors) {
|
|||
}
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, Emit_Case_Default) {
|
||||
ast::CaseStatement c;
|
||||
|
||||
auto body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::BreakStatement>());
|
||||
c.set_body(std::move(body));
|
||||
ast::CaseStatement c(std::move(body));
|
||||
|
||||
gen.increment_indent();
|
||||
|
||||
|
|
|
@ -32,10 +32,9 @@ namespace {
|
|||
using WgslGeneratorImplTest = TestHelper;
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, Emit_Switch) {
|
||||
auto def = create<ast::CaseStatement>();
|
||||
auto def_body = create<ast::BlockStatement>();
|
||||
def_body->append(create<ast::BreakStatement>());
|
||||
def->set_body(std::move(def_body));
|
||||
auto def = create<ast::CaseStatement>(std::move(def_body));
|
||||
|
||||
ast::type::I32Type i32;
|
||||
ast::CaseSelectorList case_val;
|
||||
|
|
Loading…
Reference in New Issue