Fix -Wextra-semi-stmt -Wsuggest-destructor-override -Wdeprecated-copy-dtor (#4164)

* Fix -Wextra-semi-stmt
* Fix -Wsuggest-destructor-override
* Fix -Wdeprecated-copy-dtor
diff --git a/source/opt/constants.h b/source/opt/constants.h
index e17ae6b..5bd0ae3 100644
--- a/source/opt/constants.h
+++ b/source/opt/constants.h
@@ -58,7 +58,7 @@
 class Constant {
  public:
   Constant() = delete;
-  virtual ~Constant() {}
+  virtual ~Constant() = default;
 
   // Make a deep copy of this constant.
   virtual std::unique_ptr<Constant> Copy() const = 0;
diff --git a/source/opt/folding_rules.cpp b/source/opt/folding_rules.cpp
index 010eec9..1e7c424 100644
--- a/source/opt/folding_rules.cpp
+++ b/source/opt/folding_rules.cpp
@@ -470,7 +470,7 @@
     float fval = val.getAsFloat();                                           \
     if (!IsValidResult(fval)) return 0;                                      \
     words = val.GetWords();                                                  \
-  }
+  } static_assert(true, "require extra semicolon")
   switch (opcode) {
     case SpvOpFMul:
       FOLD_OP(*);
@@ -522,7 +522,7 @@
       uint32_t val = input1->GetU32() op input2->GetU32(); \
       words.push_back(val);                                \
     }                                                      \
-  }
+  } static_assert(true, "require extra semicalon")
   switch (opcode) {
     case SpvOpIMul:
       FOLD_OP(*);
diff --git a/source/opt/inline_pass.h b/source/opt/inline_pass.h
index abe773a..9a5429b 100644
--- a/source/opt/inline_pass.h
+++ b/source/opt/inline_pass.h
@@ -37,7 +37,7 @@
   using cbb_ptr = const BasicBlock*;
 
  public:
-  virtual ~InlinePass() = default;
+  virtual ~InlinePass() override = default;
 
  protected:
   InlinePass();
diff --git a/source/opt/mem_pass.h b/source/opt/mem_pass.h
index dcc16b6..5a77670 100644
--- a/source/opt/mem_pass.h
+++ b/source/opt/mem_pass.h
@@ -38,7 +38,7 @@
 // utility functions and supporting state.
 class MemPass : public Pass {
  public:
-  virtual ~MemPass() = default;
+  virtual ~MemPass() override = default;
 
   // Returns an undef value for the given |var_id|'s type.
   uint32_t GetUndefVal(uint32_t var_id) {
diff --git a/source/opt/type_manager.cpp b/source/opt/type_manager.cpp
index ce9c2c1..7935ad3 100644
--- a/source/opt/type_manager.cpp
+++ b/source/opt/type_manager.cpp
@@ -223,7 +223,7 @@
   case Type::k##kind:                                                     \
     typeInst = MakeUnique<Instruction>(context(), SpvOpType##kind, 0, id, \
                                        std::initializer_list<Operand>{}); \
-    break;
+    break
     DefineParameterlessCase(Void);
     DefineParameterlessCase(Bool);
     DefineParameterlessCase(Sampler);
@@ -513,7 +513,7 @@
 #define DefineNoSubtypeCase(kind)             \
   case Type::k##kind:                         \
     rebuilt_ty.reset(type.Clone().release()); \
-    return type_pool_.insert(std::move(rebuilt_ty)).first->get();
+    return type_pool_.insert(std::move(rebuilt_ty)).first->get()
 
     DefineNoSubtypeCase(Void);
     DefineNoSubtypeCase(Bool);
diff --git a/source/opt/types.h b/source/opt/types.h
index d5be9be..9ecd41a 100644
--- a/source/opt/types.h
+++ b/source/opt/types.h
@@ -101,7 +101,7 @@
 
   Type(Kind k) : kind_(k) {}
 
-  virtual ~Type() {}
+  virtual ~Type() = default;
 
   // Attaches a decoration directly on this type.
   void AddDecoration(std::vector<uint32_t>&& d) {
diff --git a/source/val/validate_decorations.cpp b/source/val/validate_decorations.cpp
index ed336b4..f076b04 100644
--- a/source/val/validate_decorations.cpp
+++ b/source/val/validate_decorations.cpp
@@ -1619,7 +1619,7 @@
   {                                             \
     spv_result_t e##LINE = (X);                 \
     if (e##LINE != SPV_SUCCESS) return e##LINE; \
-  }
+  } static_assert(true, "require extra semicolon")
 #define PASS_OR_BAIL(X) PASS_OR_BAIL_AT_LINE(X, __LINE__)
 
 // Check rules for decorations where we start from the decoration rather
diff --git a/source/val/validate_logicals.cpp b/source/val/validate_logicals.cpp
index 5886dbf..bb35f55 100644
--- a/source/val/validate_logicals.cpp
+++ b/source/val/validate_logicals.cpp
@@ -188,7 +188,7 @@
           case SpvOpTypeStruct: {
             if (!composites) return fail();
             break;
-          };
+          }
 
           default:
             return fail();
diff --git a/source/val/validation_state.cpp b/source/val/validation_state.cpp
index 6dfc7bf..f0ac032 100644
--- a/source/val/validation_state.cpp
+++ b/source/val/validation_state.cpp
@@ -1736,7 +1736,7 @@
       return VUID_WRAP(VUID-StandaloneSpirv-OpMemoryBarrier-04733);
     default:
       return "";  // unknown id
-  };
+  }
   // clang-format on
 }
 
diff --git a/test/binary_parse_test.cpp b/test/binary_parse_test.cpp
index 93e87bd..9a13f22 100644
--- a/test/binary_parse_test.cpp
+++ b/test/binary_parse_test.cpp
@@ -198,7 +198,7 @@
 
 class BinaryParseTest : public spvtest::TextToBinaryTestBase<::testing::Test> {
  protected:
-  ~BinaryParseTest() { spvDiagnosticDestroy(diagnostic_); }
+  ~BinaryParseTest() override { spvDiagnosticDestroy(diagnostic_); }
 
   void Parse(const SpirvVector& words, spv_result_t expected_result,
              bool flip_words = false) {
diff --git a/test/binary_to_text_test.cpp b/test/binary_to_text_test.cpp
index e8a02fd..9cad966 100644
--- a/test/binary_to_text_test.cpp
+++ b/test/binary_to_text_test.cpp
@@ -36,12 +36,12 @@
  public:
   BinaryToText()
       : context(spvContextCreate(SPV_ENV_UNIVERSAL_1_0)), binary(nullptr) {}
-  ~BinaryToText() {
+  ~BinaryToText() override {
     spvBinaryDestroy(binary);
     spvContextDestroy(context);
   }
 
-  virtual void SetUp() {
+  void SetUp() override {
     const char* textStr = R"(
       OpSource OpenCL_C 12
       OpMemoryModel Physical64 OpenCL
@@ -72,7 +72,7 @@
     ASSERT_EQ(SPV_SUCCESS, error);
   }
 
-  virtual void TearDown() {
+  void TearDown() override {
     spvBinaryDestroy(binary);
     binary = nullptr;
   }
diff --git a/test/opt/instruction_list_test.cpp b/test/opt/instruction_list_test.cpp
index e745790..2c3c242 100644
--- a/test/opt/instruction_list_test.cpp
+++ b/test/opt/instruction_list_test.cpp
@@ -35,7 +35,7 @@
  public:
   TestInstruction() : Instruction() { created_instructions_.push_back(this); }
 
-  ~TestInstruction() { deleted_instructions_.push_back(this); }
+  ~TestInstruction() override{ deleted_instructions_.push_back(this); }
 
   static std::vector<TestInstruction*> created_instructions_;
   static std::vector<TestInstruction*> deleted_instructions_;
diff --git a/test/test_fixture.h b/test/test_fixture.h
index 436993e..0c5bfc9 100644
--- a/test/test_fixture.h
+++ b/test/test_fixture.h
@@ -46,7 +46,7 @@
     text = {textStr, strlen(textStr)};
   }
 
-  virtual ~TextToBinaryTestBase() {
+  ~TextToBinaryTestBase() override {
     DestroyBinary();
     if (diagnostic) spvDiagnosticDestroy(diagnostic);
   }
diff --git a/test/val/val_id_test.cpp b/test/val/val_id_test.cpp
index c65d171..25c9e54 100644
--- a/test/val/val_id_test.cpp
+++ b/test/val/val_id_test.cpp
@@ -835,7 +835,7 @@
         position_(spv_position_t{0, 0, 0}),
         diagnostic_(spvDiagnosticCreate(&position_, "")) {}
 
-  ~OpTypeArrayLengthTest() { spvDiagnosticDestroy(diagnostic_); }
+  ~OpTypeArrayLengthTest() override { spvDiagnosticDestroy(diagnostic_); }
 
   // Runs spvValidate() on v, printing any errors via spvDiagnosticPrint().
   spv_result_t Val(const SpirvVector& v, const std::string& expected_err = "") {
diff --git a/test/val/val_state_test.cpp b/test/val/val_state_test.cpp
index b2d2604..65cb1c3 100644
--- a/test/val/val_state_test.cpp
+++ b/test/val/val_state_test.cpp
@@ -43,7 +43,7 @@
         options_(spvValidatorOptionsCreate()),
         state_(context_, options_, kFakeBinary, 0, 1) {}
 
-  ~ValidationStateTest() {
+  ~ValidationStateTest() override {
     spvContextDestroy(context_);
     spvValidatorOptionsDestroy(options_);
   }
diff --git a/utils/generate_grammar_tables.py b/utils/generate_grammar_tables.py
index 2a67733..c4ed180 100755
--- a/utils/generate_grammar_tables.py
+++ b/utils/generate_grammar_tables.py
@@ -601,7 +601,7 @@
         '      return "{extension}";\n'
     function += ''.join([template.format(extension=extension)
                          for extension in extensions])
-    function += '  };\n\n  return "";\n}'
+    function += '  }\n\n  return "";\n}'
     return function
 
 
@@ -647,7 +647,7 @@
     function += '    case SpvCapabilityMax:\n' \
         '      assert(0 && "Attempting to convert SpvCapabilityMax to string");\n' \
         '      return "";\n'
-    function += '  };\n\n  return "";\n}'
+    function += '  }\n\n  return "";\n}'
     return function