[ast] Remove unused constructors and setters.

This CL removes unused default constructors and various set methods
from the AST classes where they are not longer required.

Change-Id: Ic437911c62d8c9e4354a1fa6bdc8483ce7511daf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34641
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
dan sinclair
2020-12-02 14:31:38 +00:00
committed by Commit Bot service account
parent fb54145b6f
commit 4d28b27935
71 changed files with 189 additions and 376 deletions

View File

@@ -2137,12 +2137,13 @@ bool FunctionEmitter::EmitSwitchStart(const BlockInfo& block_info) {
assert(construct->begin_id == block_info.id);
const auto* branch = block_info.basic_block->terminator();
auto* const switch_stmt =
AddStatement(create<ast::SwitchStatement>())->As<ast::SwitchStatement>();
const auto selector_id = branch->GetSingleWordInOperand(0);
// Generate the code for the selector.
auto selector = MakeExpression(selector_id);
switch_stmt->set_condition(selector.expr);
ast::CaseStatementList list;
auto* swch = create<ast::SwitchStatement>(selector.expr, list);
auto* const switch_stmt = AddStatement(swch)->As<ast::SwitchStatement>();
// First, push the statement block for the entire switch. All the actual
// work is done by completion actions of the case/default clauses.
@@ -2194,12 +2195,6 @@ bool FunctionEmitter::EmitSwitchStart(const BlockInfo& block_info) {
// Push them on in reverse order.
const auto last_clause_index = clause_heads.size() - 1;
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(
create<ast::CaseStatement>(create<ast::BlockStatement>()));
auto* clause = cases->back();
// Create a list of integer literals for the selector values leading to
// this case clause.
ast::CaseSelectorList selectors;
@@ -2220,14 +2215,20 @@ bool FunctionEmitter::EmitSwitchStart(const BlockInfo& block_info) {
create<ast::SintLiteral>(selector.type, value32));
}
}
clause->set_selectors(selectors);
}
// Where does this clause end?
const auto end_id = (i + 1 < clause_heads.size()) ? clause_heads[i + 1]->id
: construct->end_id;
// Create the case clause. Temporarily put it in the wrong order
// on the case statement list.
cases->emplace_back(create<ast::CaseStatement>(selectors, nullptr));
auto* clause = cases->back();
PushNewStatementBlock(construct, end_id, [clause](StatementBlock* s) {
// The `set_body` method of CaseStatement can be removed if this set
// is removed.
clause->set_body(s->statements_);
});

View File

@@ -1745,14 +1745,13 @@ Maybe<ast::CaseStatement*> ParserImpl::switch_body() {
auto source = t.source();
next(); // Consume the peek
auto* stmt = create<ast::CaseStatement>(create<ast::BlockStatement>());
stmt->set_source(source);
ast::CaseSelectorList selector_list;
if (t.IsCase()) {
auto selectors = expect_case_selectors();
if (selectors.errored)
return Failure::kErrored;
stmt->set_selectors(std::move(selectors.value));
selector_list = std::move(selectors.value);
}
const char* use = "case statement";
@@ -1767,9 +1766,7 @@ Maybe<ast::CaseStatement*> ParserImpl::switch_body() {
if (!body.matched)
return add_error(body.source, "expected case body");
stmt->set_body(body.value);
return stmt;
return create<ast::CaseStatement>(source, selector_list, body.value);
}
// case_selectors