From debfebbd7bd0f3d0095f2ab95eba3ce87c8a4beb Mon Sep 17 00:00:00 2001 From: Mikhail Kaskov Date: Tue, 6 Sep 2022 14:44:19 +0300 Subject: [PATCH] Fixed clang-tidy for compiler in ecmascript --- .../compiler/branch_elimination_ecma_test.cpp | 18 +++++++------ .../compiler/checks_elimination_ecma_test.cpp | 5 +++- tests/compiler/codegen_ecma_test.cpp | 26 ++++++++++--------- tests/compiler/ir_builder_ecma_test.cpp | 2 +- tests/compiler/lowering_ecma_test.cpp | 5 +++- tests/compiler/peepholes_ecma_test.cpp | 4 ++- tests/compiler/types_resolving_ecma_tests.cpp | 5 +++- tests/compiler/unit_ecma_test.cpp | 4 +-- tests/compiler/vn_test_ecma.cpp | 2 +- 9 files changed, 43 insertions(+), 28 deletions(-) diff --git a/tests/compiler/branch_elimination_ecma_test.cpp b/tests/compiler/branch_elimination_ecma_test.cpp index a9c36da15..1565e80cd 100644 --- a/tests/compiler/branch_elimination_ecma_test.cpp +++ b/tests/compiler/branch_elimination_ecma_test.cpp @@ -21,9 +21,10 @@ namespace panda::compiler { class IrBranchEliminationTest : public AsmTest { public: - IrBranchEliminationTest() {} + IrBranchEliminationTest() = default; }; +// NOLINTBEGIN(readability-magic-numbers) TEST_F(IrBranchEliminationTest, EliminateCompareAnyTypeVNDiffTypesTrue) { auto graph = CreateGraphDynStubWithDefaultRuntime(); @@ -94,7 +95,7 @@ TEST_F(IrBranchEliminationTest, EliminateCompareAnyTypeVNDiffTypesTrue) EXPECT_TRUE(GraphComparator().Compare(graph, graph_opt)); } -TEST_F(IrBranchEliminationTest, EliminateCompareAnyTypeVNDiffTypesFalse_1) +TEST_F(IrBranchEliminationTest, EliminateCompareAnyTypeVNDiffTypesFalse1) { auto graph = CreateGraphDynStubWithDefaultRuntime(); GRAPH(graph) @@ -142,7 +143,7 @@ TEST_F(IrBranchEliminationTest, EliminateCompareAnyTypeVNDiffTypesFalse_1) EXPECT_TRUE(GraphComparator().Compare(graph, graph_opt)); } -TEST_F(IrBranchEliminationTest, EliminateCompareAnyTypeVNDiffTypesFalse_2) +TEST_F(IrBranchEliminationTest, EliminateCompareAnyTypeVNDiffTypesFalse2) { auto graph = CreateGraphDynStubWithDefaultRuntime(); GRAPH(graph) @@ -190,7 +191,7 @@ TEST_F(IrBranchEliminationTest, EliminateCompareAnyTypeVNDiffTypesFalse_2) EXPECT_TRUE(GraphComparator().Compare(graph, graph_opt)); } -TEST_F(IrBranchEliminationTest, EliminateCompareAnyTypeVNEqTypesTrue_1) +TEST_F(IrBranchEliminationTest, EliminateCompareAnyTypeVNEqTypesTrue1) { auto graph = CreateGraphDynStubWithDefaultRuntime(); GRAPH(graph) @@ -260,7 +261,7 @@ TEST_F(IrBranchEliminationTest, EliminateCompareAnyTypeVNEqTypesTrue_1) EXPECT_TRUE(GraphComparator().Compare(graph, graph_opt)); } -TEST_F(IrBranchEliminationTest, EliminateCompareAnyTypeVNEqTypesTrue_2) +TEST_F(IrBranchEliminationTest, EliminateCompareAnyTypeVNEqTypesTrue2) { auto graph = CreateGraphDynStubWithDefaultRuntime(); GRAPH(graph) @@ -330,7 +331,7 @@ TEST_F(IrBranchEliminationTest, EliminateCompareAnyTypeVNEqTypesTrue_2) EXPECT_TRUE(GraphComparator().Compare(graph, graph_opt)); } -TEST_F(IrBranchEliminationTest, EliminateCompareAnyTypeVNEqTypesTrue_3) +TEST_F(IrBranchEliminationTest, EliminateCompareAnyTypeVNEqTypesTrue3) { auto graph = CreateGraphDynStubWithDefaultRuntime(); GRAPH(graph) @@ -399,7 +400,7 @@ TEST_F(IrBranchEliminationTest, EliminateCompareAnyTypeVNEqTypesTrue_3) EXPECT_TRUE(GraphComparator().Compare(graph, graph_opt)); } -TEST_F(IrBranchEliminationTest, EliminateCompareAnyTypeSubtype_1) +TEST_F(IrBranchEliminationTest, EliminateCompareAnyTypeSubtype1) { auto graph = CreateGraphDynStubWithDefaultRuntime(); GRAPH(graph) @@ -469,7 +470,7 @@ TEST_F(IrBranchEliminationTest, EliminateCompareAnyTypeSubtype_1) EXPECT_TRUE(GraphComparator().Compare(graph, graph_opt)); } -TEST_F(IrBranchEliminationTest, EliminateCompareAnyTypeSubtype_2) +TEST_F(IrBranchEliminationTest, EliminateCompareAnyTypeSubtype2) { auto graph = CreateGraphDynStubWithDefaultRuntime(); GRAPH(graph) @@ -516,5 +517,6 @@ TEST_F(IrBranchEliminationTest, EliminateCompareAnyTypeSubtype_2) EXPECT_TRUE(GraphComparator().Compare(graph, graph_opt)); } +// NOLINTEND(readability-magic-numbers) } // namespace panda::compiler diff --git a/tests/compiler/checks_elimination_ecma_test.cpp b/tests/compiler/checks_elimination_ecma_test.cpp index 457291111..57ab18329 100644 --- a/tests/compiler/checks_elimination_ecma_test.cpp +++ b/tests/compiler/checks_elimination_ecma_test.cpp @@ -21,9 +21,10 @@ namespace panda::compiler { class CheckEliminationEcmaTest : public AsmTest { public: - CheckEliminationEcmaTest() {} + CheckEliminationEcmaTest() = default; }; +// NOLINTBEGIN(readability-magic-numbers) TEST_F(CheckEliminationEcmaTest, EliminateAnyTypeCheckAfterCastValueToAnyType) { auto graph = CreateGraphDynWithDefaultRuntime(); @@ -396,4 +397,6 @@ TEST_F(CheckEliminationEcmaTest, EliminateAnyTypeCheckWithUndefinedType) EXPECT_TRUE(GraphComparator().Compare(graph, graph_opt)); } +// NOLINTEND(readability-magic-numbers) + } // namespace panda::compiler diff --git a/tests/compiler/codegen_ecma_test.cpp b/tests/compiler/codegen_ecma_test.cpp index 8df013bb0..edf1ced51 100644 --- a/tests/compiler/codegen_ecma_test.cpp +++ b/tests/compiler/codegen_ecma_test.cpp @@ -32,7 +32,10 @@ namespace panda::compiler { class CodegenEcmaTest : public GraphTest { public: CodegenEcmaTest() : exec_module_(GetAllocator(), GetGraph()->GetRuntime()) {} - ~CodegenEcmaTest() override {} + ~CodegenEcmaTest() override = default; + + NO_COPY_SEMANTIC(CodegenEcmaTest); + NO_MOVE_SEMANTIC(CodegenEcmaTest); void TestCompareAnyType(AnyBaseType any_type, uint64_t val, bool expected_value); void TestAnyTypeCheck(AnyBaseType any_type, uint64_t val); @@ -49,12 +52,10 @@ private: static bool RunCodegen(Graph *graph) { - if (!graph->RunPass()) { - return false; - } - return true; + return graph->RunPass(); } +// NOLINTBEGIN(readability-magic-numbers) template void CodegenEcmaTest::CheckReturnValue(Graph *graph, T expected_value) { @@ -63,7 +64,7 @@ void CodegenEcmaTest::CheckReturnValue(Graph *graph, T expected_value) ASSERT_TRUE(RunCodegen(graph)); auto code_entry = reinterpret_cast(graph->GetData().Data()); - auto code_exit = code_entry + graph->GetData().Size(); + auto code_exit = code_entry + graph->GetData().Size(); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) ASSERT(code_entry != nullptr && code_exit != nullptr); @@ -93,12 +94,12 @@ void CodegenEcmaTest::TestCompareAnyType(AnyBaseType any_type, uint64_t val, boo CheckReturnValue(graph, expected_value); } -TEST_F(CodegenEcmaTest, CompareAnyTypeInstBoolTrue_1) +TEST_F(CodegenEcmaTest, CompareAnyTypeInstBoolTrue1) { TestCompareAnyType(AnyBaseType::ECMASCRIPT_BOOLEAN_TYPE, TaggedValue::VALUE_TRUE, true); } -TEST_F(CodegenEcmaTest, CompareAnyTypeInstBoolTrue_2) +TEST_F(CodegenEcmaTest, CompareAnyTypeInstBoolTrue2) { TestCompareAnyType(AnyBaseType::ECMASCRIPT_BOOLEAN_TYPE, TaggedValue::VALUE_FALSE, true); } @@ -113,12 +114,12 @@ TEST_F(CodegenEcmaTest, CompareAnyTypeInstDoubleTrue) TestCompareAnyType(AnyBaseType::ECMASCRIPT_DOUBLE_TYPE, TaggedValue::DOUBLE_ENCODE_OFFSET, true); } -TEST_F(CodegenEcmaTest, CompareAnyTypeInstDoubleFalse_1) +TEST_F(CodegenEcmaTest, CompareAnyTypeInstDoubleFalse1) { TestCompareAnyType(AnyBaseType::ECMASCRIPT_DOUBLE_TYPE, TaggedValue::TAG_INT, false); } -TEST_F(CodegenEcmaTest, CompareAnyTypeInstDoubleFalse_2) +TEST_F(CodegenEcmaTest, CompareAnyTypeInstDoubleFalse2) { TestCompareAnyType(AnyBaseType::ECMASCRIPT_DOUBLE_TYPE, TaggedValue::TAG_OBJECT + 1, false); } @@ -344,12 +345,12 @@ void CodegenEcmaTest::TestAnyTypeCheck(AnyBaseType any_type, uint64_t val) CheckReturnValue(graph, 1); } -TEST_F(CodegenEcmaTest, AnyTypeCheckInstBoolTrue_1) +TEST_F(CodegenEcmaTest, AnyTypeCheckInstBoolTrue1) { TestAnyTypeCheck(AnyBaseType::ECMASCRIPT_BOOLEAN_TYPE, TaggedValue::VALUE_TRUE); } -TEST_F(CodegenEcmaTest, AnyTypeCheckInstBoolTrue_2) +TEST_F(CodegenEcmaTest, AnyTypeCheckInstBoolTrue2) { TestAnyTypeCheck(AnyBaseType::ECMASCRIPT_BOOLEAN_TYPE, TaggedValue::VALUE_FALSE); } @@ -389,5 +390,6 @@ TEST_F(CodegenEcmaTest, AnyTypeCheckInstCommonUndefined) TestAnyTypeCheck(AnyBaseType::UNDEFINED_TYPE, TaggedValue::VALUE_NULL); TestAnyTypeCheck(AnyBaseType::UNDEFINED_TYPE, TaggedValue::VALUE_UNDEFINED); } +// NOLINTEND(readability-magic-numbers) } // namespace panda::compiler diff --git a/tests/compiler/ir_builder_ecma_test.cpp b/tests/compiler/ir_builder_ecma_test.cpp index 8ccf7ba63..9d2e39742 100644 --- a/tests/compiler/ir_builder_ecma_test.cpp +++ b/tests/compiler/ir_builder_ecma_test.cpp @@ -19,7 +19,7 @@ namespace panda::compiler { class IrBuilderTest : public AsmTest { public: - IrBuilderTest() {} + IrBuilderTest() = default; }; TEST_F(IrBuilderTest, CompareAnyType) diff --git a/tests/compiler/lowering_ecma_test.cpp b/tests/compiler/lowering_ecma_test.cpp index 0ecea76f9..ead0edb02 100644 --- a/tests/compiler/lowering_ecma_test.cpp +++ b/tests/compiler/lowering_ecma_test.cpp @@ -22,9 +22,10 @@ namespace panda::compiler { class LoweringEcmaTest : public AsmTest { public: - LoweringEcmaTest() {} + LoweringEcmaTest() = default; }; +// NOLINTBEGIN(readability-magic-numbers) TEST_F(LoweringEcmaTest, CastValueToAnyTypeWithConst) { auto graph = CreateGraphDynWithDefaultRuntime(); @@ -100,4 +101,6 @@ TEST_F(LoweringEcmaTest, CastValueToAnyTypeWithSaveState) EXPECT_TRUE(GraphComparator().Compare(graph, graph_opt)); } +// NOLINTEND(readability-magic-numbers) + } // namespace panda::compiler diff --git a/tests/compiler/peepholes_ecma_test.cpp b/tests/compiler/peepholes_ecma_test.cpp index 956f754c6..c11ee88e8 100644 --- a/tests/compiler/peepholes_ecma_test.cpp +++ b/tests/compiler/peepholes_ecma_test.cpp @@ -22,9 +22,10 @@ namespace panda::compiler { class PeepholesTest : public AsmTest { public: - PeepholesTest() {} + PeepholesTest() = default; }; +// NOLINTBEGIN(readability-magic-numbers) TEST_F(PeepholesTest, CastTrueSimple) { auto graph = CreateGraphDynStubWithDefaultRuntime(); @@ -378,5 +379,6 @@ TEST_F(PeepholesTest, CompareCastToAnyAndConst) EXPECT_TRUE(GraphComparator().Compare(graph, graph_opt)); } +// NOLINTEND(readability-magic-numbers) } // namespace panda::compiler diff --git a/tests/compiler/types_resolving_ecma_tests.cpp b/tests/compiler/types_resolving_ecma_tests.cpp index 3d156833b..90df3e086 100644 --- a/tests/compiler/types_resolving_ecma_tests.cpp +++ b/tests/compiler/types_resolving_ecma_tests.cpp @@ -23,7 +23,7 @@ namespace panda::compiler { class TypeResolvingTest : public AsmTest { public: - TypeResolvingTest() {} + TypeResolvingTest() = default; Graph *ConstructGraphWithIntrinsic(RuntimeInterface::IntrinsicId id); Graph *ConstructGraphWithIntrinsic(AnyBaseType type, RuntimeInterface::IntrinsicId id); @@ -43,6 +43,7 @@ public: void TestLdConsts(TestArray tests); }; +// NOLINTBEGIN(readability-magic-numbers) template Graph *TypeResolvingTest::ConstructGraphWithConst(AnyBaseType any_type, T cnst) { @@ -581,4 +582,6 @@ TEST_F(TypeResolvingTest, ResolveLoopPhi) ASSERT_EQ(phi.GetType(), DataType::INT32); ASSERT_EQ(phi.GetInput(1U).GetInst(), &phi); } +// NOLINTEND(readability-magic-numbers) + } // namespace panda::compiler diff --git a/tests/compiler/unit_ecma_test.cpp b/tests/compiler/unit_ecma_test.cpp index 19d23b690..4efae8b94 100644 --- a/tests/compiler/unit_ecma_test.cpp +++ b/tests/compiler/unit_ecma_test.cpp @@ -37,7 +37,7 @@ namespace panda::compiler { void PandaRuntimeTest::Initialize([[maybe_unused]] int argc, char **argv) { ASSERT(argc > 0); - exec_path_ = argv[0]; + exec_path_ = argv[0]; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) } PandaRuntimeTest::PandaRuntimeTest() @@ -57,7 +57,7 @@ PandaRuntimeTest::PandaRuntimeTest() panda::RuntimeOptions runtime_options(exec_name); runtime_options.SetBootPandaFiles({pandastdlib_path}); runtime_options.SetLoadRuntimes({"ecmascript"}); - runtime_options.SetHeapSizeLimit(50_MB); + runtime_options.SetHeapSizeLimit(50_MB); // NOLINT(readability-magic-numbers) runtime_options.SetEnableAn(true); runtime_options.SetGcType("epsilon"); Logger::InitializeStdLogging(Logger::Level::ERROR, Logger::Component::COMPILER); diff --git a/tests/compiler/vn_test_ecma.cpp b/tests/compiler/vn_test_ecma.cpp index d6da4a7e7..2953b46e7 100644 --- a/tests/compiler/vn_test_ecma.cpp +++ b/tests/compiler/vn_test_ecma.cpp @@ -22,7 +22,7 @@ namespace panda::compiler { class VNTest : public AsmTest { public: - VNTest() {} + VNTest() = default; }; TEST_F(VNTest, CompareAnyTypeVNTrue) -- Gitee