reader/spirv: Fix permissive GCC warning

... about getters having the same name as the type they return. Prefix getters with `Get`, remove unused ones.

Also remove the cases field, the compiler helpfully now tells us it is unused.

Change-Id: I7e3fcdae3818cee5aae8b70b48e9b0507a8d3b45
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35743
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
diff --git a/src/reader/spirv/function.cc b/src/reader/spirv/function.cc
index c8303d5..4a6350d 100644
--- a/src/reader/spirv/function.cc
+++ b/src/reader/spirv/function.cc
@@ -711,7 +711,7 @@
       function_(function),
       i32_(ast_module_.create<ast::type::I32>()),
       ep_info_(ep_info) {
-  PushNewStatementBlock(nullptr, 0, nullptr, nullptr);
+  PushNewStatementBlock(nullptr, 0, nullptr);
 }
 
 FunctionEmitter::FunctionEmitter(ParserImpl* pi,
@@ -721,14 +721,12 @@
 FunctionEmitter::~FunctionEmitter() = default;
 
 FunctionEmitter::StatementBlock::StatementBlock(
-    const spirv::Construct* construct,
+    const Construct* construct,
     uint32_t end_id,
-    FunctionEmitter::CompletionAction completion_action,
-    ast::CaseStatementList* cases)
+    FunctionEmitter::CompletionAction completion_action)
     : construct_(construct),
       end_id_(end_id),
-      completion_action_(completion_action),
-      cases_(cases) {}
+      completion_action_(completion_action) {}
 
 FunctionEmitter::StatementBlock::StatementBlock(StatementBlock&& other) =
     default;
@@ -758,10 +756,8 @@
 
 void FunctionEmitter::PushNewStatementBlock(const Construct* construct,
                                             uint32_t end_id,
-                                            ast::CaseStatementList* cases,
                                             CompletionAction action) {
-  statements_stack_.emplace_back(
-      StatementBlock{construct, end_id, action, cases});
+  statements_stack_.emplace_back(StatementBlock{construct, end_id, action});
 }
 
 void FunctionEmitter::PushGuard(const std::string& guard_name,
@@ -778,7 +774,7 @@
   auto* builder = AddStatementBuilder<IfStatementBuilder>(cond);
 
   PushNewStatementBlock(
-      top.Construct(), end_id, nullptr, [=](const ast::StatementList& stmts) {
+      top.GetConstruct(), end_id, [=](const ast::StatementList& stmts) {
         builder->body = create<ast::BlockStatement>(Source{}, stmts);
       });
 }
@@ -791,7 +787,7 @@
   auto* builder = AddStatementBuilder<IfStatementBuilder>(cond);
 
   PushNewStatementBlock(
-      top.Construct(), end_id, nullptr, [=](const ast::StatementList& stmts) {
+      top.GetConstruct(), end_id, [=](const ast::StatementList& stmts) {
         builder->body = create<ast::BlockStatement>(Source{}, stmts);
       });
 }
@@ -800,7 +796,7 @@
   assert(!statements_stack_.empty());
   auto& entry = statements_stack_[0];
   entry.Finalize(&ast_module_);
-  return entry.Statements();
+  return entry.GetStatements();
 }
 
 ast::Statement* FunctionEmitter::AddStatement(ast::Statement* statement) {
@@ -813,7 +809,7 @@
 
 ast::Statement* FunctionEmitter::LastStatement() {
   assert(!statements_stack_.empty());
-  auto& statement_list = statements_stack_.back().Statements();
+  auto& statement_list = statements_stack_.back().GetStatements();
   assert(!statement_list.empty());
   return statement_list.back();
 }
@@ -845,7 +841,7 @@
 
   statements_stack_[0].Finalize(&ast_module_);
 
-  auto& statements = statements_stack_[0].Statements();
+  auto& statements = statements_stack_[0].GetStatements();
   auto* body = create<ast::BlockStatement>(Source{}, statements);
   ast_module_.AddFunction(
       create<ast::Function>(decl.source, ast_module_.RegisterSymbol(decl.name),
@@ -854,7 +850,7 @@
 
   // Maintain the invariant by repopulating the one and only element.
   statements_stack_.clear();
-  PushNewStatementBlock(constructs_[0].get(), 0, nullptr, nullptr);
+  PushNewStatementBlock(constructs_[0].get(), 0, nullptr);
 
   return success();
 }
@@ -2046,7 +2042,7 @@
 bool FunctionEmitter::EmitBasicBlock(const BlockInfo& block_info) {
   // Close off previous constructs.
   while (!statements_stack_.empty() &&
-         (statements_stack_.back().EndId() == block_info.id)) {
+         (statements_stack_.back().GetEndId() == block_info.id)) {
     statements_stack_.back().Finalize(&ast_module_);
     statements_stack_.pop_back();
   }
@@ -2060,7 +2056,7 @@
   std::vector<const Construct*> entering_constructs;  // inner most comes first
   {
     auto* here = block_info.construct;
-    auto* const top_construct = statements_stack_.back().Construct();
+    auto* const top_construct = statements_stack_.back().GetConstruct();
     while (here != top_construct) {
       // Only enter a construct at its header block.
       if (here->begin_id == block_info.id) {
@@ -2290,7 +2286,7 @@
   auto push_else = [this, builder, else_end, construct]() {
     // Push the else clause onto the stack first.
     PushNewStatementBlock(
-        construct, else_end, nullptr, [=](const ast::StatementList& stmts) {
+        construct, else_end, [=](const ast::StatementList& stmts) {
           // Only set the else-clause if there are statements to fill it.
           if (!stmts.empty()) {
             // The "else" consists of the statement list from the top of
@@ -2337,7 +2333,7 @@
 
     // Push the then clause onto the stack.
     PushNewStatementBlock(
-        construct, then_end, nullptr, [=](const ast::StatementList& stmts) {
+        construct, then_end, [=](const ast::StatementList& stmts) {
           builder->body = create<ast::BlockStatement>(Source{}, stmts);
         });
   }
@@ -2361,7 +2357,7 @@
 
   // Grab a pointer to the case list.  It will get buried in the statement block
   // stack.
-  PushNewStatementBlock(construct, construct->end_id, &swch->cases, nullptr);
+  PushNewStatementBlock(construct, construct->end_id, nullptr);
 
   // We will push statement-blocks onto the stack to gather the statements in
   // the default clause and cases clauses. Determine the list of blocks
@@ -2433,7 +2429,7 @@
     auto case_idx = swch->cases.size();
     swch->cases.emplace_back(nullptr);
     PushNewStatementBlock(
-        construct, end_id, nullptr, [=](const ast::StatementList& stmts) {
+        construct, end_id, [=](const ast::StatementList& stmts) {
           auto* body = create<ast::BlockStatement>(Source{}, stmts);
           swch->cases[case_idx] =
               create<ast::CaseStatement>(Source{}, selectors, body);
@@ -2461,11 +2457,10 @@
 
 bool FunctionEmitter::EmitLoopStart(const Construct* construct) {
   auto* builder = AddStatementBuilder<LoopStatementBuilder>();
-  PushNewStatementBlock(construct, construct->end_id, nullptr,
-                        [=](const ast::StatementList& stmts) {
-                          builder->body =
-                              create<ast::BlockStatement>(Source{}, stmts);
-                        });
+  PushNewStatementBlock(
+      construct, construct->end_id, [=](const ast::StatementList& stmts) {
+        builder->body = create<ast::BlockStatement>(Source{}, stmts);
+      });
   return success();
 }
 
@@ -2478,11 +2473,10 @@
     return Fail() << "internal error: starting continue construct, "
                      "expected loop on top of stack";
   }
-  PushNewStatementBlock(construct, construct->end_id, nullptr,
-                        [=](const ast::StatementList& stmts) {
-                          loop->continuing =
-                              create<ast::BlockStatement>(Source{}, stmts);
-                        });
+  PushNewStatementBlock(
+      construct, construct->end_id, [=](const ast::StatementList& stmts) {
+        loop->continuing = create<ast::BlockStatement>(Source{}, stmts);
+      });
 
   return success();
 }
@@ -2570,7 +2564,7 @@
 
       AddStatement(MakeSimpleIf(cond, true_branch, false_branch));
       if (!flow_guard.empty()) {
-        PushGuard(flow_guard, statements_stack_.back().EndId());
+        PushGuard(flow_guard, statements_stack_.back().GetEndId());
       }
       return true;
     }
diff --git a/src/reader/spirv/function.h b/src/reader/spirv/function.h
index 533c7eb..c980475 100644
--- a/src/reader/spirv/function.h
+++ b/src/reader/spirv/function.h
@@ -861,8 +861,7 @@
    public:
     StatementBlock(const Construct* construct,
                    uint32_t end_id,
-                   CompletionAction completion_action,
-                   ast::CaseStatementList* cases);
+                   CompletionAction completion_action);
     StatementBlock(StatementBlock&&);
     ~StatementBlock();
 
@@ -897,40 +896,28 @@
     void SetConstruct(const Construct* construct) { construct_ = construct; }
 
     /// @return the construct to which this construct constributes
-    const Construct* Construct() const { return construct_; }
+    const Construct* GetConstruct() const { return construct_; }
 
     /// @return the ID of the block at which the completion action should be
     /// triggered and this statement block discarded. This is often the `end_id`
     /// of `construct` itself.
-    uint32_t EndId() const { return end_id_; }
-
-    /// @return the completion action finishes processing this statement block
-    CompletionAction CompletionAction() const { return completion_action_; }
+    uint32_t GetEndId() const { return end_id_; }
 
     /// @return the list of statements being built, if this construct is not a
     /// switch.
-    const ast::StatementList& Statements() const { return statements_; }
-
-    /// @return the list of switch cases being built, if this construct is a
-    /// switch
-    ast::CaseStatementList* Cases() const { return cases_; }
+    const ast::StatementList& GetStatements() const { return statements_; }
 
    private:
     /// The construct to which this construct constributes.
-    const spirv::Construct* construct_;
+    const Construct* construct_;
     /// The ID of the block at which the completion action should be triggered
     /// and this statement block discarded. This is often the `end_id` of
     /// `construct` itself.
     uint32_t const end_id_;
     /// The completion action finishes processing this statement block.
     FunctionEmitter::CompletionAction const completion_action_;
-
-    // Only one of `statements` or `cases` is active.
-
     /// The list of statements being built, if this construct is not a switch.
     ast::StatementList statements_;
-    /// The list of switch cases being built, if this construct is a switch.
-    ast::CaseStatementList* cases_ = nullptr;
 
     /// Owned statement builders
     std::vector<std::unique_ptr<StatementBuilder>> builders_;
@@ -939,11 +926,9 @@
   };
 
   /// Pushes an empty statement block onto the statements stack.
-  /// @param cases the case list to push into
   /// @param action the completion action for this block
   void PushNewStatementBlock(const Construct* construct,
                              uint32_t end_id,
-                             ast::CaseStatementList* cases,
                              CompletionAction action);
 
   /// Emits an if-statement whose condition is the given flow guard