From a6e7cc39efcc000947df842cb138eecb66c55b47 Mon Sep 17 00:00:00 2001 From: lirismankarina Date: Mon, 30 Jun 2025 19:43:56 +0300 Subject: [PATCH] Fix codecheck MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue: [新需求]: codecheck fix https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICIYSG Description: some code style fixes for frontend Reason: clear code style needed Tests: all tests passed Signed-off-by: lirismankarina --- .../ets/constantExpressionLowering.cpp | 3 +++ .../lowering/ets/declareOverloadLowering.cpp | 2 ++ ...defaultParametersInConstructorLowering.cpp | 15 +++++++++---- .../compiler/lowering/ets/enumLowering.cpp | 7 ++++++ .../lowering/ets/exportAnonymousConst.cpp | 1 + .../lowering/ets/expressionLambdaLowering.cpp | 1 + .../lowering/ets/genericBridgesLowering.cpp | 8 +++++-- .../ets/interfaceObjectLiteralLowering.cpp | 11 +++++++--- .../ets/interfacePropertyDeclarations.cpp | 1 + .../compiler/lowering/ets/lambdaLowering.cpp | 22 ++++++++++++++++--- .../lowering/ets/lateInitialization.cpp | 2 ++ ets2panda/ir/ets/etsClassLiteral.cpp | 1 + ets2panda/ir/ets/etsFunctionType.cpp | 1 + ets2panda/ir/ets/etsKeyofType.cpp | 2 ++ ets2panda/ir/ets/etsNeverType.cpp | 1 + .../ir/ets/etsNewArrayInstanceExpression.cpp | 1 + .../ir/ets/etsNewClassInstanceExpression.cpp | 1 + .../etsNewMultiDimArrayInstanceExpression.cpp | 1 + ets2panda/ir/ets/etsNonNullishTypeNode.cpp | 1 + ets2panda/ir/ets/etsNullishTypes.cpp | 2 ++ ets2panda/ir/ets/etsPackageDeclaration.cpp | 1 + ets2panda/ir/ets/etsParameterExpression.cpp | 1 + ets2panda/ir/ets/etsParameterExpression.h | 1 + ets2panda/ir/ets/etsPrimitiveType.cpp | 1 + ets2panda/ir/ets/etsStringLiteralType.cpp | 1 + ets2panda/ir/ets/etsTuple.cpp | 2 ++ ets2panda/ir/ets/etsTypeReferencePart.cpp | 1 + ets2panda/ir/ets/etsUnionType.cpp | 1 + ets2panda/ir/expressions/arrayExpression.cpp | 3 +++ .../expressions/arrowFunctionExpression.cpp | 3 +++ .../ir/expressions/assignmentExpression.cpp | 1 + ets2panda/ir/expressions/awaitExpression.cpp | 1 + ets2panda/ir/expressions/binaryExpression.cpp | 1 + ets2panda/ir/expressions/binaryExpression.h | 2 ++ ets2panda/ir/expressions/blockExpression.cpp | 1 + 35 files changed, 93 insertions(+), 12 deletions(-) diff --git a/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp b/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp index de86a2313a..96da74bb4b 100644 --- a/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp +++ b/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp @@ -346,6 +346,7 @@ ir::AstNode *ConstantExpressionLowering::FoldBinaryBooleanConstant(ir::BinaryExp } auto resNode = util::NodeAllocator::Alloc(context_->allocator, result); + ES2PANDA_ASSERT(resNode); resNode->SetParent(expr->Parent()); resNode->SetRange(expr->Range()); return resNode; @@ -545,6 +546,7 @@ ir::AstNode *ConstantExpressionLowering::FoldBinaryStringConstant(ir::BinaryExpr auto const rhs = expr->Right()->AsLiteral(); auto const resStr = util::UString(lhs->ToString() + rhs->ToString(), context_->allocator).View(); auto resNode = util::NodeAllocator::Alloc(context_->allocator, resStr); + ES2PANDA_ASSERT(resNode); resNode->SetParent(expr->Parent()); resNode->SetRange(expr->Range()); return resNode; @@ -758,6 +760,7 @@ ir::AstNode *ConstantExpressionLowering::FoldTSAsExpression(ir::TSAsExpression * ir::AstNode *ConstantExpressionLowering::FoldMultilineString(ir::TemplateLiteral *expr) { auto *result = util::NodeAllocator::Alloc(context_->allocator, expr->GetMultilineString()); + ES2PANDA_ASSERT(result); result->SetParent(expr->Parent()); result->SetRange(expr->Range()); return result; diff --git a/ets2panda/compiler/lowering/ets/declareOverloadLowering.cpp b/ets2panda/compiler/lowering/ets/declareOverloadLowering.cpp index 613fcf10d2..1acc1c8299 100644 --- a/ets2panda/compiler/lowering/ets/declareOverloadLowering.cpp +++ b/ets2panda/compiler/lowering/ets/declareOverloadLowering.cpp @@ -34,6 +34,7 @@ void GenerateOverloadHelperParams(public_lib::Context *ctx, uint32_t minArg, siz id->SetTsTypeAnnotation(typeAnnotation); typeAnnotation->SetParent(id); auto *param = ctx->AllocNode(id, false, allocator); + ES2PANDA_ASSERT(param); param->SetOptional(idx >= minArg); params.push_back(param); } @@ -84,6 +85,7 @@ void BuildOverloadHelperFunction(public_lib::Context *ctx, ir::MethodDefinition method->Modifiers(), allocator, false); method->AddOverload(helperOverload); + ES2PANDA_ASSERT(helperOverload->Function()); helperOverload->Function()->ClearFlag((ir::ScriptFunctionFlags::OVERLOAD)); helperOverload->SetParent(method); diff --git a/ets2panda/compiler/lowering/ets/defaultParametersInConstructorLowering.cpp b/ets2panda/compiler/lowering/ets/defaultParametersInConstructorLowering.cpp index d9ede70dc7..383b70b3cd 100644 --- a/ets2panda/compiler/lowering/ets/defaultParametersInConstructorLowering.cpp +++ b/ets2panda/compiler/lowering/ets/defaultParametersInConstructorLowering.cpp @@ -63,7 +63,8 @@ static bool HasDefaultParameters(const ir::ScriptFunction *function, util::Diagn static ir::TSTypeParameterDeclaration *CreateParameterDeclaraion(ir::MethodDefinition *method, public_lib::Context *ctx) { auto const allocator = ctx->allocator; - if (method->Function()->TypeParams() == nullptr || method->Function()->TypeParams()->Params().empty()) { + if ((method->Function() != nullptr && method->Function()->TypeParams() == nullptr) || + method->Function()->TypeParams()->Params().empty()) { return nullptr; } @@ -90,6 +91,7 @@ static ir::FunctionSignature CreateFunctionSignature(ir::MethodDefinition *metho auto const allocator = ctx->allocator; ir::TSTypeParameterDeclaration *typeParamDecl = CreateParameterDeclaraion(method, ctx); + ES2PANDA_ASSERT(method->Function()); auto *returnTypeAnnotation = method->Function()->ReturnTypeAnnotation() != nullptr ? method->Function()->ReturnTypeAnnotation()->Clone(allocator, nullptr)->AsTypeNode() @@ -103,7 +105,8 @@ static ir::TSTypeParameterInstantiation *CreateTypeParameterInstantiation(ir::Me { auto const allocator = ctx->allocator; - if (method->Function()->TypeParams() == nullptr || method->Function()->TypeParams()->Params().empty()) { + if ((method->Function() != nullptr && method->Function()->TypeParams() == nullptr) || + method->Function()->TypeParams()->Params().empty()) { return nullptr; } ArenaVector selfParams(allocator->Adapter()); @@ -131,6 +134,7 @@ static ir::BlockStatement *CreateFunctionBody(ir::MethodDefinition *method, publ auto const allocator = ctx->allocator; ArenaVector funcStatements(allocator->Adapter()); + ES2PANDA_ASSERT(method->Id()); auto *const callee = util::NodeAllocator::ForceSetParent(allocator, method->Id()->Name(), allocator); @@ -163,6 +167,7 @@ static ir::FunctionExpression *CreateFunctionExpression(ir::MethodDefinition *me allocator, allocator, ir::ScriptFunction::ScriptFunctionData { body, std::move(signature), method->Function()->Flags(), {}, method->Function()->Language()}); + ES2PANDA_ASSERT(method->Function()); funcNode->AddModifier(method->Function()->Modifiers()); funcNode->SetRange({startLoc, endLoc}); @@ -184,7 +189,7 @@ static void CreateFunctionOverload(ir::MethodDefinition *method, ArenaVectorFunction()->AddFlag(ir::ScriptFunctionFlags::OVERLOAD); overloadMethod->SetRange(funcExpression->Range()); - if (!method->IsDeclare() && method->Parent()->IsTSInterfaceBody()) { + if (!method->IsDeclare() && method->Parent()->IsTSInterfaceBody() && (overloadMethod->Function() != nullptr)) { overloadMethod->Function()->Body()->AsBlockStatement()->Statements().clear(); } @@ -195,6 +200,7 @@ static void CreateFunctionOverload(ir::MethodDefinition *method, ArenaVectorallocator; for (auto p : function->Params()) { @@ -219,6 +225,7 @@ static void ClearOptionalParameters(public_lib::Context *ctx, ir::ScriptFunction if (oldParam->IsOptional()) { param = util::NodeAllocator::ForceSetParent(allocator, oldParam->Ident(), false, allocator); + ES2PANDA_ASSERT(param); param->SetParent(function); } ES2PANDA_ASSERT(!param->AsETSParameterExpression()->IsOptional()); @@ -245,7 +252,7 @@ static void ProcessGlobalFunctionDefinition(ir::MethodDefinition *method, public for (size_t i = 0; i < params.size() - paramsToCut; ++i) { auto param = params[i]->AsETSParameterExpression(); callArgs.push_back(param->Ident()->CloneReference(allocator, nullptr)->AsIdentifier()); - + ES2PANDA_ASSERT(param->Ident()->Clone(allocator, nullptr)); functionParams.push_back(allocator->New( param->Ident()->Clone(allocator, nullptr)->AsIdentifier(), false, allocator)); } diff --git a/ets2panda/compiler/lowering/ets/enumLowering.cpp b/ets2panda/compiler/lowering/ets/enumLowering.cpp index f13666933d..5212c1dc3a 100644 --- a/ets2panda/compiler/lowering/ets/enumLowering.cpp +++ b/ets2panda/compiler/lowering/ets/enumLowering.cpp @@ -39,6 +39,7 @@ namespace { [[nodiscard]] ir::Identifier *MakeParamRefIdent(public_lib::Context *ctx, ir::ETSParameterExpression *paramExpr) { auto *const refIdent = ctx->AllocNode(paramExpr->Ident()->Name(), ctx->Allocator()); + ES2PANDA_ASSERT(refIdent); refIdent->SetRange(paramExpr->Ident()->Range()); refIdent->SetVariable(paramExpr->Ident()->Variable()); return refIdent; @@ -413,13 +414,17 @@ void EnumLoweringPhase::ProcessEnumClassDeclaration(ir::TSEnumDeclaration *const auto *ident = enumClassDecl->Definition()->Ident(); if (flags.isLocal) { auto *scope = NearestScope(enumDecl->Parent()); + ES2PANDA_ASSERT(scope); auto localCtx = varbinder::LexicalScope::Enter(varbinder_, scope); + ES2PANDA_ASSERT(scope); scope->EraseBinding(ident->Name()); InitScopesPhaseETS::RunExternalNode(enumClassDecl, varbinder_); var = varbinder_->GetScope()->FindLocal(ident->Name(), varbinder::ResolveBindingOptions::ALL); } else if (flags.isTopLevel) { auto *scope = program_->GlobalClassScope(); + ES2PANDA_ASSERT(scope); auto localCtx = varbinder::LexicalScope::Enter(varbinder_, scope); + ES2PANDA_ASSERT(scope); scope->StaticDeclScope()->EraseBinding(ident->Name()); InitScopesPhaseETS::RunExternalNode(enumClassDecl, varbinder_); var = varbinder_->GetScope()->FindLocal(ident->Name(), varbinder::ResolveBindingOptions::ALL); @@ -791,11 +796,13 @@ ir::VariableDeclaration *CreateForLoopInitVariableDeclaration(public_lib::Contex { auto *const init = ctx->AllocNode("0"); auto *const decl = ctx->AllocNode(ir::VariableDeclaratorFlag::LET, loopIdentifier, init); + ES2PANDA_ASSERT(loopIdentifier); loopIdentifier->SetParent(decl); ArenaVector decls(ctx->Allocator()->Adapter()); decls.push_back(decl); auto *const declaration = ctx->AllocNode( ir::VariableDeclaration::VariableDeclarationKind::LET, ctx->Allocator(), std::move(decls)); + ES2PANDA_ASSERT(decl); decl->SetParent(declaration); return declaration; } diff --git a/ets2panda/compiler/lowering/ets/exportAnonymousConst.cpp b/ets2panda/compiler/lowering/ets/exportAnonymousConst.cpp index 3cb3fd1c24..029659c547 100644 --- a/ets2panda/compiler/lowering/ets/exportAnonymousConst.cpp +++ b/ets2panda/compiler/lowering/ets/exportAnonymousConst.cpp @@ -103,6 +103,7 @@ static void HandleExportDefaultInExportNamedDecl(public_lib::Context *const ctx, exports.emplace_back(specifier); auto *exportDefaulNamedDecl = allocator->New( allocator, static_cast(nullptr), std::move(exports)); + ES2PANDA_ASSERT(exportDefaulNamedDecl); exportDefaulNamedDecl->AddModifier(ir::ModifierFlags::DEFAULT_EXPORT); exportDefaulNamedDeclarations.push_back(exportDefaulNamedDecl); continue; diff --git a/ets2panda/compiler/lowering/ets/expressionLambdaLowering.cpp b/ets2panda/compiler/lowering/ets/expressionLambdaLowering.cpp index 7d4112c7f6..e09b2b2af2 100644 --- a/ets2panda/compiler/lowering/ets/expressionLambdaLowering.cpp +++ b/ets2panda/compiler/lowering/ets/expressionLambdaLowering.cpp @@ -37,6 +37,7 @@ static ir::AstNode *ConvertExpression(public_lib::Context *ctx, ir::ArrowFunctio auto *const block = ctx->AllocNode(allocator, std::move(statements)); + ES2PANDA_ASSERT(block); block->SetScope(scope); block->SetParent(function); diff --git a/ets2panda/compiler/lowering/ets/genericBridgesLowering.cpp b/ets2panda/compiler/lowering/ets/genericBridgesLowering.cpp index 36ce44662c..0e4414bb3d 100644 --- a/ets2panda/compiler/lowering/ets/genericBridgesLowering.cpp +++ b/ets2panda/compiler/lowering/ets/genericBridgesLowering.cpp @@ -86,6 +86,7 @@ void GenericBridgesPhase::AddGenericBridge(ir::ClassDefinition const *const clas auto *const bridgeMethod = parser->CreateFormattedClassMethodDefinition(sourceCode, typeNodes)->AsMethodDefinition(); + ES2PANDA_ASSERT(bridgeMethod); bridgeMethod->AddModifier(methodDefinition->Modifiers()); bridgeMethod->ClearModifier(ir::ModifierFlags::NATIVE | ir::ModifierFlags::ABSTRACT); bridgeMethod->AddAstNodeFlags(methodDefinition->GetAstNodeFlags()); @@ -143,6 +144,7 @@ void GenericBridgesPhase::ProcessScriptFunction(ir::ClassDefinition const *const // We are not interested in functions that either don't have type parameters at all // or have type parameters that are not modified in the derived class + ES2PANDA_ASSERT(baseFunction); auto const *baseSignature1 = baseFunction->Signature()->Substitute(relation, substitutions.baseConstraints); if (baseSignature1 == baseFunction->Signature()) { return; @@ -215,7 +217,8 @@ void GenericBridgesPhase::CreateGenericBridges(ir::ClassDefinition const *const // Skip `static`, `final` and special methods... auto *const method = item->AsMethodDefinition(); if (method->Kind() != ir::MethodDefinitionKind::METHOD || method->IsStatic() || method->IsFinal() || - method->Id()->Name().Utf8().find("lambda$invoke$") != std::string_view::npos) { + (method->Id() != nullptr && + method->Id()->Name().Utf8().find("lambda$invoke$") != std::string_view::npos)) { continue; } @@ -272,7 +275,7 @@ void GenericBridgesPhase::ProcessInterfaces(ir::ClassDefinition *const classDefi !typeParameters.empty()) { if (Substitutions substitutions = GetSubstitutions(interfaceType, typeParameters); // NOLINTNEXTLINE(clang-analyzer-core.CallAndMessage) - !substitutions.derivedSubstitutions->empty()) { + (substitutions.derivedSubstitutions != nullptr) && !substitutions.derivedSubstitutions->empty()) { ES2PANDA_ASSERT(interfaceType->GetDeclNode()->IsTSInterfaceDeclaration()); auto const &interfaceBody = interfaceType->GetDeclNode()->AsTSInterfaceDeclaration()->Body()->Body(); CreateGenericBridges(classDefinition, substitutions, interfaceBody); @@ -303,6 +306,7 @@ ir::ClassDefinition *GenericBridgesPhase::ProcessClassDefinition(ir::ClassDefini // Check if the class derived from base generic class has either explicit class type substitutions // or type parameters with narrowing constraints. if (Substitutions substitutions = GetSubstitutions(superType, typeParameters); + (substitutions.derivedSubstitutions != nullptr) && // NOLINTNEXTLINE(clang-analyzer-core.CallAndMessage) !substitutions.derivedSubstitutions->empty()) { // If it has, then probably the generic bridges should be created. diff --git a/ets2panda/compiler/lowering/ets/interfaceObjectLiteralLowering.cpp b/ets2panda/compiler/lowering/ets/interfaceObjectLiteralLowering.cpp index 7b00e071ae..cdbb0350fa 100644 --- a/ets2panda/compiler/lowering/ets/interfaceObjectLiteralLowering.cpp +++ b/ets2panda/compiler/lowering/ets/interfaceObjectLiteralLowering.cpp @@ -72,6 +72,7 @@ static ir::ClassProperty *CreateAnonClassField(public_lib::Context *ctx, ir::Met { auto *const parser = ctx->parser->AsETSParser(); // Field type annotation + ES2PANDA_ASSERT(ifaceMethod->Function()); auto *fieldType = ifaceMethod->Function()->Signature()->ReturnType(); std::stringstream sourceCode; @@ -105,7 +106,7 @@ static ir::MethodDefinition *CreateAnonClassFieldGetterSetter(public_lib::Contex sourceCode << "public set @@I1 (anonParam:@@T2){" << std::endl; sourceCode << "this.@@I3 = anonParam" << std::endl; sourceCode << "}" << std::endl; - + ES2PANDA_ASSERT(ifaceMethod->Id()); return parser ->CreateFormattedClassMethodDefinition(sourceCode.str(), ifaceMethod->Id()->Name(), fieldType, anonClassFieldName) @@ -131,7 +132,7 @@ static void FillClassBody(public_lib::Context *ctx, ArenaVector * ES2PANDA_ASSERT(it->IsMethodDefinition()); auto *ifaceMethod = it->AsMethodDefinition(); - if (!ifaceMethod->Function()->IsGetter()) { + if (ifaceMethod->Function() != nullptr && !ifaceMethod->Function()->IsGetter()) { continue; } @@ -201,6 +202,7 @@ static void AnnotateGeneratedAnonClass(checker::ETSChecker *checker, ir::ClassDe checker->ProgramAllocNode(Signatures::INTERFACE_OBJ_LITERAL, checker->ProgramAllocator()); annoId->SetAnnotationUsage(); auto *annoUsage = checker->ProgramAllocNode(annoId, checker->ProgramAllocator()); + ES2PANDA_ASSERT(annoUsage); annoUsage->AddModifier(ir::ModifierFlags::ANNOTATION_USAGE); annoUsage->SetParent(classDef); annoId->SetParent(annoUsage); @@ -254,6 +256,7 @@ static void GenerateAnonClassTypeFromInterface(public_lib::Context *ctx, ir::TSI // Class implements auto *classImplements = ctx->AllocNode( ctx->AllocNode(ifaceNode->TsType(), ctx->Allocator())); + ES2PANDA_ASSERT(classImplements); classImplements->SetParent(classDef); classDef->Implements().emplace_back(classImplements); classType->RemoveObjectFlag(checker::ETSObjectFlags::RESOLVED_INTERFACES); @@ -331,6 +334,7 @@ static checker::Type *ProcessDeclNode(checker::ETSChecker *checker, checker::ETS continue; } + ES2PANDA_ASSERT(it->AsMethodDefinition()->Id()); checker->LogError(diagnostic::ABSTRACT_METH_IN_ABSTRACT_CLASS, {it->AsMethodDefinition()->Id()->Name()}, objExpr->Start()); return checker->GlobalTypeError(); @@ -379,7 +383,8 @@ static bool CheckInterfaceShouldGenerateAnonClass(ir::TSInterfaceDeclaration *in for (auto it : interfaceDecl->Body()->Body()) { ES2PANDA_ASSERT(it->IsMethodDefinition()); auto methodDef = it->AsMethodDefinition(); - if (!methodDef->Function()->IsGetter() && !methodDef->Function()->IsSetter()) { + if (methodDef->Function() != nullptr && !methodDef->Function()->IsGetter() && + !methodDef->Function()->IsSetter()) { return false; } } diff --git a/ets2panda/compiler/lowering/ets/interfacePropertyDeclarations.cpp b/ets2panda/compiler/lowering/ets/interfacePropertyDeclarations.cpp index c997421bf4..f9832dc3c3 100644 --- a/ets2panda/compiler/lowering/ets/interfacePropertyDeclarations.cpp +++ b/ets2panda/compiler/lowering/ets/interfacePropertyDeclarations.cpp @@ -191,6 +191,7 @@ static void AddOverload(ir::MethodDefinition *method, ir::MethodDefinition *over { method->AddOverload(overload); overload->SetParent(method); + ES2PANDA_ASSERT(overload->Function()); overload->Function()->AddFlag(ir::ScriptFunctionFlags::OVERLOAD); overload->Function()->Id()->SetVariable(variable); } diff --git a/ets2panda/compiler/lowering/ets/lambdaLowering.cpp b/ets2panda/compiler/lowering/ets/lambdaLowering.cpp index df7f1a1a0b..3164100516 100644 --- a/ets2panda/compiler/lowering/ets/lambdaLowering.cpp +++ b/ets2panda/compiler/lowering/ets/lambdaLowering.cpp @@ -112,6 +112,7 @@ static std::pair Clon auto *newTypeParamNode = util::NodeAllocator::ForceSetParent(allocator, newTypeParamId, nullptr, nullptr, allocator); auto *newTypeParam = allocator->New(); + ES2PANDA_ASSERT(newTypeParam); newTypeParam->SetDeclNode(newTypeParamNode); auto *newTypeParamDecl = allocator->New(newTypeParamId->Name()); @@ -186,6 +187,7 @@ ParamsAndVarMap CreateLambdaCalleeParameters(public_lib::Context *ctx, ir::Arrow auto *oldParamType = oldParam->AsETSParameterExpression()->Ident()->TsType(); auto *newParamType = oldParamType->Substitute(checker->Relation(), substitution); auto *newParam = oldParam->AsETSParameterExpression()->Clone(allocator, nullptr); + ES2PANDA_ASSERT(newParam); if (newParam->IsOptional()) { newParam->SetOptional(false); newParamType = checker->CreateETSUnionType({newParamType, checker->GlobalETSUndefinedType()}); @@ -287,6 +289,7 @@ static ir::MethodDefinition *SetUpCalleeMethod(public_lib::Context *ctx, LambdaI var->AddFlag(varbinder::VariableFlags::METHOD); var->SetScope(scopeForMethod); func->Id()->SetVariable(var); + ES2PANDA_ASSERT(method->Id()); method->Id()->SetVariable(var); if (info->callReceiver != nullptr) { auto paramScopeCtx = varbinder::LexicalScope::Enter(varBinder, paramScope); @@ -309,6 +312,7 @@ static ir::MethodDefinition *SetUpCalleeMethod(public_lib::Context *ctx, LambdaI } using ISS = ir::ScriptFunction::ScriptFunctionData; +// CC-OFFNXT(huge_method[C++], huge_method) solid logic static ir::MethodDefinition *CreateCalleeMethod(public_lib::Context *ctx, ir::ArrowFunctionExpression *lambda, LambdaInfo const *info, CalleeMethodInfo const *cmInfo) { @@ -351,6 +355,7 @@ static ir::MethodDefinition *CreateCalleeMethod(public_lib::Context *ctx, ir::Ar funcFlags, modifierFlags}); auto *funcScope = cmInfo->body == nullptr ? allocator->New(allocator, paramScope) : cmInfo->body->Scope()->AsFunctionScope(); + ES2PANDA_ASSERT(funcScope); funcScope->BindName(info->calleeClass->Definition()->TsType()->AsETSObjectType()->AssemblerName()); func->SetScope(funcScope); ProcessCalleeMethodBody(cmInfo->body, checker, paramScope, substitution, varMap); @@ -485,6 +490,7 @@ static void CreateLambdaClassConstructor(public_lib::Context *ctx, ir::ClassDefi ir::ScriptFunction::ScriptFunctionData {body, ir::FunctionSignature(nullptr, std::move(params), nullptr), ir::ScriptFunctionFlags::CONSTRUCTOR | ir::ScriptFunctionFlags::IMPLICIT_SUPER_CALL_NEEDED}); + ES2PANDA_ASSERT(func); func->SetIdent(constructorId); auto *funcExpr = util::NodeAllocator::ForceSetParent(allocator, func); @@ -560,7 +566,7 @@ static ArenaVector CreateRestArgumentsArrayReall lciInfo->restParameterIdentifier, lciInfo->restArgumentIdentifier, restParameterIndex, spreadArrIterator, checker->MaybeBoxType(elementType), restParameterIndex, restParameterIndex); } - + ES2PANDA_ASSERT(args); return ArenaVector(std::move(args->AsBlockStatement()->Statements())); } @@ -572,6 +578,7 @@ static void CreateInvokeMethodRestParameter(public_lib::Context *ctx, LambdaClas auto *anyType = checker->GlobalETSNullishObjectType(); auto *restIdent = Gensym(allocator); + ES2PANDA_ASSERT(restIdent); lciInfo->restParameterIdentifier = restIdent->Name(); lciInfo->restArgumentIdentifier = GenName(allocator).View(); auto *spread = allocator->New(ir::AstNodeType::REST_ELEMENT, allocator, restIdent); @@ -747,6 +754,7 @@ static checker::ETSObjectType *FunctionTypeToLambdaProviderType(checker::ETSChec checker::Signature *signature) { if (signature->RestVar() != nullptr) { + ES2PANDA_ASSERT(checker->GlobalBuiltinLambdaType(signature->ArgCount(), true)); return checker->GlobalBuiltinLambdaType(signature->ArgCount(), true)->AsETSObjectType(); } // Note: FunctionN is not supported yet @@ -807,6 +815,7 @@ static ir::ClassDeclaration *CreateEmptyLambdaClassDeclaration(public_lib::Conte auto lambdaClassName = util::UString {std::string_view {"LambdaObject-"}, allocator}; lambdaClassName.Append(info->calleeClass->Definition()->Ident()->Name()).Append("$").Append(info->name); + ES2PANDA_ASSERT(lambdaProviderClass); auto *providerTypeReference = checker->AllocNode( checker->AllocNode( checker->AllocNode(lambdaProviderClass->AsETSObjectType()->Name(), checker->Allocator()), @@ -857,6 +866,7 @@ static ir::ClassDeclaration *CreateLambdaClass(public_lib::Context *ctx, checker CreateEmptyLambdaClassDeclaration(ctx, info, newTypeParams, fnInterface, lambdaProviderClass); auto classDefinition = classDeclaration->Definition(); if (info->isFunctionReference) { + ES2PANDA_ASSERT(callee->Function()); classDefinition->SetFunctionalReferenceReferencedMethod(callee->Function()->Scope()->InternalName()); classDefinition->SetModifiers(classDefinition->Modifiers() | ir::ClassDefinitionModifiers::FUNCTIONAL_REFERENCE); @@ -916,8 +926,10 @@ static ir::ETSNewClassInstanceExpression *CreateConstructorCall(public_lib::Cont auto *newExpr = util::NodeAllocator::ForceSetParent( allocator, allocator->New(constructedType, allocator), std::move(args)); auto *lambdaOrFuncRefParent = lambdaOrFuncRef->Parent(); + ES2PANDA_ASSERT(newExpr); newExpr->SetParent(lambdaOrFuncRefParent); // NOTE(dslynko, #19869): Required for correct debug-info generation + ES2PANDA_ASSERT(newExpr); newExpr->SetRange(lambdaOrFuncRefParent != nullptr ? lambdaOrFuncRefParent->Range() : lambdaOrFuncRef->Range()); auto *nearestScope = NearestScope(lambdaOrFuncRef); @@ -1002,6 +1014,7 @@ static ir::ScriptFunction *GetWrappingLambdaParentFunction(public_lib::Context * } bodyStmts.push_back(stmt); func->SetBody(util::NodeAllocator::ForceSetParent(allocator, allocator, std::move(bodyStmts))); + ES2PANDA_ASSERT(func->Body()); func->Body()->SetParent(func); return func; } @@ -1017,6 +1030,7 @@ static ir::ArrowFunctionExpression *CreateWrappingLambda(public_lib::Context *ct auto *func = GetWrappingLambdaParentFunction(ctx, funcRef, signature); auto *lambda = util::NodeAllocator::ForceSetParent(allocator, func, allocator); + ES2PANDA_ASSERT(lambda); lambda->SetParent(parent); auto *nearestScope = NearestScope(lambda); @@ -1086,6 +1100,7 @@ static ir::AstNode *ConvertFunctionReference(public_lib::Context *ctx, ir::Expre ES2PANDA_ASSERT(funcRef->TsType()->IsETSArrowType()); auto *lambdaClass = CreateLambdaClass(ctx, funcRef->TsType()->AsETSFunctionType(), method, &info); auto *constructorCall = CreateConstructorCall(ctx, funcRef, lambdaClass, &info); + ES2PANDA_ASSERT(constructorCall); constructorCall->TsType()->AsETSObjectType()->AddObjectFlag(checker::ETSObjectFlags::FUNCTIONAL_REFERENCE); return constructorCall; @@ -1107,8 +1122,8 @@ static bool IsFunctionOrMethodCall(checker::ETSChecker *checker, ir::CallExpress // Not skip if invoke pattern Union.() where field is of ETSArrowType if (callee->IsMemberExpression()) { auto me = callee->AsMemberExpression(); - if (me->Object()->TsType() != nullptr && checker->GetApparentType(me->Object()->TsType())->IsETSUnionType() && - me->TsType()->IsETSMethodType()) { + if (me->Object()->TsType() != nullptr && checker->GetApparentType(me->Object()->TsType()) != nullptr && + checker->GetApparentType(me->Object()->TsType())->IsETSUnionType() && me->TsType()->IsETSMethodType()) { return true; } } @@ -1147,6 +1162,7 @@ static ir::AstNode *InsertInvokeCall(public_lib::Context *ctx, ir::CallExpressio checker::PropertySearchFlags::SEARCH_IN_INTERFACES); ES2PANDA_ASSERT(prop != nullptr); auto *invoke0Id = allocator->New(invokeMethodName, allocator); + ES2PANDA_ASSERT(invoke0Id); invoke0Id->SetTsType(prop->TsType()); invoke0Id->SetVariable(prop); diff --git a/ets2panda/compiler/lowering/ets/lateInitialization.cpp b/ets2panda/compiler/lowering/ets/lateInitialization.cpp index a6e6b95098..ec9d7ee9b3 100644 --- a/ets2panda/compiler/lowering/ets/lateInitialization.cpp +++ b/ets2panda/compiler/lowering/ets/lateInitialization.cpp @@ -36,6 +36,7 @@ ir::ClassProperty *TransformerClassProperty(public_lib::Context *ctx, ir::ClassP auto annotationType = checker->CreateETSUnionType({property->TsType(), checker->GlobalETSUndefinedType()}); auto typeAnnotation = allocator->New(annotationType, allocator); + ES2PANDA_ASSERT(typeAnnotation); typeAnnotation->SetParent(property); typeAnnotation->SetTsType(annotationType); property->SetTypeAnnotation(typeAnnotation); @@ -75,6 +76,7 @@ static ir::AstNode *TransformerMemberExpression(ir::MemberExpression *memberExpr blockStatements.push_back(parser->CreateFormattedStatement(ss.str(), name)); blockStatements.push_back(parser->CreateFormattedStatement("@@I1 as @@T2", name, typeNode)); auto *res = util::NodeAllocator::ForceSetParent(allocator, std::move(blockStatements)); + ES2PANDA_ASSERT(res); res->SetParent(parent); Recheck(ctx->phaseManager, varbinder, checker, res); diff --git a/ets2panda/ir/ets/etsClassLiteral.cpp b/ets2panda/ir/ets/etsClassLiteral.cpp index fa65001a99..ba0830fb30 100644 --- a/ets2panda/ir/ets/etsClassLiteral.cpp +++ b/ets2panda/ir/ets/etsClassLiteral.cpp @@ -72,6 +72,7 @@ ETSClassLiteral *ETSClassLiteral::Clone(ArenaAllocator *const allocator, AstNode expr->SetParent(clone); } if (parent != nullptr) { + ES2PANDA_ASSERT(clone); clone->SetParent(parent); } diff --git a/ets2panda/ir/ets/etsFunctionType.cpp b/ets2panda/ir/ets/etsFunctionType.cpp index da4e93b20c..5171fe1338 100644 --- a/ets2panda/ir/ets/etsFunctionType.cpp +++ b/ets2panda/ir/ets/etsFunctionType.cpp @@ -155,6 +155,7 @@ ETSFunctionType *ETSFunctionType::Clone(ArenaAllocator *const allocator, AstNode if (!Annotations().empty()) { ArenaVector annotationUsages {allocator->Adapter()}; for (auto *annotationUsage : Annotations()) { + ES2PANDA_ASSERT(annotationUsage->Clone(allocator, clone)); annotationUsages.push_back(annotationUsage->Clone(allocator, clone)->AsAnnotationUsage()); } clone->SetAnnotations(std::move(annotationUsages)); diff --git a/ets2panda/ir/ets/etsKeyofType.cpp b/ets2panda/ir/ets/etsKeyofType.cpp index 2ef1666092..66f076e6fd 100644 --- a/ets2panda/ir/ets/etsKeyofType.cpp +++ b/ets2panda/ir/ets/etsKeyofType.cpp @@ -64,6 +64,7 @@ checker::Type *ETSKeyofType::GetType(checker::ETSChecker *checker) } auto *typeReference = type_->GetType(checker); + ES2PANDA_ASSERT(typeReference); if (typeReference->IsETSPrimitiveType()) { typeReference = checker->MaybeBoxType(typeReference); @@ -88,6 +89,7 @@ ETSKeyofType *ETSKeyofType::Clone(ArenaAllocator *const allocator, AstNode *cons { TypeNode *type = type_->Clone(allocator, nullptr); ETSKeyofType *clone = allocator->New(type, allocator); + ES2PANDA_ASSERT(clone); if (parent != nullptr) { clone->SetParent(parent); } diff --git a/ets2panda/ir/ets/etsNeverType.cpp b/ets2panda/ir/ets/etsNeverType.cpp index 79284dd1f7..5139f9c4fe 100644 --- a/ets2panda/ir/ets/etsNeverType.cpp +++ b/ets2panda/ir/ets/etsNeverType.cpp @@ -73,6 +73,7 @@ checker::Type *ETSNeverType::GetType([[maybe_unused]] checker::ETSChecker *check ETSNeverType *ETSNeverType::Clone(ArenaAllocator *allocator, AstNode *parent) { auto *const clone = allocator->New(allocator); + ES2PANDA_ASSERT(clone); if (parent != nullptr) { clone->SetParent(parent); diff --git a/ets2panda/ir/ets/etsNewArrayInstanceExpression.cpp b/ets2panda/ir/ets/etsNewArrayInstanceExpression.cpp index a3356c3c10..3df900701a 100644 --- a/ets2panda/ir/ets/etsNewArrayInstanceExpression.cpp +++ b/ets2panda/ir/ets/etsNewArrayInstanceExpression.cpp @@ -84,6 +84,7 @@ ETSNewArrayInstanceExpression *ETSNewArrayInstanceExpression::Clone(ArenaAllocat auto *const typeRef = typeReference_ != nullptr ? typeReference_->Clone(allocator, nullptr) : nullptr; auto *const dimension = dimension_ != nullptr ? dimension_->Clone(allocator, nullptr)->AsExpression() : nullptr; auto *const clone = allocator->New(typeRef, dimension); + ES2PANDA_ASSERT(clone); if (typeRef != nullptr) { typeRef->SetParent(clone); diff --git a/ets2panda/ir/ets/etsNewClassInstanceExpression.cpp b/ets2panda/ir/ets/etsNewClassInstanceExpression.cpp index 4a32953e5d..7c0b525c0e 100644 --- a/ets2panda/ir/ets/etsNewClassInstanceExpression.cpp +++ b/ets2panda/ir/ets/etsNewClassInstanceExpression.cpp @@ -109,6 +109,7 @@ ETSNewClassInstanceExpression *ETSNewClassInstanceExpression::Clone(ArenaAllocat AstNode *const parent) { auto *const clone = allocator->New(*this, allocator); + ES2PANDA_ASSERT(clone); if (parent != nullptr) { clone->SetParent(parent); } diff --git a/ets2panda/ir/ets/etsNewMultiDimArrayInstanceExpression.cpp b/ets2panda/ir/ets/etsNewMultiDimArrayInstanceExpression.cpp index a79d71241b..78ea464ef9 100644 --- a/ets2panda/ir/ets/etsNewMultiDimArrayInstanceExpression.cpp +++ b/ets2panda/ir/ets/etsNewMultiDimArrayInstanceExpression.cpp @@ -107,6 +107,7 @@ ETSNewMultiDimArrayInstanceExpression *ETSNewMultiDimArrayInstanceExpression::Cl AstNode *const parent) { auto *const clone = allocator->New(*this, allocator); + ES2PANDA_ASSERT(clone); if (parent != nullptr) { clone->SetParent(parent); } diff --git a/ets2panda/ir/ets/etsNonNullishTypeNode.cpp b/ets2panda/ir/ets/etsNonNullishTypeNode.cpp index 14226f3c0f..00d68dbfce 100644 --- a/ets2panda/ir/ets/etsNonNullishTypeNode.cpp +++ b/ets2panda/ir/ets/etsNonNullishTypeNode.cpp @@ -69,6 +69,7 @@ ETSNonNullishTypeNode *ETSNonNullishTypeNode::Clone(ArenaAllocator *allocator, A { TypeNode *typeNode = typeNode_->Clone(allocator, nullptr); ETSNonNullishTypeNode *clone = allocator->New(typeNode, allocator); + ES2PANDA_ASSERT(clone); clone->SetParent(parent); clone->typeNode_->SetParent(clone); return clone; diff --git a/ets2panda/ir/ets/etsNullishTypes.cpp b/ets2panda/ir/ets/etsNullishTypes.cpp index e3e9e79836..602945adc4 100644 --- a/ets2panda/ir/ets/etsNullishTypes.cpp +++ b/ets2panda/ir/ets/etsNullishTypes.cpp @@ -73,6 +73,7 @@ checker::Type *ETSUndefinedType::GetType([[maybe_unused]] checker::ETSChecker *c ETSUndefinedType *ETSUndefinedType::Clone(ArenaAllocator *allocator, AstNode *parent) { auto *const clone = allocator->New(allocator); + ES2PANDA_ASSERT(clone); if (parent != nullptr) { clone->SetParent(parent); @@ -151,6 +152,7 @@ ETSNullType *ETSNullType::Clone(ArenaAllocator *allocator, AstNode *parent) if (!Annotations().empty()) { ArenaVector annotationUsages {allocator->Adapter()}; for (auto *annotationUsage : Annotations()) { + ES2PANDA_ASSERT(annotationUsage->Clone(allocator, clone)); annotationUsages.push_back(annotationUsage->Clone(allocator, clone)->AsAnnotationUsage()); } clone->SetAnnotations(std::move(annotationUsages)); diff --git a/ets2panda/ir/ets/etsPackageDeclaration.cpp b/ets2panda/ir/ets/etsPackageDeclaration.cpp index 277abfc2d3..e6de02bf1e 100644 --- a/ets2panda/ir/ets/etsPackageDeclaration.cpp +++ b/ets2panda/ir/ets/etsPackageDeclaration.cpp @@ -69,6 +69,7 @@ ETSPackageDeclaration *ETSPackageDeclaration::Clone(ArenaAllocator *const alloca { auto const name = name_ != nullptr ? name_->Clone(allocator, nullptr)->AsExpression() : nullptr; auto *const clone = allocator->New(name); + ES2PANDA_ASSERT(clone); if (name != nullptr) { name->SetParent(clone); diff --git a/ets2panda/ir/ets/etsParameterExpression.cpp b/ets2panda/ir/ets/etsParameterExpression.cpp index 382a8a6f11..4f1f375369 100644 --- a/ets2panda/ir/ets/etsParameterExpression.cpp +++ b/ets2panda/ir/ets/etsParameterExpression.cpp @@ -247,6 +247,7 @@ ETSParameterExpression *ETSParameterExpression::Clone(ArenaAllocator *const allo initializer->SetParent(clone); } + ES2PANDA_ASSERT(clone); if (parent != nullptr) { clone->SetParent(parent); } diff --git a/ets2panda/ir/ets/etsParameterExpression.h b/ets2panda/ir/ets/etsParameterExpression.h index a38f760c79..91013b3372 100644 --- a/ets2panda/ir/ets/etsParameterExpression.h +++ b/ets2panda/ir/ets/etsParameterExpression.h @@ -49,6 +49,7 @@ public: void SetIdent(Identifier *ident) noexcept { ident_ = ident; + ES2PANDA_ASSERT(ident_); ident_->SetParent(this); } diff --git a/ets2panda/ir/ets/etsPrimitiveType.cpp b/ets2panda/ir/ets/etsPrimitiveType.cpp index c18f743502..58f800f0ab 100644 --- a/ets2panda/ir/ets/etsPrimitiveType.cpp +++ b/ets2panda/ir/ets/etsPrimitiveType.cpp @@ -167,6 +167,7 @@ ETSPrimitiveType *ETSPrimitiveType::Clone(ArenaAllocator *const allocator, AstNo if (!Annotations().empty()) { ArenaVector annotationUsages {allocator->Adapter()}; for (auto *annotationUsage : Annotations()) { + ES2PANDA_ASSERT(annotationUsage->Clone(allocator, clone)); annotationUsages.push_back(annotationUsage->Clone(allocator, clone)->AsAnnotationUsage()); } clone->SetAnnotations(std::move(annotationUsages)); diff --git a/ets2panda/ir/ets/etsStringLiteralType.cpp b/ets2panda/ir/ets/etsStringLiteralType.cpp index d6227f2673..83a867e97d 100644 --- a/ets2panda/ir/ets/etsStringLiteralType.cpp +++ b/ets2panda/ir/ets/etsStringLiteralType.cpp @@ -82,6 +82,7 @@ ETSStringLiteralType *ETSStringLiteralType::Clone(ArenaAllocator *allocator, Ast if (!Annotations().empty()) { ArenaVector annotationUsages {allocator->Adapter()}; for (auto *annotationUsage : Annotations()) { + ES2PANDA_ASSERT(annotationUsage->Clone(allocator, clone)); annotationUsages.push_back(annotationUsage->Clone(allocator, clone)->AsAnnotationUsage()); } clone->SetAnnotations(std::move(annotationUsages)); diff --git a/ets2panda/ir/ets/etsTuple.cpp b/ets2panda/ir/ets/etsTuple.cpp index b79654c62e..8de5db97f1 100644 --- a/ets2panda/ir/ets/etsTuple.cpp +++ b/ets2panda/ir/ets/etsTuple.cpp @@ -127,6 +127,7 @@ checker::Type *ETSTuple::GetType(checker::ETSChecker *const checker) auto *tupleType = checker->ProgramAllocator()->New(checker, typeList); if (IsReadonlyType()) { + ES2PANDA_ASSERT(checker->GetReadonlyType(tupleType)); tupleType = checker->GetReadonlyType(tupleType)->AsETSTupleType(); } @@ -137,6 +138,7 @@ checker::Type *ETSTuple::GetType(checker::ETSChecker *const checker) ETSTuple *ETSTuple::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const clone = allocator->New(allocator, size_); + ES2PANDA_ASSERT(clone); clone->AddModifier(flags_); diff --git a/ets2panda/ir/ets/etsTypeReferencePart.cpp b/ets2panda/ir/ets/etsTypeReferencePart.cpp index 3c7089b10f..9d309f0b38 100644 --- a/ets2panda/ir/ets/etsTypeReferencePart.cpp +++ b/ets2panda/ir/ets/etsTypeReferencePart.cpp @@ -257,6 +257,7 @@ ETSTypeReferencePart *ETSTypeReferencePart::Clone(ArenaAllocator *const allocato prevClone->SetParent(clone); } + ES2PANDA_ASSERT(clone); if (parent != nullptr) { clone->SetParent(parent); } diff --git a/ets2panda/ir/ets/etsUnionType.cpp b/ets2panda/ir/ets/etsUnionType.cpp index 39860832e4..b454c1bf79 100644 --- a/ets2panda/ir/ets/etsUnionType.cpp +++ b/ets2panda/ir/ets/etsUnionType.cpp @@ -127,6 +127,7 @@ ETSUnionType *ETSUnionType::Clone(ArenaAllocator *const allocator, AstNode *cons if (!Annotations().empty()) { ArenaVector annotationUsages {allocator->Adapter()}; for (auto *annotationUsage : Annotations()) { + ES2PANDA_ASSERT(annotationUsage->Clone(allocator, clone)); annotationUsages.push_back(annotationUsage->Clone(allocator, clone)->AsAnnotationUsage()); } clone->SetAnnotations(std::move(annotationUsages)); diff --git a/ets2panda/ir/expressions/arrayExpression.cpp b/ets2panda/ir/expressions/arrayExpression.cpp index cc9ec65885..a8d90d7e86 100644 --- a/ets2panda/ir/expressions/arrayExpression.cpp +++ b/ets2panda/ir/expressions/arrayExpression.cpp @@ -48,6 +48,7 @@ ArrayExpression::ArrayExpression([[maybe_unused]] Tag const tag, ArrayExpression ArrayExpression *ArrayExpression::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const clone = allocator->New(Tag {}, *this, allocator); + ES2PANDA_ASSERT(clone); if (parent != nullptr) { clone->SetParent(parent); } @@ -345,6 +346,7 @@ checker::Type *ArrayExpression::CheckPattern(checker::TSChecker *checker) index--; } + ES2PANDA_ASSERT(desc); const checker::TupleTypeInfo tupleTypeInfo = {combinedFlags, minLength, static_cast(desc->properties.size()), false}; return checker->CreateTupleType(desc, std::move(elementFlags), tupleTypeInfo); @@ -413,6 +415,7 @@ checker::VerifiedType ArrayExpression::Check(checker::ETSChecker *checker) std::optional ArrayExpression::ExtractPossiblePreferredType(checker::Type *type) { + ES2PANDA_ASSERT(type); if (type->IsETSArrayType() || type->IsETSTupleType() || type->IsETSResizableArrayType()) { return std::make_optional(type); } diff --git a/ets2panda/ir/expressions/arrowFunctionExpression.cpp b/ets2panda/ir/expressions/arrowFunctionExpression.cpp index c4941954ec..dde0cd72a6 100644 --- a/ets2panda/ir/expressions/arrowFunctionExpression.cpp +++ b/ets2panda/ir/expressions/arrowFunctionExpression.cpp @@ -88,12 +88,14 @@ checker::VerifiedType ArrowFunctionExpression::Check(checker::ETSChecker *checke ArrowFunctionExpression::ArrowFunctionExpression(ArrowFunctionExpression const &other, ArenaAllocator *const allocator) : JsDocAllowed>(static_cast(other), allocator) { + ES2PANDA_ASSERT(other.func_->Clone(allocator, this)); func_ = other.func_->Clone(allocator, this)->AsScriptFunction(); } ArrowFunctionExpression *ArrowFunctionExpression::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const clone = allocator->New(*this, allocator); + ES2PANDA_ASSERT(clone); if (parent != nullptr) { clone->SetParent(parent); @@ -120,6 +122,7 @@ ir::TypeNode *ArrowFunctionExpression::CreateReturnNodeFromType(checker::ETSChec auto *ident = checker->AllocNode(util::StringView(""), checker->Allocator()); auto *const part = checker->AllocNode(ident, checker->Allocator()); auto *returnNode = checker->AllocNode(part, checker->Allocator()); + ES2PANDA_ASSERT(returnNode); returnNode->SetTsType(returnType); return returnNode; } diff --git a/ets2panda/ir/expressions/assignmentExpression.cpp b/ets2panda/ir/expressions/assignmentExpression.cpp index d6ff928480..2505910c5f 100644 --- a/ets2panda/ir/expressions/assignmentExpression.cpp +++ b/ets2panda/ir/expressions/assignmentExpression.cpp @@ -169,6 +169,7 @@ AssignmentExpression *AssignmentExpression::Clone(ArenaAllocator *const allocato auto *const left = left_ != nullptr ? left_->Clone(allocator, nullptr)->AsExpression() : nullptr; auto *const right = right_ != nullptr ? right_->Clone(allocator, nullptr)->AsExpression() : nullptr; auto *const clone = allocator->New(Tag {}, *this, left, right); + ES2PANDA_ASSERT(clone); if (parent != nullptr) { clone->SetParent(parent); diff --git a/ets2panda/ir/expressions/awaitExpression.cpp b/ets2panda/ir/expressions/awaitExpression.cpp index 6071bd4155..d9e6b54668 100644 --- a/ets2panda/ir/expressions/awaitExpression.cpp +++ b/ets2panda/ir/expressions/awaitExpression.cpp @@ -74,6 +74,7 @@ AwaitExpression *AwaitExpression::Clone(ArenaAllocator *const allocator, AstNode { auto *const argument = argument_ != nullptr ? argument_->Clone(allocator, nullptr)->AsExpression() : nullptr; auto *const clone = allocator->New(argument); + ES2PANDA_ASSERT(clone); if (argument != nullptr) { argument->SetParent(clone); diff --git a/ets2panda/ir/expressions/binaryExpression.cpp b/ets2panda/ir/expressions/binaryExpression.cpp index 21babd5626..ddfd3f3a06 100644 --- a/ets2panda/ir/expressions/binaryExpression.cpp +++ b/ets2panda/ir/expressions/binaryExpression.cpp @@ -99,6 +99,7 @@ BinaryExpression *BinaryExpression::Clone(ArenaAllocator *const allocator, AstNo auto *const left = left_ != nullptr ? left_->Clone(allocator, nullptr)->AsExpression() : nullptr; auto *const right = right_ != nullptr ? right_->Clone(allocator, nullptr)->AsExpression() : nullptr; auto *const clone = allocator->New(left, right, operator_); + ES2PANDA_ASSERT(clone); if (operationType_ != nullptr) { clone->SetOperationType(operationType_); diff --git a/ets2panda/ir/expressions/binaryExpression.h b/ets2panda/ir/expressions/binaryExpression.h index e7accbe3b4..7c5d8fa200 100644 --- a/ets2panda/ir/expressions/binaryExpression.h +++ b/ets2panda/ir/expressions/binaryExpression.h @@ -113,6 +113,7 @@ public: void SetLeft(Expression *expr) noexcept { left_ = expr; + ES2PANDA_ASSERT(left_); left_->SetParent(this); SetStart(left_->Start()); } @@ -120,6 +121,7 @@ public: void SetRight(Expression *expr) noexcept { right_ = expr; + ES2PANDA_ASSERT(right_); right_->SetParent(this); SetEnd(right_->End()); } diff --git a/ets2panda/ir/expressions/blockExpression.cpp b/ets2panda/ir/expressions/blockExpression.cpp index c38cb57710..853f4973fc 100644 --- a/ets2panda/ir/expressions/blockExpression.cpp +++ b/ets2panda/ir/expressions/blockExpression.cpp @@ -40,6 +40,7 @@ BlockExpression::BlockExpression([[maybe_unused]] Tag const tag, BlockExpression BlockExpression *BlockExpression::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const clone = allocator->New(Tag {}, *this, allocator); + ES2PANDA_ASSERT(clone); if (parent != nullptr) { clone->SetParent(parent); } -- Gitee