From 4a59fd47634f51dce424364f81c05d1700f98121 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Tue, 9 Mar 2021 13:16:43 +0000 Subject: [PATCH] Fix -Wextra-semi-stmt -Wsuggest-destructor-override -Wdeprecated-copy-dtor (#4164) * Fix -Wextra-semi-stmt * Fix -Wsuggest-destructor-override * Fix -Wdeprecated-copy-dtor --- source/opt/constants.h | 2 +- source/opt/folding_rules.cpp | 4 ++-- source/opt/inline_pass.h | 2 +- source/opt/mem_pass.h | 2 +- source/opt/type_manager.cpp | 4 ++-- source/opt/types.h | 2 +- source/val/validate_decorations.cpp | 2 +- source/val/validate_logicals.cpp | 2 +- source/val/validation_state.cpp | 2 +- test/binary_parse_test.cpp | 2 +- test/binary_to_text_test.cpp | 6 +++--- test/opt/instruction_list_test.cpp | 2 +- test/test_fixture.h | 2 +- test/val/val_id_test.cpp | 2 +- test/val/val_state_test.cpp | 2 +- utils/generate_grammar_tables.py | 4 ++-- 16 files changed, 21 insertions(+), 21 deletions(-) diff --git a/source/opt/constants.h b/source/opt/constants.h index e17ae6b6..5bd0ae32 100644 --- a/source/opt/constants.h +++ b/source/opt/constants.h @@ -58,7 +58,7 @@ class ConstantManager; class Constant { public: Constant() = delete; - virtual ~Constant() {} + virtual ~Constant() = default; // Make a deep copy of this constant. virtual std::unique_ptr Copy() const = 0; diff --git a/source/opt/folding_rules.cpp b/source/opt/folding_rules.cpp index 010eec9c..1e7c424b 100644 --- a/source/opt/folding_rules.cpp +++ b/source/opt/folding_rules.cpp @@ -470,7 +470,7 @@ uint32_t PerformFloatingPointOperation(analysis::ConstantManager* const_mgr, 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 PerformIntegerOperation(analysis::ConstantManager* const_mgr, 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 abe773af..9a5429ba 100644 --- a/source/opt/inline_pass.h +++ b/source/opt/inline_pass.h @@ -37,7 +37,7 @@ class InlinePass : public Pass { 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 dcc16b65..5a77670d 100644 --- a/source/opt/mem_pass.h +++ b/source/opt/mem_pass.h @@ -38,7 +38,7 @@ namespace opt { // 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 ce9c2c14..7935ad33 100644 --- a/source/opt/type_manager.cpp +++ b/source/opt/type_manager.cpp @@ -223,7 +223,7 @@ uint32_t TypeManager::GetTypeInstruction(const Type* type) { case Type::k##kind: \ typeInst = MakeUnique(context(), SpvOpType##kind, 0, id, \ std::initializer_list{}); \ - break; + break DefineParameterlessCase(Void); DefineParameterlessCase(Bool); DefineParameterlessCase(Sampler); @@ -513,7 +513,7 @@ Type* TypeManager::RebuildType(const Type& type) { #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 d5be9be4..9ecd41a6 100644 --- a/source/opt/types.h +++ b/source/opt/types.h @@ -101,7 +101,7 @@ class Type { Type(Kind k) : kind_(k) {} - virtual ~Type() {} + virtual ~Type() = default; // Attaches a decoration directly on this type. void AddDecoration(std::vector&& d) { diff --git a/source/val/validate_decorations.cpp b/source/val/validate_decorations.cpp index ed336b47..f076b04c 100644 --- a/source/val/validate_decorations.cpp +++ b/source/val/validate_decorations.cpp @@ -1619,7 +1619,7 @@ spv_result_t CheckLocationDecoration(ValidationState_t& vstate, { \ 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 5886dbf5..bb35f558 100644 --- a/source/val/validate_logicals.cpp +++ b/source/val/validate_logicals.cpp @@ -188,7 +188,7 @@ spv_result_t LogicalsPass(ValidationState_t& _, const Instruction* inst) { 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 6dfc7bf6..f0ac0327 100644 --- a/source/val/validation_state.cpp +++ b/source/val/validation_state.cpp @@ -1736,7 +1736,7 @@ std::string ValidationState_t::VkErrorID(uint32_t id, 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 93e87bdd..9a13f22c 100644 --- a/test/binary_parse_test.cpp +++ b/test/binary_parse_test.cpp @@ -198,7 +198,7 @@ ParsedInstruction MakeParsedInt32TypeInstruction(uint32_t result_id) { 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 e8a02fd5..9cad9661 100644 --- a/test/binary_to_text_test.cpp +++ b/test/binary_to_text_test.cpp @@ -36,12 +36,12 @@ class BinaryToText : public ::testing::Test { 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 @@ class BinaryToText : public ::testing::Test { 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 e745790a..2c3c2429 100644 --- a/test/opt/instruction_list_test.cpp +++ b/test/opt/instruction_list_test.cpp @@ -35,7 +35,7 @@ class TestInstruction : public Instruction { public: TestInstruction() : Instruction() { created_instructions_.push_back(this); } - ~TestInstruction() { deleted_instructions_.push_back(this); } + ~TestInstruction() override{ deleted_instructions_.push_back(this); } static std::vector created_instructions_; static std::vector deleted_instructions_; diff --git a/test/test_fixture.h b/test/test_fixture.h index 436993e2..0c5bfc9c 100644 --- a/test/test_fixture.h +++ b/test/test_fixture.h @@ -46,7 +46,7 @@ class TextToBinaryTestBase : public T { 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 c65d1715..25c9e546 100644 --- a/test/val/val_id_test.cpp +++ b/test/val/val_id_test.cpp @@ -835,7 +835,7 @@ class OpTypeArrayLengthTest 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 b2d26045..65cb1c3a 100644 --- a/test/val/val_state_test.cpp +++ b/test/val/val_state_test.cpp @@ -43,7 +43,7 @@ class ValidationStateTest : public testing::Test { 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 2a677336..c4ed180a 100755 --- a/utils/generate_grammar_tables.py +++ b/utils/generate_grammar_tables.py @@ -601,7 +601,7 @@ def generate_extension_to_string_mapping(extensions): ' 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 @@ def generate_capability_to_string_mapping(operand_kinds): 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