From df6d9efc448f0518bbaf621b74594c95b5f20dbe Mon Sep 17 00:00:00 2001 From: aakmaev Date: Tue, 22 Apr 2025 15:11:57 +0300 Subject: [PATCH] Fix clang format and remove workaround Signed-off-by: Akmaev Aleksey --- ets2panda/checker/types/ets/etsResizableArrayType.h | 1 - ets2panda/checker/types/signature.cpp | 4 +--- .../lowering/ets/constantExpressionLowering.cpp | 1 - ets2panda/compiler/lowering/ets/restArgsLowering.cpp | 9 +++++---- ets2panda/compiler/lowering/ets/spreadLowering.cpp | 6 +++--- .../ets/topLevelStmts/globalClassHandler.cpp | 9 +++------ .../lowering/ets/topLevelStmts/globalClassHandler.h | 12 +++++++----- 7 files changed, 19 insertions(+), 23 deletions(-) diff --git a/ets2panda/checker/types/ets/etsResizableArrayType.h b/ets2panda/checker/types/ets/etsResizableArrayType.h index 4f685b51cf..8b041760eb 100644 --- a/ets2panda/checker/types/ets/etsResizableArrayType.h +++ b/ets2panda/checker/types/ets/etsResizableArrayType.h @@ -76,7 +76,6 @@ public: ETSResizableArrayType *Substitute(TypeRelation *relation, const Substitution *substitution) override; - void ToString(std::stringstream &ss, [[maybe_unused]] bool precise) const override; private: diff --git a/ets2panda/checker/types/signature.cpp b/ets2panda/checker/types/signature.cpp index 0983219efb..34b2d8a74e 100644 --- a/ets2panda/checker/types/signature.cpp +++ b/ets2panda/checker/types/signature.cpp @@ -217,9 +217,7 @@ static bool MethodSignaturesAreCompatible(TypeRelation *relation, bool checkIden } auto const areCompatible = [relation, checkIdentical](Type *superT, Type *subT) { - return checkIdentical - ? superT->IsETSTypeParameter() || subT->IsETSTypeParameter() || relation->IsIdenticalTo(superT, subT) - : relation->IsSupertypeOf(superT, subT); + return checkIdentical ? relation->IsIdenticalTo(superT, subT) : relation->IsSupertypeOf(superT, subT); }; if (!relation->NoReturnTypeCheck() && !areCompatible(super->ReturnType(), sub->ReturnType())) { return false; diff --git a/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp b/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp index 3d00d014f3..ab0e05cae9 100644 --- a/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp +++ b/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp @@ -1405,7 +1405,6 @@ ir::AstNode *ConstantExpressionLowering::MaybeUnfoldMemberExpression(ir::MemberE ir::AstNode *ConstantExpressionLowering::MaybeUnfold(ir::AstNode *node) { ir::NodeTransformer handleMaybeUnfold = [this](ir::AstNode *const n) { - if (n->IsIdentifier()) { return MaybeUnfoldIdentifier(n->AsIdentifier()); } diff --git a/ets2panda/compiler/lowering/ets/restArgsLowering.cpp b/ets2panda/compiler/lowering/ets/restArgsLowering.cpp index cf74d5d53a..b8b421ea10 100644 --- a/ets2panda/compiler/lowering/ets/restArgsLowering.cpp +++ b/ets2panda/compiler/lowering/ets/restArgsLowering.cpp @@ -119,10 +119,11 @@ static ir::Expression *CreateRestArgsArray(public_lib::Context *context, ArenaVe ss << "for (let i = 0; i < @@I8.length; ++i) { @@I9[i] = @@I10[i]}"; ss << "@@I11;"; auto *arrayExpr = checker->AllocNode(std::move(copiedArguments), allocator); - auto *loweringResult = - parser->CreateFormattedExpression(ss.str(), genSymIdent, type->Clone(allocator, nullptr), arrayExpr, genSymIdent2, - type, type->Clone(allocator, nullptr), genSymIdent->Clone(allocator, nullptr), genSymIdent->Clone(allocator, nullptr), - genSymIdent2->Clone(allocator, nullptr), genSymIdent->Clone(allocator, nullptr), genSymIdent2->Clone(allocator, nullptr)); + auto *loweringResult = parser->CreateFormattedExpression( + ss.str(), genSymIdent, type->Clone(allocator, nullptr), arrayExpr, genSymIdent2, type, + type->Clone(allocator, nullptr), genSymIdent->Clone(allocator, nullptr), genSymIdent->Clone(allocator, nullptr), + genSymIdent2->Clone(allocator, nullptr), genSymIdent->Clone(allocator, nullptr), + genSymIdent2->Clone(allocator, nullptr)); return loweringResult; } diff --git a/ets2panda/compiler/lowering/ets/spreadLowering.cpp b/ets2panda/compiler/lowering/ets/spreadLowering.cpp index 7eb4d5283a..31bd8b08a9 100644 --- a/ets2panda/compiler/lowering/ets/spreadLowering.cpp +++ b/ets2panda/compiler/lowering/ets/spreadLowering.cpp @@ -108,9 +108,9 @@ static ir::Identifier *CreateNewArrayDeclareStatement(public_lib::Context *ctx, newArrayDeclareStr << "let @@I1: FixedArray<@@T2> = new (@@T3)[@@I4];" << std::endl; } - ir::Statement *newArrayDeclareSt = - parser->CreateFormattedStatement(newArrayDeclareStr.str(), newArrayId->Clone(allocator, nullptr), arrayElementType, - arrayElementType, newArrayLengthId->Clone(allocator, nullptr)); + ir::Statement *newArrayDeclareSt = parser->CreateFormattedStatement( + newArrayDeclareStr.str(), newArrayId->Clone(allocator, nullptr), arrayElementType, arrayElementType, + newArrayLengthId->Clone(allocator, nullptr)); statements.emplace_back(newArrayDeclareSt); return newArrayId; diff --git a/ets2panda/compiler/lowering/ets/topLevelStmts/globalClassHandler.cpp b/ets2panda/compiler/lowering/ets/topLevelStmts/globalClassHandler.cpp index 9d21718251..4135e26bac 100644 --- a/ets2panda/compiler/lowering/ets/topLevelStmts/globalClassHandler.cpp +++ b/ets2panda/compiler/lowering/ets/topLevelStmts/globalClassHandler.cpp @@ -141,8 +141,7 @@ void GlobalClassHandler::SetupGlobalMethods(ArenaVector &&initS return; } - ir::MethodDefinition *initMethod = - CreateGlobalMethod(compiler::Signatures::INIT_METHOD, std::move(initStatements)); + ir::MethodDefinition *initMethod = CreateGlobalMethod(compiler::Signatures::INIT_METHOD, std::move(initStatements)); InsertInGlobal(globalClass, initMethod); if (!initMethod->Function()->Body()->AsBlockStatement()->Statements().empty()) { AddInitCallToStaticBlock(globalClass, initMethod); @@ -223,8 +222,7 @@ ir::ClassDeclaration *GlobalClassHandler::TransformNamespace(ir::ETSModule *ns) const ModuleDependencies md {allocator_->Adapter()}; auto immediateInitStatements = FormInitMethodStatements(&md, std::move(immediateInitializers)); auto initializerBlockStatements = FormInitMethodStatements(&md, std::move(initializerBlock)); - SetupGlobalMethods(std::move(immediateInitStatements), globalClass, - ns->IsDeclare()); + SetupGlobalMethods(std::move(immediateInitStatements), globalClass, ns->IsDeclare()); // remove namespaceDecl from orginal node auto end = std::remove_if(body.begin(), body.end(), [&namespaces](ir::AstNode *node) { @@ -318,8 +316,7 @@ void GlobalClassHandler::SetupGlobalClass(const ArenaVector & CollectProgramGlobalClasses(namespaces); TransformBrokenNamespace(); - auto initializerBlockStmts = - FormInitStaticBlockMethodStatements(moduleDependencies, std::move(initializerBlock)); + auto initializerBlockStmts = FormInitStaticBlockMethodStatements(moduleDependencies, std::move(initializerBlock)); CollectExportedClasses(globalClass, globalProgram_->Ast()->Statements()); diff --git a/ets2panda/compiler/lowering/ets/topLevelStmts/globalClassHandler.h b/ets2panda/compiler/lowering/ets/topLevelStmts/globalClassHandler.h index 8dac90e886..1d65297dec 100644 --- a/ets2panda/compiler/lowering/ets/topLevelStmts/globalClassHandler.h +++ b/ets2panda/compiler/lowering/ets/topLevelStmts/globalClassHandler.h @@ -32,7 +32,10 @@ public: ArenaVector statements; }; explicit GlobalClassHandler(parser::ETSParser *parser, ArenaAllocator *allocator, parser::Program *program) - : parser_(parser), allocator_(allocator), globalProgram_(program), packageInitializerBlockCount_(allocator->Adapter()) {}; + : parser_(parser), + allocator_(allocator), + globalProgram_(program), + packageInitializerBlockCount_(allocator->Adapter()) {}; static void MergeNamespace(ArenaVector &namespaces, parser::Program *program); @@ -64,8 +67,8 @@ private: template void CollectExportedClasses(ir::ClassDefinition *classDef, const ArenaVector &statements); void CollectNamespaceExportedClasses(ir::ClassDefinition *classDef); - void SetupGlobalMethods(ArenaVector &&initStatements, - ir::ClassDefinition *globalClass, bool isDeclare); + void SetupGlobalMethods(ArenaVector &&initStatements, ir::ClassDefinition *globalClass, + bool isDeclare); void SetupInitializerBlock(ArenaVector> &&initializerBlock, ir::ClassDefinition *globalClass); ArenaVector TransformNamespaces(ArenaVector &namespaces); @@ -78,8 +81,7 @@ private: ArenaVector &&initializerBlocks); ArenaVector> FormInitStaticBlockMethodStatements( - const ModuleDependencies *moduleDependencies, - ArenaVector &&initStatements); + const ModuleDependencies *moduleDependencies, ArenaVector &&initStatements); void TransformBrokenNamespace(); ArenaVector FormInitMethodStatements(const ModuleDependencies *moduleDependencies, -- Gitee