From 25f97a87088004f6ac4fb3a77b9a28bb53bb20af Mon Sep 17 00:00:00 2001 From: Redkin Mikhail Date: Wed, 24 Jan 2024 17:33:53 +0300 Subject: [PATCH 1/2] Fix linters Signed-off-by: Redkin Mikhail --- ets2panda/checker/ets/dynamic.cpp | 51 ++++++++++++- ets2panda/checker/ets/enum.cpp | 99 ++++++++++++++++++++------ ets2panda/checker/ets/function.cpp | 97 ++++++++++++++++++++++--- ets2panda/checker/ets/helpers.cpp | 16 ++++- ets2panda/checker/ets/typeCreation.cpp | 14 ++++ 5 files changed, 243 insertions(+), 34 deletions(-) diff --git a/ets2panda/checker/ets/dynamic.cpp b/ets2panda/checker/ets/dynamic.cpp index c0037fea91..5000097a39 100644 --- a/ets2panda/checker/ets/dynamic.cpp +++ b/ets2panda/checker/ets/dynamic.cpp @@ -50,7 +50,9 @@ ir::ETSParameterExpression *ETSChecker::AddParam(varbinder::FunctionParamScope * checker::Type *type) { auto paramCtx = varbinder::LexicalScope::Enter(VarBinder(), paramScope, false); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *paramIdent = AllocNode(name, Allocator()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *param = AllocNode(paramIdent, nullptr); auto *paramVar = std::get<1>(VarBinder()->AddParamDecl(param)); paramVar->SetTsType(type); @@ -85,6 +87,7 @@ template ir::ScriptFunction *ETSChecker::CreateDynamicCallIntrinsic(ir::Expression *callee, const ArenaVector &arguments, Language lang) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *name = AllocNode("invoke", Allocator()); auto *paramScope = Allocator()->New(Allocator(), nullptr); auto *scope = Allocator()->New(Allocator(), paramScope); @@ -102,8 +105,10 @@ ir::ScriptFunction *ETSChecker::CreateDynamicCallIntrinsic(ir::Expression *calle ir::ETSParameterExpression *param2; if (!IsByValueCall(VarBinder()->AsETSBinder(), callee)) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) param2 = AddParam(paramScope, "qname", GlobalETSStringLiteralType()); } else { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) param2 = AddParam(paramScope, "this", dynamicType); } @@ -119,6 +124,7 @@ ir::ScriptFunction *ETSChecker::CreateDynamicCallIntrinsic(ir::Expression *calle info->params.push_back(param->Ident()->Variable()->AsLocalVariable()); } + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *func = AllocNode(ir::FunctionSignature(nullptr, std::move(params), nullptr), nullptr, ir::ScriptFunctionFlags::METHOD, ir::ModifierFlags::NONE, false, Language(Language::Id::ETS)); @@ -220,10 +226,12 @@ std::conditional_t ET if constexpr (IS_STATIC) { builder(scope, &statements, nullptr); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *body = AllocNode(Allocator(), std::move(statements)); body->SetScope(scope); id = AllocNode(compiler::Signatures::CCTOR, Allocator()); func = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) AllocNode(ir::FunctionSignature(nullptr, std::move(params), nullptr), body, ir::ScriptFunctionFlags::STATIC_BLOCK | ir::ScriptFunctionFlags::EXPRESSION, ir::ModifierFlags::STATIC, false, Language(Language::Id::ETS)); @@ -333,6 +341,7 @@ void ETSChecker::BuildClass(util::StringView name, const ClassBuilder &builder) Allocator(), classDef->Ident()->Name(), classDef->Ident()->Name(), classDef, checker::ETSObjectFlags::CLASS); classDef->SetTsType(classDefType); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *classDecl = AllocNode(classDef, Allocator()); classDecl->SetParent(VarBinder()->TopScope()->Node()); classDef->Scope()->BindNode(classDecl); @@ -362,6 +371,7 @@ void ETSChecker::BuildDynamicCallClass(bool isConstruct) auto &intrinsics = entry.second; auto className = isConstruct ? compiler::Signatures::Dynamic::NewClass(lang) : compiler::Signatures::Dynamic::CallClass(lang); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) BuildClass(className, [this, lang, &intrinsics, isConstruct](varbinder::ClassScope *scope, ArenaVector *classBody) { for (auto &[_, func] : intrinsics) { @@ -382,6 +392,7 @@ void ETSChecker::BuildDynamicCallClass(bool isConstruct) classBody->push_back(method); } + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) classBody->push_back(CreateDynamicCallClassInitializer(scope, lang, isConstruct)); }); } @@ -397,23 +408,31 @@ ir::ClassStaticBlock *ETSChecker::CreateDynamicModuleClassInitializer( auto builtin = compiler::Signatures::Dynamic::LoadModuleBuiltin(import->Language()); auto [builtin_class_name, builtin_method_name] = util::Helpers::SplitSignature(builtin); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *classId = AllocNode(builtin_class_name, Allocator()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *methodId = AllocNode(builtin_method_name, Allocator()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *callee = AllocNode(classId, methodId, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); ArenaVector callParams(Allocator()->Adapter()); callParams.push_back(import->ResolvedSource()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *loadCall = AllocNode(callee, std::move(callParams), nullptr, false); auto *moduleClassId = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) AllocNode(compiler::Signatures::DYNAMIC_MODULE_CLASS, Allocator()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *fieldId = AllocNode(import->AssemblerName(), Allocator()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *property = AllocNode( moduleClassId, fieldId, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); auto *initializer = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) AllocNode(property, loadCall, lexer::TokenType::PUNCTUATOR_SUBSTITUTION); { @@ -421,6 +440,7 @@ ir::ClassStaticBlock *ETSChecker::CreateDynamicModuleClassInitializer( initializer->Check(this); } + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) statements->push_back(AllocNode(initializer)); } }); @@ -436,6 +456,7 @@ ir::MethodDefinition *ETSChecker::CreateClassMethod(varbinder::ClassScope *class ArenaVector params(Allocator()->Adapter()); auto *paramScope = Allocator()->New(Allocator(), classScope); auto *scope = Allocator()->New(Allocator(), paramScope); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *id = AllocNode(methodName, Allocator()); ArenaVector statements(Allocator()->Adapter()); @@ -443,9 +464,11 @@ ir::MethodDefinition *ETSChecker::CreateClassMethod(varbinder::ClassScope *class builder(scope, &statements, ¶ms, &returnType); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *body = AllocNode(Allocator(), std::move(statements)); body->SetScope(scope); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *func = AllocNode(ir::FunctionSignature(nullptr, std::move(params), nullptr), body, ir::ScriptFunctionFlags::METHOD, modifierFlags, false, Language(Language::Id::ETS)); @@ -464,7 +487,9 @@ ir::MethodDefinition *ETSChecker::CreateClassMethod(varbinder::ClassScope *class } func->SetSignature(signature); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *funcExpr = AllocNode(func); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *method = AllocNode(ir::MethodDefinitionKind::METHOD, func->Id(), funcExpr, modifierFlags, Allocator(), false); @@ -528,9 +553,12 @@ ir::MethodDefinition *ETSChecker::CreateLambdaObjectClassInvokeMethod(varbinder: ++idx; } + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *properyId = AllocNode("jsvalue_lambda", Allocator()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *callee = AllocNode(thisParam, properyId, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *callLambda = AllocNode(callee, std::move(callParams), nullptr, false); { @@ -558,19 +586,23 @@ void ETSChecker::EmitDynamicModuleClassInitCall() auto *staticBlock = (*it)->AsClassStaticBlock(); auto *cctorBody = staticBlock->Function()->Body()->AsBlockStatement(); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *classId = AllocNode(compiler::Signatures::DYNAMIC_MODULE_CLASS, Allocator()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *methodId = AllocNode(compiler::Signatures::DYNAMIC_MODULE_CLASS_INIT, Allocator()); auto *callee = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) AllocNode(classId, methodId, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); ArenaVector callParams(Allocator()->Adapter()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *initCall = AllocNode(callee, std::move(callParams), nullptr, false); { ScopeContext ctx(this, cctorBody->Scope()); initCall->Check(this); } - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) cctorBody->Statements().push_back(AllocNode(initCall)); } @@ -604,7 +636,9 @@ void ETSChecker::BuildDynamicImportClass() fields.insert(import->AssemblerName()); imports.push_back(import); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *fieldIdent = AllocNode(import->AssemblerName(), Allocator()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *field = AllocNode(fieldIdent, nullptr, nullptr, ir::ModifierFlags::STATIC | ir::ModifierFlags::PUBLIC, Allocator(), false); @@ -623,11 +657,13 @@ void ETSChecker::BuildDynamicImportClass() classBody->push_back(field); } + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) classBody->push_back(CreateDynamicModuleClassInitializer(scope, imports)); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) classBody->push_back(CreateDynamicModuleClassInitMethod(scope)); }); // clang-format on - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) EmitDynamicModuleClassInitCall(); } @@ -649,17 +685,22 @@ ir::MethodDefinition *ETSChecker::CreateLambdaObjectClassInitializer(varbinder:: AddParam(scope->Parent()->AsFunctionParamScope(), jsvalueParamName.View(), GlobalBuiltinJSValueType()); params->push_back(jsvalueParam); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *moduleClassId = AllocNode("this", Allocator()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *fieldId = AllocNode("jsvalue_lambda", Allocator()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *property = AllocNode(moduleClassId, fieldId, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); auto *initializer = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) AllocNode(property, jsvalueParam, lexer::TokenType::PUNCTUATOR_SUBSTITUTION); { ScopeContext ctx(this, scope); initializer->Check(this); } + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) statements->push_back(AllocNode(initializer)); }, functionalInterface); @@ -683,6 +724,7 @@ void ETSChecker::BuildLambdaObjectClass(ETSObjectType *functionalInterface, ir:: return; } + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) BuildClass(util::StringView(syntheticLambdaObjName), [this, invokeSignature, retTypeAnnotation, functionalInterface](varbinder::ClassScope *scope, ArenaVector *classBody) { @@ -690,7 +732,9 @@ void ETSChecker::BuildLambdaObjectClass(ETSObjectType *functionalInterface, ir:: classType->AddInterface(functionalInterface); auto assemblyName = "jsvalue_lambda"; + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *fieldIdent = AllocNode(assemblyName, Allocator()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *field = AllocNode(fieldIdent, nullptr, nullptr, ir::ModifierFlags::PRIVATE, Allocator(), false); field->SetTsType(GlobalBuiltinJSValueType()); @@ -707,8 +751,9 @@ void ETSChecker::BuildLambdaObjectClass(ETSObjectType *functionalInterface, ir:: classBody->push_back(field); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) classBody->push_back(CreateLambdaObjectClassInitializer(scope, functionalInterface)); - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) classBody->push_back(CreateLambdaObjectClassInvokeMethod(scope, invokeSignature, retTypeAnnotation)); }); diff --git a/ets2panda/checker/ets/enum.cpp b/ets2panda/checker/ets/enum.cpp index f9a116f3f2..e832da0332 100644 --- a/ets2panda/checker/ets/enum.cpp +++ b/ets2panda/checker/ets/enum.cpp @@ -87,13 +87,13 @@ template for (const auto *const member : enumType->GetMembers()) { elements.push_back(elementMaker(member->AsTSEnumMember())); } - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const arrayExpr = checker->Allocator()->New(std::move(elements), checker->Allocator()); arrayExpr->SetPreferredType(elementType); arrayExpr->SetTsType(checker->CreateETSArrayType(elementType)); auto *const arrayIdent = MakeQualifiedIdentifier(checker->Allocator(), enumType->GetDecl(), name); - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const arrayClassProp = checker->Allocator()->New( arrayIdent, arrayExpr, nullptr, ir::ModifierFlags::STATIC | ir::ModifierFlags::PUBLIC | ir::ModifierFlags::CONST, checker->Allocator(), false); @@ -118,7 +118,9 @@ template const util::StringView &name, Type *const type) { const auto paramCtx = varbinder::LexicalScope::Enter(varbinder, scope, false); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const paramIdent = checker->Allocator()->New(name, checker->Allocator()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const param = checker->Allocator()->New(paramIdent, nullptr); auto *const paramVar = std::get<1>(varbinder->AddParamDecl(param)); paramVar->SetTsType(type); @@ -130,8 +132,11 @@ template [[nodiscard]] ir::ETSTypeReference *MakeTypeReference(panda::ArenaAllocator *allocator, const util::StringView &name) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const ident = allocator->New(name, allocator); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const referencePart = allocator->New(ident); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return allocator->New(referencePart); } @@ -141,10 +146,11 @@ template ArenaVector &&body, ir::TypeNode *const returnTypeAnnotation, bool isDeclare) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const functionScope = varbinder->Allocator()->New(checker->Allocator(), paramScope); functionScope->BindParamScope(paramScope); paramScope->BindFunctionScope(functionScope); - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const bodyBlock = checker->Allocator()->New(checker->Allocator(), std::move(body)); bodyBlock->SetScope(functionScope); @@ -154,6 +160,7 @@ template flags |= ir::ModifierFlags::DECLARE; } + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const function = checker->Allocator()->New( ir::FunctionSignature(nullptr, std::move(params), returnTypeAnnotation), bodyBlock, ir::ScriptFunctionFlags::METHOD, flags, isDeclare, Language(Language::Id::ETS)); @@ -170,9 +177,10 @@ template void MakeMethodDef(ETSChecker *const checker, varbinder::ETSBinder *const varbinder, ir::Identifier *const ident, ir::ScriptFunction *const function) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const functionExpr = checker->Allocator()->New(function); function->SetParent(functionExpr); - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const methodDef = checker->Allocator()->New( ir::MethodDefinitionKind::METHOD, ident, functionExpr, ir::ModifierFlags::PUBLIC, checker->Allocator(), false); methodDef->SetParent(varbinder->Program()->GlobalClass()); @@ -224,6 +232,7 @@ ir::Identifier *ETSChecker::CreateEnumNamesArray(ETSEnumInterface const *const e return MakeArray(this, VarBinder()->AsETSBinder(), enumType, "NamesArray", GlobalBuiltinETSStringType(), [this](const ir::TSEnumMember *const member) { auto *const enumNameStringLiteral = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) Allocator()->New(member->Key()->AsIdentifier()->Name()); enumNameStringLiteral->SetTsType(GlobalBuiltinETSStringType()); return enumNameStringLiteral; @@ -236,6 +245,7 @@ ir::Identifier *ETSChecker::CreateEnumValuesArray(ETSEnumType *const enumType) return MakeArray( this, VarBinder()->AsETSBinder(), enumType, "ValuesArray", GlobalIntType(), [this](const ir::TSEnumMember *const member) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const enumValueLiteral = Allocator()->New(lexer::Number( member->AsTSEnumMember()->Init()->AsNumberLiteral()->Number().GetValue())); enumValueLiteral->SetTsType(GlobalIntType()); @@ -245,6 +255,7 @@ ir::Identifier *ETSChecker::CreateEnumValuesArray(ETSEnumType *const enumType) ir::Identifier *ETSChecker::CreateEnumStringValuesArray(ETSEnumInterface *const enumType) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return MakeArray(this, VarBinder()->AsETSBinder(), enumType, "StringValuesArray", GlobalETSStringLiteralType(), [this, isStringEnum = enumType->IsETSStringEnumType()](const ir::TSEnumMember *const member) { auto const stringValue = @@ -256,6 +267,7 @@ ir::Identifier *ETSChecker::CreateEnumStringValuesArray(ETSEnumInterface *const .GetValue()), Allocator()) .View(); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const enumValueStringLiteral = Allocator()->New(stringValue); enumValueStringLiteral->SetTsType(GlobalETSStringLiteralType()); return enumValueStringLiteral; @@ -264,6 +276,7 @@ ir::Identifier *ETSChecker::CreateEnumStringValuesArray(ETSEnumInterface *const ir::Identifier *ETSChecker::CreateEnumItemsArray(ETSEnumInterface *const enumType) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const enumTypeIdent = Allocator()->New(enumType->GetName(), Allocator()); enumTypeIdent->SetTsType(enumType); @@ -271,7 +284,9 @@ ir::Identifier *ETSChecker::CreateEnumItemsArray(ETSEnumInterface *const enumTyp this, VarBinder()->AsETSBinder(), enumType, "ItemsArray", enumType, [this, enumTypeIdent](const ir::TSEnumMember *const member) { auto *const enumMemberIdent = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) Allocator()->New(member->AsTSEnumMember()->Key()->AsIdentifier()->Name(), Allocator()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const enumMemberExpr = Allocator()->New( enumTypeIdent, enumMemberIdent, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); enumMemberExpr->SetTsType(member->AsTSEnumMember()->Key()->AsIdentifier()->Variable()->TsType()); @@ -283,15 +298,20 @@ ETSEnumType::Method ETSChecker::CreateEnumFromIntMethod(ir::Identifier *const na ETSEnumInterface *const enumType) { auto *const paramScope = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) VarBinder()->Allocator()->New(Allocator(), Program()->GlobalScope()); auto *const inputOrdinalIdent = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) MakeFunctionParam(this, VarBinder()->AsETSBinder(), paramScope, "ordinal", GlobalIntType()); auto *const inArraySizeExpr = [this, namesArrayIdent, inputOrdinalIdent]() { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const lengthIdent = Allocator()->New("length", Allocator()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const valuesArrayLengthExpr = Allocator()->New( namesArrayIdent, lengthIdent, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const expr = Allocator()->New(inputOrdinalIdent, valuesArrayLengthExpr, lexer::TokenType::PUNCTUATOR_LESS_THAN); expr->SetOperationType(GlobalIntType()); @@ -301,24 +321,29 @@ ETSEnumType::Method ETSChecker::CreateEnumFromIntMethod(ir::Identifier *const na auto *const returnEnumStmt = [this, inputOrdinalIdent, enumType]() { inputOrdinalIdent->SetTsType(enumType); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return Allocator()->New(inputOrdinalIdent); }(); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const ifOrdinalExistsStmt = Allocator()->New(inArraySizeExpr, returnEnumStmt, nullptr); auto *const throwNoEnumStmt = [this, inputOrdinalIdent, enumType]() { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const exceptionReference = MakeTypeReference(Allocator(), "Exception"); util::UString messageString(util::StringView("No enum constant in "), Allocator()); messageString.Append(enumType->GetName()); messageString.Append(" with ordinal value "); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const message = Allocator()->New(messageString.View()); auto *const newExprArg = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) Allocator()->New(message, inputOrdinalIdent, lexer::TokenType::PUNCTUATOR_PLUS); ArenaVector newExprArgs(Allocator()->Adapter()); newExprArgs.push_back(newExprArg); - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const newExpr = Allocator()->New( exceptionReference, std::move(newExprArgs), GlobalBuiltinExceptionType()->GetDeclNode()->AsClassDefinition()); @@ -326,7 +351,7 @@ ETSEnumType::Method ETSChecker::CreateEnumFromIntMethod(ir::Identifier *const na newExpr->SetSignature( ResolveConstructExpression(GlobalBuiltinExceptionType(), newExpr->GetArguments(), newExpr->Start())); newExpr->SetTsType(GlobalBuiltinExceptionType()); - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return Allocator()->New(newExpr); }(); @@ -337,9 +362,10 @@ ETSEnumType::Method ETSChecker::CreateEnumFromIntMethod(ir::Identifier *const na body.push_back(ifOrdinalExistsStmt); body.push_back(throwNoEnumStmt); body.push_back(returnEnumStmt); - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const enumTypeAnnotation = MakeTypeReference(Allocator(), enumType->GetName()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const function = MakeFunction(this, VarBinder()->AsETSBinder(), paramScope, std::move(params), std::move(body), enumTypeAnnotation, enumType->GetDecl()->IsDeclare()); function->AddFlag(ir::ScriptFunctionFlags::THROWS); @@ -348,6 +374,7 @@ ETSEnumType::Method ETSChecker::CreateEnumFromIntMethod(ir::Identifier *const na function->SetIdent(ident); function->Scope()->BindInternalName(ident->Name()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) MakeMethodDef(this, VarBinder()->AsETSBinder(), ident, function); return {MakeGlobalSignature(this, function, enumType), nullptr}; @@ -357,15 +384,18 @@ ETSEnumType::Method ETSChecker::CreateEnumToStringMethod(ir::Identifier *const s ETSEnumInterface *const enumType) { auto *const paramScope = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) VarBinder()->Allocator()->New(Allocator(), Program()->GlobalClassScope()); - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const inputEnumIdent = MakeFunctionParam(this, VarBinder()->AsETSBinder(), paramScope, "ordinal", enumType); auto *const returnStmt = [this, inputEnumIdent, stringValuesArrayIdent]() { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const arrayAccessExpr = Allocator()->New( stringValuesArrayIdent, inputEnumIdent, ir::MemberExpressionKind::ELEMENT_ACCESS, true, false); arrayAccessExpr->SetTsType(GlobalETSStringLiteralType()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return Allocator()->New(arrayAccessExpr); }(); @@ -375,15 +405,17 @@ ETSEnumType::Method ETSChecker::CreateEnumToStringMethod(ir::Identifier *const s ArenaVector params(Allocator()->Adapter()); params.push_back(inputEnumIdent); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const stringTypeAnnotation = MakeTypeReference(Allocator(), GlobalBuiltinETSStringType()->Name()); auto *const function = MakeFunction(this, VarBinder()->AsETSBinder(), paramScope, std::move(params), std::move(body), stringTypeAnnotation, enumType->GetDecl()->IsDeclare()); auto *const functionIdent = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) MakeQualifiedIdentifier(Allocator(), enumType->GetDecl(), ETSEnumType::TO_STRING_METHOD_NAME); function->SetIdent(functionIdent); function->Scope()->BindInternalName(functionIdent->Name()); - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) MakeMethodDef(this, VarBinder()->AsETSBinder(), functionIdent, function); return { @@ -395,15 +427,18 @@ ETSEnumType::Method ETSChecker::CreateEnumGetValueMethod(ir::Identifier *const v ETSEnumType *const enumType) { auto *const paramScope = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) VarBinder()->Allocator()->New(Allocator(), Program()->GlobalClassScope()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const inputEnumIdent = MakeFunctionParam(this, VarBinder()->AsETSBinder(), paramScope, "e", enumType); auto *const returnStmt = [this, inputEnumIdent, valuesArrayIdent]() { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const arrayAccessExpr = Allocator()->New( valuesArrayIdent, inputEnumIdent, ir::MemberExpressionKind::ELEMENT_ACCESS, true, false); arrayAccessExpr->SetTsType(GlobalIntType()); - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return Allocator()->New(arrayAccessExpr); }(); @@ -412,7 +447,7 @@ ETSEnumType::Method ETSChecker::CreateEnumGetValueMethod(ir::Identifier *const v ArenaVector params(Allocator()->Adapter()); params.push_back(inputEnumIdent); - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const intTypeAnnotation = Allocator()->New(ir::PrimitiveType::INT); auto *const function = MakeFunction(this, VarBinder()->AsETSBinder(), paramScope, std::move(params), std::move(body), intTypeAnnotation, enumType->GetDecl()->IsDeclare()); @@ -432,15 +467,17 @@ ETSEnumType::Method ETSChecker::CreateEnumGetNameMethod(ir::Identifier *const na ETSEnumInterface *const enumType) { auto *const paramScope = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) VarBinder()->Allocator()->New(Allocator(), Program()->GlobalScope()); - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const inputEnumIdent = MakeFunctionParam(this, VarBinder()->AsETSBinder(), paramScope, "ordinal", enumType); auto *const returnStmt = [this, inputEnumIdent, namesArrayIdent]() { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const arrayAccessExpr = Allocator()->New( namesArrayIdent, inputEnumIdent, ir::MemberExpressionKind::ELEMENT_ACCESS, true, false); arrayAccessExpr->SetTsType(GlobalBuiltinETSStringType()); - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return Allocator()->New(arrayAccessExpr); }(); @@ -449,13 +486,14 @@ ETSEnumType::Method ETSChecker::CreateEnumGetNameMethod(ir::Identifier *const na ArenaVector params(Allocator()->Adapter()); params.push_back(inputEnumIdent); - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const stringTypeAnnotation = MakeTypeReference(Allocator(), GlobalBuiltinETSStringType()->Name()); auto *const function = MakeFunction(this, VarBinder()->AsETSBinder(), paramScope, std::move(params), std::move(body), stringTypeAnnotation, enumType->GetDecl()->IsDeclare()); auto *const functionIdent = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) MakeQualifiedIdentifier(Allocator(), enumType->GetDecl(), ETSEnumType::GET_NAME_METHOD_NAME); function->SetIdent(functionIdent); function->Scope()->BindInternalName(functionIdent->Name()); @@ -470,14 +508,17 @@ ETSEnumType::Method ETSChecker::CreateEnumValueOfMethod(ir::Identifier *const na ETSEnumInterface *const enumType) { auto *const paramScope = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) VarBinder()->Allocator()->New(Allocator(), Program()->GlobalScope()); auto *const inputNameIdent = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) MakeFunctionParam(this, VarBinder()->AsETSBinder(), paramScope, "name", GlobalBuiltinETSStringType()); varbinder::LexicalScope loopDeclScope(VarBinder()); auto *const forLoopIIdent = [this]() { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const ident = Allocator()->New("i", Allocator()); ident->SetTsType(GlobalIntType()); auto [decl, var] = VarBinder()->NewVarDecl(ident->Start(), ident->Name()); @@ -490,22 +531,28 @@ ETSEnumType::Method ETSChecker::CreateEnumValueOfMethod(ir::Identifier *const na }(); auto *const forLoopInitVarDecl = [this, forLoopIIdent]() { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const init = Allocator()->New("0"); init->SetTsType(GlobalIntType()); auto *const decl = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) Allocator()->New(ir::VariableDeclaratorFlag::LET, forLoopIIdent, init); decl->SetTsType(GlobalIntType()); ArenaVector decls(Allocator()->Adapter()); decls.push_back(decl); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return Allocator()->New(ir::VariableDeclaration::VariableDeclarationKind::LET, Allocator(), std::move(decls), false); }(); auto *const forLoopTest = [this, namesArrayIdent, forLoopIIdent]() { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const lengthIdent = Allocator()->New("length", Allocator()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const arrayLengthExpr = Allocator()->New( namesArrayIdent, lengthIdent, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); arrayLengthExpr->SetTsType(GlobalIntType()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const binaryExpr = Allocator()->New(forLoopIIdent, arrayLengthExpr, lexer::TokenType::PUNCTUATOR_LESS_THAN); binaryExpr->SetOperationType(GlobalIntType()); @@ -515,22 +562,25 @@ ETSEnumType::Method ETSChecker::CreateEnumValueOfMethod(ir::Identifier *const na auto *const forLoopUpdate = [this, forLoopIIdent]() { auto *const incrementExpr = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) Allocator()->New(forLoopIIdent, lexer::TokenType::PUNCTUATOR_PLUS_PLUS, true); incrementExpr->SetTsType(GlobalIntType()); return incrementExpr; }(); auto *const ifStmt = [this, namesArrayIdent, forLoopIIdent, inputNameIdent]() { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const namesArrayElementExpr = Allocator()->New( namesArrayIdent, forLoopIIdent, ir::MemberExpressionKind::ELEMENT_ACCESS, true, false); namesArrayElementExpr->SetTsType(GlobalBuiltinETSStringType()); - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const namesEqualExpr = Allocator()->New(inputNameIdent, namesArrayElementExpr, lexer::TokenType::PUNCTUATOR_EQUAL); namesEqualExpr->SetOperationType(GlobalBuiltinETSStringType()); namesEqualExpr->SetTsType(GlobalETSBooleanType()); - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const returnStmt = Allocator()->New(forLoopIIdent); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return Allocator()->New(namesEqualExpr, returnStmt, nullptr); }(); @@ -538,6 +588,7 @@ ETSEnumType::Method ETSChecker::CreateEnumValueOfMethod(ir::Identifier *const na loopScope.GetScope()->BindDecls(loopDeclScope.GetScope()); auto *const forLoop = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) Allocator()->New(forLoopInitVarDecl, forLoopTest, forLoopUpdate, ifStmt); loopScope.GetScope()->BindNode(forLoop); forLoop->SetScope(loopScope.GetScope()); @@ -547,23 +598,24 @@ ETSEnumType::Method ETSChecker::CreateEnumValueOfMethod(ir::Identifier *const na util::UString messageString(util::StringView("No enum constant "), Allocator()); messageString.Append(enumType->GetName()); messageString.Append('.'); - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const message = Allocator()->New(messageString.View()); auto *const newExprArg = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) Allocator()->New(message, inputNameIdent, lexer::TokenType::PUNCTUATOR_PLUS); ArenaVector newExprArgs(Allocator()->Adapter()); newExprArgs.push_back(newExprArg); - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const exceptionReference = MakeTypeReference(Allocator(), "Exception"); - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const newExpr = Allocator()->New( exceptionReference, std::move(newExprArgs), GlobalBuiltinExceptionType()->GetDeclNode()->AsClassDefinition()); newExpr->SetSignature( ResolveConstructExpression(GlobalBuiltinExceptionType(), newExpr->GetArguments(), newExpr->Start())); newExpr->SetTsType(GlobalBuiltinExceptionType()); - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return Allocator()->New(newExpr); }(); @@ -573,7 +625,7 @@ ETSEnumType::Method ETSChecker::CreateEnumValueOfMethod(ir::Identifier *const na ArenaVector params(Allocator()->Adapter()); params.push_back(inputNameIdent); - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const enumTypeAnnotation = MakeTypeReference(Allocator(), enumType->GetName()); auto *const function = MakeFunction(this, VarBinder()->AsETSBinder(), paramScope, std::move(params), @@ -581,6 +633,7 @@ ETSEnumType::Method ETSChecker::CreateEnumValueOfMethod(ir::Identifier *const na function->AddFlag(ir::ScriptFunctionFlags::THROWS); auto *const functionIdent = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) MakeQualifiedIdentifier(Allocator(), enumType->GetDecl(), ETSEnumType::VALUE_OF_METHOD_NAME); function->SetIdent(functionIdent); function->Scope()->BindInternalName(functionIdent->Name()); @@ -597,8 +650,9 @@ ETSEnumType::Method ETSChecker::CreateEnumValuesMethod(ir::Identifier *const ite ETSEnumInterface *const enumType) { auto *const paramScope = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) VarBinder()->Allocator()->New(Allocator(), Program()->GlobalScope()); - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const returnStmt = Allocator()->New(itemsArrayIdent); ArenaVector body(Allocator()->Adapter()); body.push_back(returnStmt); @@ -606,6 +660,7 @@ ETSEnumType::Method ETSChecker::CreateEnumValuesMethod(ir::Identifier *const ite ArenaVector params(Allocator()->Adapter()); auto *const enumArrayTypeAnnotation = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) Allocator()->New(MakeTypeReference(Allocator(), enumType->GetName())); auto *const function = MakeFunction(this, VarBinder()->AsETSBinder(), paramScope, std::move(params), diff --git a/ets2panda/checker/ets/function.cpp b/ets2panda/checker/ets/function.cpp index 5c9d216477..f2fab6d86d 100644 --- a/ets2panda/checker/ets/function.cpp +++ b/ets2panda/checker/ets/function.cpp @@ -1380,6 +1380,7 @@ void ETSChecker::BuildFunctionalInterfaceName(ir::ETSFunctionType *funcType) void ETSChecker::CreateFunctionalInterfaceForFunctionType(ir::ETSFunctionType *funcType) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *identNode = Allocator()->New(util::StringView("FunctionalInterface"), Allocator()); auto interfaceCtx = varbinder::LexicalScope(VarBinder()); @@ -1401,9 +1402,11 @@ void ETSChecker::CreateFunctionalInterfaceForFunctionType(ir::ETSFunctionType *f invokeFunc->Function()->AddFlag(ir::ScriptFunctionFlags::THROWS); } + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *body = Allocator()->New(std::move(members)); ArenaVector extends(Allocator()->Adapter()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *interfaceDecl = Allocator()->New( Allocator(), identNode, nullptr, body, std::move(extends), false, false, Language(Language::Id::ETS)); interfaceDecl->SetScope(interfaceScope); @@ -1416,6 +1419,7 @@ void ETSChecker::CreateFunctionalInterfaceForFunctionType(ir::ETSFunctionType *f ir::MethodDefinition *ETSChecker::CreateInvokeFunction(ir::ETSFunctionType *funcType) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *identNode = Allocator()->New(util::StringView("invoke"), Allocator()); ArenaVector params(Allocator()->Adapter()); @@ -1428,6 +1432,7 @@ ir::MethodDefinition *ETSChecker::CreateInvokeFunction(ir::ETSFunctionType *func funcParamScope->BindFunctionScope(functionScope); ir::ModifierFlags flags = ir::ModifierFlags::ABSTRACT | ir::ModifierFlags::PUBLIC; + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *func = Allocator()->New( ir::FunctionSignature(nullptr, std::move(params), funcType->ReturnType()), nullptr, ir::ScriptFunctionFlags::METHOD, flags, false, Language(Language::Id::ETS)); @@ -1435,10 +1440,10 @@ ir::MethodDefinition *ETSChecker::CreateInvokeFunction(ir::ETSFunctionType *func func->SetScope(functionScope); functionScope->BindNode(func); funcParamScope->BindNode(func); - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *funcExpr = Allocator()->New(func); func->SetIdent(identNode); - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *method = Allocator()->New(ir::MethodDefinitionKind::METHOD, identNode, funcExpr, flags, Allocator(), false); @@ -1504,8 +1509,10 @@ void ETSChecker::CreateLambdaObjectForLambdaReference(ir::ArrowFunctionExpressio // Create the synthetic lambda class node ArenaVector implements(Allocator()->Adapter()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *identNode = Allocator()->New(util::StringView("LambdaObject"), Allocator()); auto *lambdaObject = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) Allocator()->New(Allocator(), identNode, std::move(properties), ir::ClassDefinitionModifiers::DECLARATION, Language(Language::Id::ETS)); lambda->SetResolvedLambda(lambdaObject); @@ -1550,6 +1557,7 @@ void ETSChecker::ResolveLambdaObject(ir::ClassDefinition *lambdaObject, ETSObjec bool saveThis) { // Create the class type for the lambda + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *lambdaObjectType = Allocator()->New(Allocator(), lambdaObject->Ident()->Name(), lambdaObject->Ident()->Name(), lambdaObject, checker::ETSObjectFlags::CLASS); @@ -1629,6 +1637,7 @@ void ETSChecker::ResolveLambdaObjectInvoke(ir::ClassDefinition *lambdaObject, ir } invokeFunc->Body()->AsBlockStatement()->Statements().push_back(resolvedLambdaInvokeFunctionBody); if (resolvedLambdaInvokeFunctionBody->IsExpressionStatement()) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) invokeFunc->Body()->AsBlockStatement()->Statements().push_back(Allocator()->New(nullptr)); } } @@ -1643,6 +1652,7 @@ ir::Statement *ETSChecker::ResolveLambdaObjectInvokeFuncBody(ir::ClassDefinition // If the proxy method is static, we should call it through the owner class itself if (isStatic) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) fieldIdent = Allocator()->New(proxySignature->Owner()->Name(), Allocator()); fieldPropType = proxySignature->Owner(); fieldIdent->SetVariable(proxySignature->Owner()->Variable()); @@ -1652,13 +1662,16 @@ ir::Statement *ETSChecker::ResolveLambdaObjectInvokeFuncBody(ir::ClassDefinition auto *savedThis = lambdaBody[lambdaBody.size() - 3]->AsClassProperty(); auto *fieldProp = savedThis->Key()->AsIdentifier()->Variable(); fieldPropType = fieldProp->TsType()->AsETSObjectType(); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) fieldIdent = Allocator()->New(savedThis->Key()->AsIdentifier()->Name(), Allocator()); fieldIdent->SetVariable(fieldProp); fieldIdent->SetTsType(fieldPropType); } // Set the type information for the proxy function call + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *funcIdent = Allocator()->New(proxyMethod->Function()->Id()->Name(), Allocator()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *callee = Allocator()->New(fieldIdent, funcIdent, ir::MemberExpressionKind::ELEMENT_ACCESS, false, false); callee->SetPropVar(proxySignature->OwnerVar()->AsLocalVariable()); @@ -1675,6 +1688,7 @@ ir::Statement *ETSChecker::ResolveLambdaObjectInvokeFuncBody(ir::ClassDefinition } auto *classProp = lambdaBody[i]->AsClassProperty(); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *param = Allocator()->New(classProp->Key()->AsIdentifier()->Name(), Allocator()); param->SetVariable(classProp->Key()->AsIdentifier()->Variable()); param->SetIgnoreBox(); @@ -1685,6 +1699,7 @@ ir::Statement *ETSChecker::ResolveLambdaObjectInvokeFuncBody(ir::ClassDefinition // Then we add the lambda functions parameters to the call for (auto const *const it : invokeFunc->Params()) { auto const *const param = it->AsETSParameterExpression(); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const paramIdent = Allocator()->New(param->Ident()->Name(), Allocator()); paramIdent->SetVariable(param->Variable()); paramIdent->SetTsType(param->Variable()->TsType()); @@ -1692,13 +1707,16 @@ ir::Statement *ETSChecker::ResolveLambdaObjectInvokeFuncBody(ir::ClassDefinition } // Create the synthetic call expression to the proxy method + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *resolvedCall = Allocator()->New(callee, std::move(callParams), nullptr, false); resolvedCall->SetTsType(proxySignature->ReturnType()); resolvedCall->SetSignature(proxySignature); if (proxySignature->ReturnType()->IsETSVoidType()) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return Allocator()->New(resolvedCall); } + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return Allocator()->New(resolvedCall); } @@ -1823,10 +1841,12 @@ ir::ScriptFunction *ETSChecker::CreateProxyFunc(ir::ArrowFunctionExpression *lam { // Create the synthetic parameters for the proxy method ArenaVector params(Allocator()->Adapter()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *funcParamScope = CreateProxyMethodParams(lambda, params, captured, isStatic); // Create the scopes for the proxy method auto paramCtx = varbinder::LexicalScope::Enter(VarBinder(), funcParamScope, false); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *scope = VarBinder()->Allocator()->New(Allocator(), funcParamScope); auto *body = lambda->Function()->Body(); body->AsBlockStatement()->SetScope(scope); @@ -1835,6 +1855,7 @@ ir::ScriptFunction *ETSChecker::CreateProxyFunc(ir::ArrowFunctionExpression *lam if (lambda->Function()->IsAsyncFunc()) { funcFlags |= ir::ScriptFunctionFlags::ASYNC; } + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *func = Allocator()->New( ir::FunctionSignature(nullptr, std::move(params), lambda->Function()->ReturnTypeAnnotation()), body, funcFlags, GetFlagsForProxyLambda(isStatic), false, Language(Language::Id::ETS)); @@ -1869,11 +1890,14 @@ ir::MethodDefinition *ETSChecker::CreateProxyMethodForLambda(ir::ClassDefinition auto *func = CreateProxyFunc(lambda, captured, isStatic); // Create the synthetic proxy method + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *funcExpr = Allocator()->New(func); util::UString funcName(util::StringView("lambda$invoke$"), Allocator()); funcName.Append(std::to_string(ComputeProxyMethods(klass))); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *identNode = Allocator()->New(funcName.View(), Allocator()); func->SetIdent(identNode); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *proxy = Allocator()->New(ir::MethodDefinitionKind::METHOD, identNode, funcExpr, GetFlagsForProxyLambda(isStatic), Allocator(), false); klass->Body().push_back(proxy); @@ -1994,11 +2018,13 @@ varbinder::FunctionParamScope *ETSChecker::CreateProxyMethodParams(ir::ArrowFunc // "this" should be binded with the parameter of the proxy method if (this->HasStatus(checker::CheckerStatus::IN_INSTANCE_EXTENSION_METHOD) && lambda->CapturedVars()[i]->Name() == varbinder::VarBinder::MANDATORY_PARAM_THIS) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) paramIdent = Allocator()->New(varbinder::VarBinder::MANDATORY_PARAM_THIS, Allocator()); } else { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) paramIdent = Allocator()->New(capturedVar->Name(), Allocator()); } - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *param = Allocator()->New(paramIdent, nullptr); auto [_, var] = VarBinder()->AddParamDecl(param); (void)_; @@ -2016,7 +2042,9 @@ varbinder::FunctionParamScope *ETSChecker::CreateProxyMethodParams(ir::ArrowFunc // already computed types for the lambda parameters for (auto const *const it : params) { auto *const oldParamExprIdent = it->AsETSParameterExpression()->Ident(); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const paramIdent = Allocator()->New(oldParamExprIdent->Name(), Allocator()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *param = Allocator()->New(paramIdent, nullptr); auto [_, var] = VarBinder()->AddParamDecl(param); (void)_; @@ -2038,10 +2066,12 @@ ir::ClassProperty *ETSChecker::CreateLambdaCapturedThis(varbinder::ClassScope *s // Create the name for the synthetic property node util::UString fieldName(util::StringView("field"), Allocator()); fieldName.Append(std::to_string(idx)); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *fieldIdent = Allocator()->New(fieldName.View(), Allocator()); // Create the synthetic class property node auto *field = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) Allocator()->New(fieldIdent, nullptr, nullptr, ir::ModifierFlags::NONE, Allocator(), false); // Add the declaration to the scope, and set the type based on the current class type, to be able to store the @@ -2065,10 +2095,12 @@ ir::ClassProperty *ETSChecker::CreateLambdaCapturedField(const varbinder::Variab // Create the name for the synthetic property node util::UString fieldName(util::StringView("field"), Allocator()); fieldName.Append(std::to_string(idx)); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *fieldIdent = Allocator()->New(fieldName.View(), Allocator()); // Create the synthetic class property node auto *field = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) Allocator()->New(fieldIdent, nullptr, nullptr, ir::ModifierFlags::NONE, Allocator(), false); // Add the declaration to the scope, and set the type based on the captured variable's scope @@ -2092,6 +2124,7 @@ ir::MethodDefinition *ETSChecker::CreateLambdaImplicitCtor(ArenaVector::Enter(VarBinder(), funcParamScope, false); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *scope = VarBinder()->Allocator()->New(Allocator(), funcParamScope); // Complete the synthetic constructor node's body, to be able to initialize every field by copying every @@ -2103,9 +2136,11 @@ ir::MethodDefinition *ETSChecker::CreateLambdaImplicitCtor(ArenaVectorNew(Allocator(), std::move(statements)); body->SetScope(scope); auto *func = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) Allocator()->New(ir::FunctionSignature(nullptr, std::move(params), nullptr), body, ir::ScriptFunctionFlags::CONSTRUCTOR, false, Language(Language::Id::ETS)); func->SetScope(scope); @@ -2116,9 +2151,12 @@ ir::MethodDefinition *ETSChecker::CreateLambdaImplicitCtor(ArenaVectorBindFunctionScope(scope); // Create the name for the synthetic constructor + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *funcExpr = Allocator()->New(func); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *key = Allocator()->New("constructor", Allocator()); func->SetIdent(key); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *ctor = Allocator()->New(ir::MethodDefinitionKind::CONSTRUCTOR, key, funcExpr, ir::ModifierFlags::NONE, Allocator(), false); @@ -2139,7 +2177,9 @@ varbinder::FunctionParamScope *ETSChecker::CreateLambdaCtorImplicitParams(ArenaV // captured variables for (auto *it : properties) { auto *field = it->AsClassProperty()->Key()->AsIdentifier(); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *paramField = Allocator()->New(field->Name(), Allocator()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *param = Allocator()->New(paramField, nullptr); auto [_, var] = VarBinder()->AddParamDecl(param); (void)_; @@ -2158,14 +2198,20 @@ ir::Statement *ETSChecker::CreateLambdaCtorFieldInit(util::StringView name, varb // Create synthetic field initializers for the lambda class fields // The node structure is the following: this.field0 = field0, where the left hand side refers to the lambda // classes field, and the right hand side is refers to the constructors parameter + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *thisExpr = Allocator()->New(); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *fieldAccessExpr = Allocator()->New(name, Allocator()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *leftHandSide = Allocator()->New( thisExpr, fieldAccessExpr, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *rightHandSide = Allocator()->New(name, Allocator()); rightHandSide->SetVariable(var); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *initializer = Allocator()->New(leftHandSide, rightHandSide, lexer::TokenType::PUNCTUATOR_SUBSTITUTION); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return Allocator()->New(initializer); } @@ -2187,6 +2233,7 @@ void ETSChecker::CreateLambdaObjectForFunctionReference(ir::AstNode *refNode, Si // reference through, if the referenced function is static, we won't need to store the instance object ArenaVector properties(Allocator()->Adapter()); if (!isStaticReference) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) properties.push_back(CreateLambdaImplicitField(classScope, refNode->Start())); } @@ -2206,8 +2253,10 @@ void ETSChecker::CreateLambdaObjectForFunctionReference(ir::AstNode *refNode, Si // Create the synthetic lambda class node ArenaVector implements(Allocator()->Adapter()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *identNode = Allocator()->New(util::StringView("LambdaObject"), Allocator()); auto *lambdaObject = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) Allocator()->New(Allocator(), identNode, std::move(properties), ir::ClassDefinitionModifiers::DECLARATION, Language(Language::Id::ETS)); lambdaObject->SetScope(classScope); @@ -2229,8 +2278,10 @@ ir::AstNode *ETSChecker::CreateLambdaImplicitField(varbinder::ClassScope *scope, auto fieldCtx = varbinder::LexicalScope::Enter(VarBinder(), scope->InstanceFieldScope()); // Create the synthetic class property node + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *fieldIdent = Allocator()->New("field0", Allocator()); auto *field = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) Allocator()->New(fieldIdent, nullptr, nullptr, ir::ModifierFlags::NONE, Allocator(), false); // Add the declaration to the scope @@ -2251,6 +2302,7 @@ ir::MethodDefinition *ETSChecker::CreateLambdaImplicitCtor(const lexer::SourceRa // Create the scopes auto paramCtx = varbinder::LexicalScope::Enter(VarBinder(), funcParamScope, false); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *scope = VarBinder()->Allocator()->New(Allocator(), funcParamScope); // If the reference refers to a static function, the constructor will be empty, otherwise, we have to make a @@ -2259,9 +2311,11 @@ ir::MethodDefinition *ETSChecker::CreateLambdaImplicitCtor(const lexer::SourceRa statements.push_back(CreateLambdaCtorFieldInit(util::StringView("field0"), var)); } + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *body = Allocator()->New(Allocator(), std::move(statements)); body->SetScope(scope); auto *func = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) Allocator()->New(ir::FunctionSignature(nullptr, std::move(params), nullptr), body, ir::ScriptFunctionFlags::CONSTRUCTOR, false, Language(Language::Id::ETS)); func->SetScope(scope); @@ -2272,9 +2326,12 @@ ir::MethodDefinition *ETSChecker::CreateLambdaImplicitCtor(const lexer::SourceRa funcParamScope->BindFunctionScope(scope); // Create the synthetic constructor + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *funcExpr = Allocator()->New(func); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *key = Allocator()->New("constructor", Allocator()); func->SetIdent(key); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *ctor = Allocator()->New(ir::MethodDefinitionKind::CONSTRUCTOR, key, funcExpr, ir::ModifierFlags::NONE, Allocator(), false); @@ -2295,7 +2352,9 @@ std::tuple ETSChecker::C // since when initializing the lambda class, we don't need to save the instance object which we tried to get the // function reference through if (!isStaticReference) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *paramIdent = Allocator()->New("field0", Allocator()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *param = Allocator()->New(paramIdent, nullptr); paramIdent->SetRange(pos); auto [_, var] = VarBinder()->AddParamDecl(param); @@ -2312,15 +2371,20 @@ ir::MethodDefinition *ETSChecker::CreateLambdaInvokeProto() { // Create the template for the synthetic 'invoke' method, which will be used when the function type will be // called + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *name = Allocator()->New("invoke", Allocator()); auto *paramScope = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) VarBinder()->Allocator()->New(Allocator(), VarBinder()->GetScope()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *scope = VarBinder()->Allocator()->New(Allocator(), paramScope); ArenaVector params(Allocator()->Adapter()); ArenaVector statements(Allocator()->Adapter()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *body = Allocator()->New(Allocator(), std::move(statements)); body->SetScope(scope); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *func = Allocator()->New(ir::FunctionSignature(nullptr, std::move(params), nullptr), body, ir::ScriptFunctionFlags::METHOD, ir::ModifierFlags::PUBLIC, false, Language(Language::Id::ETS)); @@ -2330,10 +2394,10 @@ ir::MethodDefinition *ETSChecker::CreateLambdaInvokeProto() paramScope->BindNode(func); scope->BindParamScope(paramScope); paramScope->BindFunctionScope(scope); - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *funcExpr = Allocator()->New(func); func->SetIdent(name); - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *method = Allocator()->New(ir::MethodDefinitionKind::METHOD, name, funcExpr, ir::ModifierFlags::PUBLIC, Allocator(), false); @@ -2374,6 +2438,7 @@ void ETSChecker::ResolveLambdaObject(ir::ClassDefinition *lambdaObject, Signatur } // Create the class type for the lambda + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *lambdaObjectType = Allocator()->New(Allocator(), lambdaObject->Ident()->Name(), lambdaObject->Ident()->Name(), lambdaObject, checker::ETSObjectFlags::CLASS); @@ -2476,8 +2541,9 @@ void ETSChecker::ResolveLambdaObjectInvoke(ir::ClassDefinition *lambdaObject, Si for (auto *it : signatureRef->Params()) { auto paramCtx = varbinder::LexicalScope::Enter( VarBinder(), invokeFunc->Scope()->ParamScope(), false); - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *paramIdent = Allocator()->New(it->Name(), Allocator()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *param = Allocator()->New(paramIdent, nullptr); auto [_, var] = VarBinder()->AddParamDecl(param); (void)_; @@ -2506,6 +2572,7 @@ void ETSChecker::ResolveLambdaObjectInvoke(ir::ClassDefinition *lambdaObject, Si invokeFunc->Body()->AsBlockStatement()->Statements().push_back(resolvedLambdaInvokeFunctionBody); if (resolvedLambdaInvokeFunctionBody->IsExpressionStatement()) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) invokeFunc->Body()->AsBlockStatement()->Statements().push_back(Allocator()->New(nullptr)); } } @@ -2519,6 +2586,7 @@ ir::Statement *ETSChecker::ResolveLambdaObjectInvokeFuncBody(ir::ClassDefinition // If this is a static function reference, we have to call the referenced function through the class itself if (isStaticReference) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) fieldIdent = Allocator()->New(signatureRef->Owner()->Name(), Allocator()); fieldPropType = signatureRef->Owner(); fieldIdent->SetVariable(signatureRef->Owner()->Variable()); @@ -2528,13 +2596,16 @@ ir::Statement *ETSChecker::ResolveLambdaObjectInvokeFuncBody(ir::ClassDefinition // reference auto *fieldProp = lambdaBody[0]->AsClassProperty()->Key()->AsIdentifier()->Variable(); fieldPropType = fieldProp->TsType()->AsETSObjectType(); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) fieldIdent = Allocator()->New("field0", Allocator()); fieldIdent->SetVariable(fieldProp); fieldIdent->SetTsType(fieldPropType); } // Set the type information for the function reference call + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *funcIdent = Allocator()->New(signatureRef->Function()->Id()->Name(), Allocator()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *callee = Allocator()->New(fieldIdent, funcIdent, ir::MemberExpressionKind::ELEMENT_ACCESS, false, false); callee->SetPropVar(signatureRef->OwnerVar()->AsLocalVariable()); @@ -2545,6 +2616,7 @@ ir::Statement *ETSChecker::ResolveLambdaObjectInvokeFuncBody(ir::ClassDefinition auto *invokeFunc = lambdaBody[lambdaBody.size() - 1]->AsMethodDefinition()->Function(); ArenaVector callParams(Allocator()->Adapter()); for (size_t idx = 0; idx != signatureRef->Params().size(); idx++) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *paramIdent = Allocator()->New(signatureRef->Params()[idx]->Name(), Allocator()); paramIdent->SetVariable(invokeFunc->Params()[idx]->AsETSParameterExpression()->Variable()); paramIdent->SetTsType(invokeFunc->Params()[idx]->AsETSParameterExpression()->Variable()->TsType()); @@ -2552,14 +2624,16 @@ ir::Statement *ETSChecker::ResolveLambdaObjectInvokeFuncBody(ir::ClassDefinition } // Create the synthetic call expression to the referenced function + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *resolvedCall = Allocator()->New(callee, std::move(callParams), nullptr, false); resolvedCall->SetTsType(signatureRef->ReturnType()); resolvedCall->SetSignature(signatureRef); if (signatureRef->ReturnType()->IsETSVoidType()) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return Allocator()->New(resolvedCall); } - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return Allocator()->New(resolvedCall); } @@ -2628,10 +2702,12 @@ ir::MethodDefinition *ETSChecker::CreateAsyncImplMethod(ir::MethodDefinition *as varbinder::FunctionParamScope *paramScope = CopyParams(asyncFunc->Params(), params); // Set impl method return type "Object" because it may return Promise as well as Promise parameter's type + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *objectId = Allocator()->New(compiler::Signatures::BUILTIN_OBJECT_CLASS, Allocator()); objectId->SetReference(); VarBinder()->AsETSBinder()->LookupTypeReference(objectId, false); auto *returnTypeAnn = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) Allocator()->New(Allocator()->New(objectId, nullptr, nullptr)); objectId->SetParent(returnTypeAnn->Part()); returnTypeAnn->Part()->SetParent(returnTypeAnn); @@ -2643,7 +2719,7 @@ ir::MethodDefinition *ETSChecker::CreateAsyncImplMethod(ir::MethodDefinition *as return GlobalBuiltinPromiseType()->AsETSObjectType(); }(asyncFuncRetTypeAnn); - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *retType = Allocator()->New(Allocator(), promiseType); returnTypeAnn->SetTsType(retType); @@ -2701,9 +2777,12 @@ ir::MethodDefinition *ETSChecker::CreateMethod(const util::StringView &name, ir: varbinder::FunctionParamScope *paramScope, ir::TypeNode *returnType, ir::AstNode *body) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *nameId = Allocator()->New(name, Allocator()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *scope = VarBinder()->Allocator()->New(Allocator(), paramScope); ir::ScriptFunction *func = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) Allocator()->New(ir::FunctionSignature(nullptr, std::move(params), returnType), body, flags, modifiers, false, Language(Language::Id::ETS)); func->SetScope(scope); @@ -2716,7 +2795,9 @@ ir::MethodDefinition *ETSChecker::CreateMethod(const util::StringView &name, ir: paramScope->BindNode(func); scope->BindParamScope(paramScope); paramScope->BindFunctionScope(scope); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *funcExpr = Allocator()->New(func); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *method = Allocator()->New(ir::MethodDefinitionKind::METHOD, nameId, funcExpr, modifiers, Allocator(), false); funcExpr->SetParent(method); diff --git a/ets2panda/checker/ets/helpers.cpp b/ets2panda/checker/ets/helpers.cpp index e720f7b96f..b80631d78d 100644 --- a/ets2panda/checker/ets/helpers.cpp +++ b/ets2panda/checker/ets/helpers.cpp @@ -514,6 +514,7 @@ void ETSChecker::ValidateCallExpressionIdentifier(ir::Identifier *const ident, T if (ident->Parent()->AsCallExpression()->Callee() == ident && !type->IsETSFunctionType() && !type->IsETSDynamicType() && (!type->IsETSObjectType() || !type->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::FUNCTIONAL)) && + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) !TryTransformingToStaticInvoke(ident, type)) { ThrowError(ident); } @@ -621,6 +622,7 @@ void ETSChecker::ValidateResolvedIdentifier(ir::Identifier *const ident, varbind switch (ident->Parent()->Type()) { case ir::AstNodeType::CALL_EXPRESSION: { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) ValidateCallExpressionIdentifier(ident, resolvedType); break; } @@ -1025,6 +1027,7 @@ checker::Type *ETSChecker::CheckArrayElements(ir::Identifier *ident, ir::ArrayEx ArenaVector elements = init->AsArrayExpression()->Elements(); checker::Type *annotationType = nullptr; if (elements.empty()) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) annotationType = Allocator()->New(GlobalETSObjectType()); } else { auto type = elements[0]->Check(this); @@ -1042,6 +1045,7 @@ checker::Type *ETSChecker::CheckArrayElements(ir::Identifier *ident, ir::ArrayEx ThrowTypeError({"Union type is not implemented yet!"}, ident->Start()); } } + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) annotationType = Allocator()->New(type); } return annotationType; @@ -1118,6 +1122,7 @@ checker::Type *ETSChecker::CheckVariableDeclaration(ir::Identifier *ident, ir::T (init->IsArrowFunctionExpression() || (init->IsTSAsExpression() && init->AsTSAsExpression()->Expr()->IsArrowFunctionExpression()))) { if (init->IsArrowFunctionExpression()) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) typeAnnotation = init->AsArrowFunctionExpression()->CreateTypeAnnotation(this); } else { typeAnnotation = init->AsTSAsExpression()->TypeAnnotation(); @@ -1333,6 +1338,7 @@ Type *ETSChecker::GetTypeFromEnumReference([[maybe_unused]] varbinder::Variable auto const *const enumDecl = var->Declaration()->Node()->AsTSEnumDeclaration(); if (auto *const itemInit = enumDecl->Members().front()->AsTSEnumMember()->Init(); itemInit->IsNumberLiteral()) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return CreateETSEnumType(enumDecl); } else if (itemInit->IsStringLiteral()) { // NOLINT(readability-else-after-return) return CreateETSStringEnumType(enumDecl); @@ -1457,6 +1463,7 @@ Type *ETSChecker::GetReferencedTypeBase(ir::Expression *name) return GetTypeFromClassReference(refVar); } case ir::AstNodeType::TS_ENUM_DECLARATION: { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return GetTypeFromEnumReference(refVar); } case ir::AstNodeType::TS_TYPE_PARAMETER: { @@ -2565,13 +2572,16 @@ void ETSChecker::AddUndefinedParamsForDefaultParams(const Signature *const signa auto const *const typeAnn = param->Ident()->TypeAnnotation(); if (typeAnn->IsETSPrimitiveType()) { if (typeAnn->AsETSPrimitiveType()->GetPrimitiveType() == ir::PrimitiveType::BOOLEAN) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) arguments.push_back(checker->Allocator()->New(false)); } else { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) arguments.push_back(checker->Allocator()->New(lexer::Number(0))); } } else { // A proxy-function is called, so default reference parameters // are initialized with null instead of undefined + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const nullLiteral = checker->Allocator()->New(); nullLiteral->SetTsType(checker->GlobalETSNullType()); arguments.push_back(nullLiteral); @@ -2579,6 +2589,7 @@ void ETSChecker::AddUndefinedParamsForDefaultParams(const Signature *const signa num |= (1U << (arguments.size() - 1)); } } + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) arguments.push_back(checker->Allocator()->New(lexer::Number(num))); } @@ -2662,10 +2673,12 @@ bool ETSChecker::TryTransformingToStaticInvoke(ir::Identifier *const ident, cons ident->Start()); } // clang-format on - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *classId = AllocNode(className, Allocator()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *methodId = AllocNode(propertyName, Allocator()); auto *transformedCallee = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) AllocNode(classId, methodId, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); classId->SetRange(ident->Range()); @@ -2683,6 +2696,7 @@ bool ETSChecker::TryTransformingToStaticInvoke(ir::Identifier *const ident, cons parser::Program program(Allocator(), VarBinder()); es2panda::CompilerOptions options; auto parser = parser::ETSParser(&program, options, parser::ParserStatus::NO_OPTS); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *argExpr = parser.CreateExpression(implicitInstantiateArgument); compiler::InitScopesPhaseETS::RunExternalNode(argExpr, &program); diff --git a/ets2panda/checker/ets/typeCreation.cpp b/ets2panda/checker/ets/typeCreation.cpp index ea39dcd47c..c1c10fe14e 100644 --- a/ets2panda/checker/ets/typeCreation.cpp +++ b/ets2panda/checker/ets/typeCreation.cpp @@ -389,27 +389,35 @@ ETSEnumType *ETSChecker::CreateETSEnumType(ir::TSEnumDeclaration const *const en auto *const namesArrayIdent = CreateEnumNamesArray(enumType); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto const getNameMethod = CreateEnumGetNameMethod(namesArrayIdent, enumType); enumType->SetGetNameMethod(getNameMethod); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto const valueOfMethod = CreateEnumValueOfMethod(namesArrayIdent, enumType); enumType->SetValueOfMethod(valueOfMethod); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto const fromIntMethod = CreateEnumFromIntMethod(namesArrayIdent, enumType); enumType->SetFromIntMethod(fromIntMethod); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const valuesArrayIdent = CreateEnumValuesArray(enumType); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto const getValueMethod = CreateEnumGetValueMethod(valuesArrayIdent, enumType); enumType->SetGetValueMethod(getValueMethod); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const stringValuesArrayIdent = CreateEnumStringValuesArray(enumType); auto const toStringMethod = CreateEnumToStringMethod(stringValuesArrayIdent, enumType); enumType->SetToStringMethod(toStringMethod); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const itemsArrayIdent = CreateEnumItemsArray(enumType); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto const valuesMethod = CreateEnumValuesMethod(itemsArrayIdent, enumType); enumType->SetValuesMethod(valuesMethod); @@ -444,23 +452,29 @@ ETSStringEnumType *ETSChecker::CreateETSStringEnumType(ir::TSEnumDeclaration con auto *const namesArrayIdent = CreateEnumNamesArray(enumType); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto const getNameMethod = CreateEnumGetNameMethod(namesArrayIdent, enumType); enumType->SetGetNameMethod(getNameMethod); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto const valueOfMethod = CreateEnumValueOfMethod(namesArrayIdent, enumType); enumType->SetValueOfMethod(valueOfMethod); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto const fromIntMethod = CreateEnumFromIntMethod(namesArrayIdent, enumType); enumType->SetFromIntMethod(fromIntMethod); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const stringValuesArrayIdent = CreateEnumStringValuesArray(enumType); auto const toStringMethod = CreateEnumToStringMethod(stringValuesArrayIdent, enumType); enumType->SetToStringMethod(toStringMethod); enumType->SetGetValueMethod(toStringMethod); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const itemsArrayIdent = CreateEnumItemsArray(enumType); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto const valuesMethod = CreateEnumValuesMethod(itemsArrayIdent, enumType); enumType->SetValuesMethod(valuesMethod); -- Gitee From b84161bbe7882b44138090dfcf1906abea8b2379 Mon Sep 17 00:00:00 2001 From: Tatiana Date: Sat, 27 Jan 2024 19:12:31 +0300 Subject: [PATCH 2/2] Add the linter hint Fix the internal issue #14356 Signed-off-by: Tatiana --- ets2panda/checker/ETSchecker.cpp | 3 +++ ets2panda/checker/ETSchecker.h | 1 + ets2panda/checker/ets/dynamic.cpp | 33 ++++++++++++++++++++++++-- ets2panda/checker/ets/enum.cpp | 5 ++++ ets2panda/checker/ets/function.cpp | 29 ++++++++++++++++++++++ ets2panda/checker/ets/helpers.cpp | 6 +++++ ets2panda/checker/ets/object.cpp | 3 +++ ets2panda/checker/ets/typeCreation.cpp | 2 ++ 8 files changed, 80 insertions(+), 2 deletions(-) diff --git a/ets2panda/checker/ETSchecker.cpp b/ets2panda/checker/ETSchecker.cpp index 834464fcb7..4456c8b1bb 100644 --- a/ets2panda/checker/ETSchecker.cpp +++ b/ets2panda/checker/ETSchecker.cpp @@ -106,9 +106,12 @@ bool ETSChecker::StartChecker([[maybe_unused]] varbinder::VarBinder *varbinder, CheckProgram(Program(), true); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) BuildDynamicCallClass(true); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) BuildDynamicCallClass(false); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) BuildDynamicImportClass(); #ifndef NDEBUG diff --git a/ets2panda/checker/ETSchecker.h b/ets2panda/checker/ETSchecker.h index 60b5410d3c..28186c14e5 100644 --- a/ets2panda/checker/ETSchecker.h +++ b/ets2panda/checker/ETSchecker.h @@ -592,6 +592,7 @@ public: template T *AllocNode(Args &&...args) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *ret = Allocator()->New(std::forward(args)...); ret->Iterate([ret](auto *child) { child->SetParent(ret); }); return ret; diff --git a/ets2panda/checker/ets/dynamic.cpp b/ets2panda/checker/ets/dynamic.cpp index 5000097a39..690297cd68 100644 --- a/ets2panda/checker/ets/dynamic.cpp +++ b/ets2panda/checker/ets/dynamic.cpp @@ -99,6 +99,7 @@ ir::ScriptFunction *ETSChecker::CreateDynamicCallIntrinsic(ir::Expression *calle auto dynamicType = GlobalBuiltinDynamicType(lang); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *objParam = AddParam(paramScope, "obj", dynamicType); params.push_back(objParam); info->params.push_back(objParam->Ident()->Variable()->AsLocalVariable()); @@ -119,6 +120,7 @@ ir::ScriptFunction *ETSChecker::CreateDynamicCallIntrinsic(ir::Expression *calle util::UString paramName("p" + std::to_string(i), Allocator()); Type *paramType = arguments[i]->TsType()->IsLambdaObject() ? GlobalBuiltinJSValueType() : arguments[i]->TsType(); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) ir::ETSParameterExpression *param = AddParam(paramScope, paramName.View(), paramType); params.push_back(param); info->params.push_back(param->Ident()->Variable()->AsLocalVariable()); @@ -188,6 +190,7 @@ Signature *ETSChecker::ResolveDynamicCallExpression(ir::Expression *callee, cons auto key = ss.str(); auto it = map.find(util::StringView(key)); if (it == map.end()) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *func = CreateDynamicCallIntrinsic(callee, arguments, lang); map.emplace(util::UString(key, Allocator()).View(), func); return func->Signature(); @@ -229,6 +232,7 @@ std::conditional_t ET // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *body = AllocNode(Allocator(), std::move(statements)); body->SetScope(scope); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) id = AllocNode(compiler::Signatures::CCTOR, Allocator()); func = // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) @@ -240,7 +244,9 @@ std::conditional_t ET builder(scope, &statements, ¶ms); auto *body = AllocNode(Allocator(), std::move(statements)); body->SetScope(scope); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) id = AllocNode(compiler::Signatures::CTOR, Allocator()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) func = AllocNode(ir::FunctionSignature(nullptr, std::move(params), nullptr), body, ir::ScriptFunctionFlags::CONSTRUCTOR | ir::ScriptFunctionFlags::EXPRESSION, ir::ModifierFlags::PUBLIC, false, Language(Language::Id::ETS)); @@ -258,6 +264,7 @@ std::conditional_t ET auto *signature = CreateSignature(signatureInfo, GlobalVoidType(), func); func->SetSignature(signature); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *funcExpr = AllocNode(func); VarBinder()->AsETSBinder()->BuildInternalName(func); @@ -265,12 +272,14 @@ std::conditional_t ET VarBinder()->Functions().push_back(func->Scope()); if constexpr (IS_STATIC) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *staticBlock = AllocNode(funcExpr, Allocator()); staticBlock->AddModifier(ir::ModifierFlags::STATIC); return staticBlock; } else { type->AddConstructSignature(signature); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *ctor = Allocator()->New(ir::MethodDefinitionKind::CONSTRUCTOR, id, funcExpr, ir::ModifierFlags::NONE, Allocator(), false); auto *funcType = CreateETSFunctionType(signature, id->Name()); @@ -284,14 +293,18 @@ std::conditional_t ET ir::ClassStaticBlock *ETSChecker::CreateDynamicCallClassInitializer(varbinder::ClassScope *classScope, Language lang, bool isConstruct) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return CreateClassInitializer( classScope, [this, lang, isConstruct](varbinder::FunctionScope *scope, ArenaVector *statements, [[maybe_unused]] ArenaVector *params) { auto [builtin_class_name, builtin_method_name] = util::Helpers::SplitSignature(isConstruct ? compiler::Signatures::Dynamic::InitNewClassBuiltin(lang) : compiler::Signatures::Dynamic::InitCallClassBuiltin(lang)); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *classId = AllocNode(builtin_class_name, Allocator()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *methodId = AllocNode(builtin_method_name, Allocator()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *callee = AllocNode(classId, methodId, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); @@ -311,9 +324,11 @@ ir::ClassStaticBlock *ETSChecker::CreateDynamicCallClassInitializer(varbinder::C } ss << name << compiler::Signatures::MANGLE_SEPARATOR; + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *className = AllocNode(util::UString(ss.str(), Allocator()).View()); callParams.push_back(className); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *initCall = AllocNode(callee, std::move(callParams), nullptr, false); { @@ -321,18 +336,21 @@ ir::ClassStaticBlock *ETSChecker::CreateDynamicCallClassInitializer(varbinder::C initCall->Check(this); } + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) statements->push_back(AllocNode(initCall)); }); } void ETSChecker::BuildClass(util::StringView name, const ClassBuilder &builder) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *classId = AllocNode(name, Allocator()); auto [decl, var] = VarBinder()->NewVarDecl(classId->Start(), classId->Name()); classId->SetVariable(var); auto classCtx = varbinder::LexicalScope(VarBinder()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *classDef = AllocNode(Allocator(), classId, ir::ClassDefinitionModifiers::DECLARATION, ir::ModifierFlags::NONE, Language(Language::Id::ETS)); classDef->SetScope(classCtx.GetScope()); @@ -379,8 +397,10 @@ void ETSChecker::BuildDynamicCallClass(bool isConstruct) func->Scope()->ParamScope()->SetParent(scope); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *funcExpr = AllocNode(func); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *method = AllocNode(ir::MethodDefinitionKind::METHOD, func->Id(), funcExpr, ir::ModifierFlags::PUBLIC | ir::ModifierFlags::NATIVE | ir::ModifierFlags::STATIC, @@ -519,6 +539,7 @@ ir::MethodDefinition *ETSChecker::CreateClassMethod(varbinder::ClassScope *class ir::MethodDefinition *ETSChecker::CreateDynamicModuleClassInitMethod(varbinder::ClassScope *classScope) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return CreateClassMethod(classScope, compiler::Signatures::DYNAMIC_MODULE_CLASS_INIT, ir::ModifierFlags::PUBLIC | ir::ModifierFlags::STATIC, [this]([[maybe_unused]] varbinder::FunctionScope *scope, @@ -531,6 +552,7 @@ ir::MethodDefinition *ETSChecker::CreateLambdaObjectClassInvokeMethod(varbinder: Signature *invokeSignature, ir::TypeNode *retTypeAnnotation) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return CreateClassMethod( classScope, compiler::Signatures::LAMBDA_OBJECT_INVOKE, ir::ModifierFlags::PUBLIC, [this, classScope, invokeSignature, @@ -538,6 +560,7 @@ ir::MethodDefinition *ETSChecker::CreateLambdaObjectClassInvokeMethod(varbinder: ArenaVector *params, Type **returnType) { util::UString thisParamName(std::string("this"), Allocator()); ir::ETSParameterExpression *thisParam = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) AddParam(scope->Parent()->AsFunctionParamScope(), thisParamName.View(), classScope->Node()->AsClassDeclaration()->Definition()->TsType()->AsETSObjectType()); params->push_back(thisParam); @@ -545,6 +568,7 @@ ir::MethodDefinition *ETSChecker::CreateLambdaObjectClassInvokeMethod(varbinder: ArenaVector callParams(Allocator()->Adapter()); uint32_t idx = 0; for (auto *invokeParam : invokeSignature->Params()) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) ir::ETSParameterExpression *param = AddParam( scope->Parent()->AsFunctionParamScope(), util::UString(std::string("p") + std::to_string(idx), Allocator()).View(), invokeParam->TsType()); @@ -566,8 +590,10 @@ ir::MethodDefinition *ETSChecker::CreateLambdaObjectClassInvokeMethod(varbinder: callLambda->Check(this); } + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *castToRetTypeExpr = Allocator()->New(callLambda, retTypeAnnotation, false); castToRetTypeExpr->SetTsType(invokeSignature->ReturnType()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *retStatement = Allocator()->New(castToRetTypeExpr); statements->push_back(retStatement); @@ -614,6 +640,7 @@ void ETSChecker::BuildDynamicImportClass() } // clang-format off + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) BuildClass(compiler::Signatures::DYNAMIC_MODULE_CLASS, [this, dynamicImports](varbinder::ClassScope *scope, ArenaVector *classBody) { std::unordered_set fields; @@ -636,9 +663,9 @@ void ETSChecker::BuildDynamicImportClass() fields.insert(import->AssemblerName()); imports.push_back(import); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *fieldIdent = AllocNode(import->AssemblerName(), Allocator()); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *field = AllocNode(fieldIdent, nullptr, nullptr, ir::ModifierFlags::STATIC | ir::ModifierFlags::PUBLIC, Allocator(), false); @@ -670,6 +697,7 @@ void ETSChecker::BuildDynamicImportClass() ir::MethodDefinition *ETSChecker::CreateLambdaObjectClassInitializer(varbinder::ClassScope *classScope, ETSObjectType *functionalInterface) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return CreateClassInitializer( classScope, [this, classScope](varbinder::FunctionScope *scope, ArenaVector *statements, @@ -682,6 +710,7 @@ ir::MethodDefinition *ETSChecker::CreateLambdaObjectClassInitializer(varbinder:: util::UString jsvalueParamName(std::string("jsvalue_param"), Allocator()); ir::ETSParameterExpression *jsvalueParam = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) AddParam(scope->Parent()->AsFunctionParamScope(), jsvalueParamName.View(), GlobalBuiltinJSValueType()); params->push_back(jsvalueParam); diff --git a/ets2panda/checker/ets/enum.cpp b/ets2panda/checker/ets/enum.cpp index e832da0332..33ad413317 100644 --- a/ets2panda/checker/ets/enum.cpp +++ b/ets2panda/checker/ets/enum.cpp @@ -229,6 +229,7 @@ void MakeMethodDef(ETSChecker *const checker, varbinder::ETSBinder *const varbin ir::Identifier *ETSChecker::CreateEnumNamesArray(ETSEnumInterface const *const enumType) { // clang-format off + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return MakeArray(this, VarBinder()->AsETSBinder(), enumType, "NamesArray", GlobalBuiltinETSStringType(), [this](const ir::TSEnumMember *const member) { auto *const enumNameStringLiteral = @@ -242,6 +243,7 @@ ir::Identifier *ETSChecker::CreateEnumNamesArray(ETSEnumInterface const *const e ir::Identifier *ETSChecker::CreateEnumValuesArray(ETSEnumType *const enumType) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return MakeArray( this, VarBinder()->AsETSBinder(), enumType, "ValuesArray", GlobalIntType(), [this](const ir::TSEnumMember *const member) { @@ -370,6 +372,7 @@ ETSEnumType::Method ETSChecker::CreateEnumFromIntMethod(ir::Identifier *const na std::move(body), enumTypeAnnotation, enumType->GetDecl()->IsDeclare()); function->AddFlag(ir::ScriptFunctionFlags::THROWS); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const ident = MakeQualifiedIdentifier(Allocator(), enumType->GetDecl(), ETSEnumType::FROM_INT_METHOD_NAME); function->SetIdent(ident); function->Scope()->BindInternalName(ident->Name()); @@ -453,6 +456,7 @@ ETSEnumType::Method ETSChecker::CreateEnumGetValueMethod(ir::Identifier *const v std::move(body), intTypeAnnotation, enumType->GetDecl()->IsDeclare()); auto *const functionIdent = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) MakeQualifiedIdentifier(Allocator(), enumType->GetDecl(), ETSEnumType::GET_VALUE_METHOD_NAME); function->SetIdent(functionIdent); function->Scope()->BindInternalName(functionIdent->Name()); @@ -667,6 +671,7 @@ ETSEnumType::Method ETSChecker::CreateEnumValuesMethod(ir::Identifier *const ite std::move(body), enumArrayTypeAnnotation, enumType->GetDecl()->IsDeclare()); auto *const functionIdent = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) MakeQualifiedIdentifier(Allocator(), enumType->GetDecl(), ETSEnumType::VALUES_METHOD_NAME); function->SetIdent(functionIdent); function->Scope()->BindInternalName(functionIdent->Name()); diff --git a/ets2panda/checker/ets/function.cpp b/ets2panda/checker/ets/function.cpp index f2fab6d86d..179992ab06 100644 --- a/ets2panda/checker/ets/function.cpp +++ b/ets2panda/checker/ets/function.cpp @@ -675,10 +675,12 @@ Signature *ETSChecker::ResolveCallExpressionAndTrailingLambda(ArenaVectorTypeParams(), arguments, pos, "call", TypeRelationFlag::NO_THROW | TypeRelationFlag::NO_CHECK_TRAILING_LAMBDA); if (sig != nullptr) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) TransformTraillingLambda(callExpr); TypeInference(sig, callExpr->Arguments()); return sig; @@ -1387,6 +1389,7 @@ void ETSChecker::CreateFunctionalInterfaceForFunctionType(ir::ETSFunctionType *f auto *interfaceScope = interfaceCtx.GetScope(); ArenaVector members(Allocator()->Adapter()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) ir::MethodDefinition *invokeFunc = CreateInvokeFunction(funcType); members.push_back(invokeFunc); @@ -1423,6 +1426,7 @@ ir::MethodDefinition *ETSChecker::CreateInvokeFunction(ir::ETSFunctionType *func auto *identNode = Allocator()->New(util::StringView("invoke"), Allocator()); ArenaVector params(Allocator()->Adapter()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *funcParamScope = CopyParams(funcType->Params(), params); auto paramCtx = varbinder::LexicalScope::Enter(VarBinder(), funcParamScope, false); @@ -1475,6 +1479,7 @@ void ETSChecker::CreateLambdaObjectForLambdaReference(ir::ArrowFunctionExpressio ArenaVector properties(Allocator()->Adapter()); for (const auto *it : capturedVars) { if (it->HasFlag(varbinder::VariableFlags::LOCAL)) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) properties.push_back(CreateLambdaCapturedField(it, classScope, idx, lambda->Start())); idx++; } else if (!it->HasFlag(varbinder::VariableFlags::STATIC) && @@ -1486,19 +1491,23 @@ void ETSChecker::CreateLambdaObjectForLambdaReference(ir::ArrowFunctionExpressio // If the lambda captured a property in the current class, we have to make a synthetic class property to store // 'this' in it if (saveThis) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) properties.push_back(CreateLambdaCapturedThis(classScope, idx, lambda->Start())); idx++; } // Create the synthetic proxy method node for the current class definiton, which we will use in the lambda // 'invoke' method to propagate the function call to the current class + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *proxyMethod = CreateProxyMethodForLambda(currentClassDef, lambda, properties, !saveThis); // Create the synthetic constructor node for the lambda class, to be able to save captured variables + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *ctor = CreateLambdaImplicitCtor(properties); properties.push_back(ctor); // Create the synthetic invoke node for the lambda class, which will propagate the call to the proxy method + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *invokeFunc = CreateLambdaInvokeProto(); properties.push_back(invokeFunc); @@ -1537,6 +1546,7 @@ void ETSChecker::CreateLambdaObjectForLambdaReference(ir::ArrowFunctionExpressio // Resolve the proxy method ResolveProxyMethod(proxyMethod, lambda); if (lambda->Function()->IsAsyncFunc()) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) ir::MethodDefinition *asyncImpl = CreateAsyncProxy(proxyMethod, currentClassDef); ir::ScriptFunction *asyncImplFunc = asyncImpl->Function(); currentClassDef->Body().push_back(asyncImpl); @@ -1549,6 +1559,7 @@ void ETSChecker::CreateLambdaObjectForLambdaReference(ir::ArrowFunctionExpressio } // Resolve the lambda object + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) ResolveLambdaObject(lambdaObject, functionalInterface, lambda, proxyMethod, saveThis); } @@ -1584,6 +1595,7 @@ void ETSChecker::ResolveLambdaObject(ir::ClassDefinition *lambdaObject, ETSObjec ResolveLambdaObjectCtor(lambdaObject); // Resolve the invoke function + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) ResolveLambdaObjectInvoke(lambdaObject, lambda, proxyMethod, !saveThis); } @@ -1631,6 +1643,7 @@ void ETSChecker::ResolveLambdaObjectInvoke(ir::ClassDefinition *lambdaObject, ir invokeFunc->Id()->Variable()->AsLocalVariable()); // Fill out the type information for the body of the invoke function + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *resolvedLambdaInvokeFunctionBody = ResolveLambdaObjectInvokeFuncBody(lambdaObject, proxyMethod, isStatic); if (invokeFunc->IsAsyncFunc()) { return; @@ -1887,6 +1900,7 @@ ir::MethodDefinition *ETSChecker::CreateProxyMethodForLambda(ir::ClassDefinition ir::ArrowFunctionExpression *lambda, ArenaVector &captured, bool isStatic) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *func = CreateProxyFunc(lambda, captured, isStatic); // Create the synthetic proxy method @@ -2120,6 +2134,7 @@ ir::MethodDefinition *ETSChecker::CreateLambdaImplicitCtor(ArenaVector params(Allocator()->Adapter()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *funcParamScope = CreateLambdaCtorImplicitParams(params, properties); // Create the scopes for the synthetic constructor node @@ -2132,6 +2147,7 @@ ir::MethodDefinition *ETSChecker::CreateLambdaImplicitCtor(ArenaVector statements(Allocator()->Adapter()); for (auto *it : properties) { auto *field = it->AsClassProperty()->Key()->AsIdentifier(); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) statements.push_back(CreateLambdaCtorFieldInit(field->Name(), field->Variable())); } @@ -2239,6 +2255,7 @@ void ETSChecker::CreateLambdaObjectForFunctionReference(ir::AstNode *refNode, Si // Create the synthetic constructor node, where we will initialize the synthetic field (if present) to the // instance object + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *ctor = CreateLambdaImplicitCtor(refNode->Range(), isStaticReference); properties.push_back(ctor); @@ -2269,6 +2286,7 @@ void ETSChecker::CreateLambdaObjectForFunctionReference(ir::AstNode *refNode, Si VarBinder()->AsETSBinder()->BuildLambdaObject(refNode, lambdaObject, signature); // Resolve the lambda object + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) ResolveLambdaObject(lambdaObject, signature, functionalInterface, refNode); } @@ -2298,6 +2316,7 @@ ir::MethodDefinition *ETSChecker::CreateLambdaImplicitCtor(const lexer::SourceRa ArenaVector statements(Allocator()->Adapter()); // Create the parameters for the synthetic constructor + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto [funcParamScope, var] = CreateLambdaCtorImplicitParam(params, pos, isStaticReference); // Create the scopes @@ -2308,6 +2327,7 @@ ir::MethodDefinition *ETSChecker::CreateLambdaImplicitCtor(const lexer::SourceRa // If the reference refers to a static function, the constructor will be empty, otherwise, we have to make a // synthetic initializer to initialize the lambda class field if (!isStaticReference) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) statements.push_back(CreateLambdaCtorFieldInit(util::StringView("field0"), var)); } @@ -2459,6 +2479,7 @@ void ETSChecker::ResolveLambdaObject(ir::ClassDefinition *lambdaObject, Signatur ResolveLambdaObjectCtor(lambdaObject, isStaticReference); // Resolve the invoke function + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) ResolveLambdaObjectInvoke(lambdaObject, signature); } @@ -2568,6 +2589,7 @@ void ETSChecker::ResolveLambdaObjectInvoke(ir::ClassDefinition *lambdaObject, Si // Fill out the type information for the body of the invoke function + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *resolvedLambdaInvokeFunctionBody = ResolveLambdaObjectInvokeFuncBody(lambdaObject, signatureRef); invokeFunc->Body()->AsBlockStatement()->Statements().push_back(resolvedLambdaInvokeFunctionBody); @@ -2699,6 +2721,7 @@ ir::MethodDefinition *ETSChecker::CreateAsyncImplMethod(ir::MethodDefinition *as varbinder::LexicalScope::Enter(VarBinder(), classDef->Scope()->AsClassScope()); auto *body = asyncFunc->Body(); ArenaVector params(Allocator()->Adapter()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) varbinder::FunctionParamScope *paramScope = CopyParams(asyncFunc->Params(), params); // Set impl method return type "Object" because it may return Promise as well as Promise parameter's type @@ -2724,6 +2747,7 @@ ir::MethodDefinition *ETSChecker::CreateAsyncImplMethod(ir::MethodDefinition *as returnTypeAnn->SetTsType(retType); ir::MethodDefinition *implMethod = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) CreateMethod(implName.View(), modifiers, flags, std::move(params), paramScope, returnTypeAnn, body); asyncFunc->SetBody(nullptr); returnTypeAnn->SetParent(implMethod->Function()); @@ -2739,6 +2763,7 @@ ir::MethodDefinition *ETSChecker::CreateAsyncProxy(ir::MethodDefinition *asyncMe ir::ScriptFunction *asyncFunc = asyncMethod->Function(); VarBinder()->AsETSBinder()->GetRecordTable()->Signatures().push_back(asyncFunc->Scope()); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) ir::MethodDefinition *implMethod = CreateAsyncImplMethod(asyncMethod, classDef); varbinder::FunctionScope *implFuncScope = implMethod->Function()->Scope(); for (auto *decl : asyncFunc->Scope()->Decls()) { @@ -2814,6 +2839,7 @@ varbinder::FunctionParamScope *ETSChecker::CopyParams(const ArenaVectorAsETSParameterExpression(); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const paramNew = paramOld->Clone(Allocator(), paramOld->Parent())->AsETSParameterExpression(); auto *const var = std::get<1>(VarBinder()->AddParamDecl(paramNew)); @@ -2890,6 +2916,7 @@ void ETSChecker::TransformTraillingLambda(ir::CallExpression *callExpr) ArenaVector params(Allocator()->Adapter()); auto *funcNode = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) AllocNode(ir::FunctionSignature(nullptr, std::move(params), nullptr), trailingBlock, ir::ScriptFunctionFlags::ARROW, false, Language(Language::Id::ETS)); funcNode->SetScope(funcScope); @@ -2900,6 +2927,7 @@ void ETSChecker::TransformTraillingLambda(ir::CallExpression *callExpr) ReplaceScope(funcNode->Body(), trailingBlock, funcScope); callExpr->SetTrailingBlock(nullptr); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *arrowFuncNode = AllocNode(Allocator(), funcNode); arrowFuncNode->SetRange(trailingBlock->Range()); arrowFuncNode->SetParent(callExpr); @@ -2917,6 +2945,7 @@ ArenaVector ETSChecker::ExtendArgumentsWithFakeLamda(ir::CallE auto *body = AllocNode(Allocator(), std::move(statements)); body->SetScope(funcScope); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *funcNode = AllocNode(ir::FunctionSignature(nullptr, std::move(params), nullptr), body, ir::ScriptFunctionFlags::ARROW, false, Language(Language::Id::ETS)); funcNode->SetScope(funcScope); diff --git a/ets2panda/checker/ets/helpers.cpp b/ets2panda/checker/ets/helpers.cpp index b80631d78d..12032d47eb 100644 --- a/ets2panda/checker/ets/helpers.cpp +++ b/ets2panda/checker/ets/helpers.cpp @@ -707,6 +707,7 @@ Type *ETSChecker::ResolveIdentifier(ir::Identifier *const ident) resolved = FindVariableInGlobal(ident); } + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) ValidateResolvedIdentifier(ident, resolved); if (resolved->HasFlag(varbinder::VariableFlags::METHOD)) { @@ -1241,6 +1242,7 @@ Type *ETSChecker::GetTypeFromClassReference(varbinder::Variable *var) void ETSChecker::ValidateGenericTypeAliasForClonedNode(ir::TSTypeAliasDeclaration *const typeAliasNode, const ir::TSTypeParameterInstantiation *const exactTypeParams) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const clonedNode = typeAliasNode->TypeAnnotation()->Clone(Allocator(), typeAliasNode); // Basic check, we really don't want to change the original type nodes, more precise checking should be made @@ -1304,6 +1306,7 @@ Type *ETSChecker::HandleTypeAlias(ir::Expression *const name, const ir::TSTypePa } if (typeParams == nullptr) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return GetReferencedTypeBase(name); } @@ -1311,6 +1314,7 @@ Type *ETSChecker::HandleTypeAlias(ir::Expression *const name, const ir::TSTypePa origTypeParam->Check(this); } + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) Type *const aliasType = GetReferencedTypeBase(name); auto *const aliasSub = NewSubstitution(); @@ -1325,6 +1329,7 @@ Type *ETSChecker::HandleTypeAlias(ir::Expression *const name, const ir::TSTypePa } } + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) ValidateGenericTypeAliasForClonedNode(typeAliasNode->AsTSTypeAliasDeclaration(), typeParams); return aliasType->Substitute(Relation(), aliasSub); @@ -1341,6 +1346,7 @@ Type *ETSChecker::GetTypeFromEnumReference([[maybe_unused]] varbinder::Variable // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return CreateETSEnumType(enumDecl); } else if (itemInit->IsStringLiteral()) { // NOLINT(readability-else-after-return) + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return CreateETSStringEnumType(enumDecl); } else { // NOLINT(readability-else-after-return) ThrowTypeError("Invalid enumeration value type.", enumDecl->Start()); diff --git a/ets2panda/checker/ets/object.cpp b/ets2panda/checker/ets/object.cpp index 6fbf90b9fc..727917c24f 100644 --- a/ets2panda/checker/ets/object.cpp +++ b/ets2panda/checker/ets/object.cpp @@ -799,6 +799,7 @@ void ETSChecker::CheckClassDefinition(ir::ClassDefinition *classDef) it->Check(this); } } + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) CreateAsyncProxyMethods(classDef); if (classDef->IsGlobal()) { @@ -834,9 +835,11 @@ void ETSChecker::CreateAsyncProxyMethods(ir::ClassDefinition *classDef) for (auto *it : classDef->Body()) { if (IsAsyncMethod(it)) { auto *method = it->AsMethodDefinition(); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) asyncImpls.push_back(CreateAsyncProxy(method, classDef)); auto *proxy = asyncImpls.back(); for (auto *overload : method->Overloads()) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *impl = CreateAsyncProxy(overload, classDef, false); impl->Function()->Id()->SetVariable(proxy->Function()->Id()->Variable()); proxy->AddOverload(impl); diff --git a/ets2panda/checker/ets/typeCreation.cpp b/ets2panda/checker/ets/typeCreation.cpp index c1c10fe14e..c66d10502d 100644 --- a/ets2panda/checker/ets/typeCreation.cpp +++ b/ets2panda/checker/ets/typeCreation.cpp @@ -387,6 +387,7 @@ ETSEnumType *ETSChecker::CreateETSEnumType(ir::TSEnumDeclaration const *const en memberVar->SetTsType(enumLiteralType); } + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const namesArrayIdent = CreateEnumNamesArray(enumType); // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) @@ -411,6 +412,7 @@ ETSEnumType *ETSChecker::CreateETSEnumType(ir::TSEnumDeclaration const *const en // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const stringValuesArrayIdent = CreateEnumStringValuesArray(enumType); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto const toStringMethod = CreateEnumToStringMethod(stringValuesArrayIdent, enumType); enumType->SetToStringMethod(toStringMethod); -- Gitee