From 2828147c9f4dd54fa72bef1386ca06979175dc5b Mon Sep 17 00:00:00 2001 From: mozgovoykirill Date: Wed, 13 Aug 2025 14:55:55 +0300 Subject: [PATCH] Clang-tidy-check-full fix Issue: #ICSTXN Testing:'ninja all tests' Signed-off-by: mozgovoykirill --- ets2panda/declgen_ets2ts/declgenEts2Ts.cpp | 8 +++++--- ets2panda/test/unit/plugin/util.cpp | 14 ++++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp b/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp index e685df218f..f535969be1 100644 --- a/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp +++ b/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp @@ -383,7 +383,8 @@ void TSDeclGen::GenDeclarations() const auto jsdoc = compiler::JsdocStringFromDeclaration(globalStatement); if (jsdoc.Utf8().find(NON_INTEROP_FLAG) != std::string_view::npos) { continue; - } else if (globalStatement->IsClassDeclaration()) { + } + if (globalStatement->IsClassDeclaration()) { GenClassDeclaration(globalStatement->AsClassDeclaration()); } else if (globalStatement->IsTSInterfaceDeclaration()) { GenInterfaceDeclaration(globalStatement->AsTSInterfaceDeclaration()); @@ -2126,7 +2127,8 @@ void TSDeclGen::ProcessClassBody(const ir::ClassDefinition *classDef) const auto jsdoc = compiler::JsdocStringFromDeclaration(prop); if (jsdoc.Utf8().find(NON_INTEROP_FLAG) != std::string_view::npos) { continue; - } else if (classDef->IsEnumTransformed()) { + } + if (classDef->IsEnumTransformed()) { if (prop->IsClassProperty()) { state_.inEnum = true; GenPropDeclaration(prop->AsClassProperty()); @@ -2279,7 +2281,7 @@ void TSDeclGen::GenMethodDeclaration(const ir::MethodDefinition *methodDef) } const auto methodIdent = GetKeyIdent(methodDef->Key()); auto methodName = methodIdent->Name().Mutf8(); - if (methodName.compare("$_iterator") == 0) { + if (methodName == "$_iterator") { methodName = "[Symbol.iterator]"; } if (GenMethodDeclarationPrefix(methodDef, methodIdent, methodName)) { diff --git a/ets2panda/test/unit/plugin/util.cpp b/ets2panda/test/unit/plugin/util.cpp index e5709c5b75..028176b94a 100644 --- a/ets2panda/test/unit/plugin/util.cpp +++ b/ets2panda/test/unit/plugin/util.cpp @@ -78,9 +78,8 @@ void AppendStatementToProgram(es2panda_Context *context, es2panda_AstNode *progr auto *statements = impl->BlockStatementStatements(context, program, &sizeOfStatements); auto **newStatements = static_cast(impl->AllocMemory(context, sizeOfStatements + 1, sizeof(es2panda_AstNode *))); - for (size_t i = 0; i < sizeOfStatements; i++) { - newStatements[i] = statements[i]; - } + std::copy_n(statements, sizeOfStatements, newStatements); + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) newStatements[sizeOfStatements] = newStatement; impl->BlockStatementSetStatements(context, program, newStatements, sizeOfStatements + 1); impl->AstNodeSetParent(context, newStatement, program); @@ -93,9 +92,9 @@ void PrependStatementToProgram(es2panda_Context *context, es2panda_AstNode *prog auto *statements = impl->BlockStatementStatements(context, program, &sizeOfStatements); auto **newStatements = static_cast(impl->AllocMemory(context, sizeOfStatements + 1, sizeof(es2panda_AstNode *))); - for (size_t i = 0; i < sizeOfStatements; i++) { - newStatements[i + 1] = statements[i]; - } + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + std::copy_n(statements, sizeOfStatements, &newStatements[1]); + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) newStatements[0] = newStatement; impl->BlockStatementSetStatements(context, program, newStatements, sizeOfStatements + 1); impl->AstNodeSetParent(context, newStatement, program); @@ -155,12 +154,15 @@ int RunAllStagesWithTestFunction(ProccedToStatePluginTestData &data) } *data.impl = GetImpl(); std::cout << "LOAD SUCCESS" << std::endl; + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) const char **args = const_cast(&(data.argv[1])); auto config = g_implPtr->CreateConfig(data.argc - 1, args); es2panda_Context *context = nullptr; if (data.fromSource) { + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) context = g_implPtr->CreateContextFromString(config, data.source.data(), data.argv[data.argc - 1]); } else { + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) context = g_implPtr->CreateContextFromFile(config, data.argv[data.argc - 1]); } if (context == nullptr) { -- Gitee