diff --git a/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp b/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp index e685df218f6891aecc7572668937e0e09e754313..f535969be16ce029dee9d74af37ea5b6698a7b32 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 e5709c5b75bff83da4e8214af53f6a76d584c81b..028176b94a3777004bc975c27c313d838d8de749 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) {