diff --git a/ets2panda/ast_verifier/ASTVerifier.cpp b/ets2panda/ast_verifier/ASTVerifier.cpp index 9854161341dad190e547fec914f090536c2a9f5e..e55eaac5bb4bfcf16edb00c06b1de418aba183b4 100644 --- a/ets2panda/ast_verifier/ASTVerifier.cpp +++ b/ets2panda/ast_verifier/ASTVerifier.cpp @@ -80,7 +80,7 @@ static auto ExtractAst(const parser::Program &program, bool checkFullProgram) return astToCheck; } -void ASTVerifier::Verify(std::string_view phaseName) +void ASTVerifier::Verify(std::string_view phaseName) noexcept { if (context_.diagnosticEngine->IsAnyError()) { // NOTE(dkofanov): As for now, the policy is that ASTVerifier doesn't interrupt pipeline if there were errors diff --git a/ets2panda/ast_verifier/ASTVerifier.h b/ets2panda/ast_verifier/ASTVerifier.h index f0d6315741c0a96d2810c77e19b6122506c8ff81..0cadf9e1637a599b85459e22ae0ad0909cdce8d6 100644 --- a/ets2panda/ast_verifier/ASTVerifier.h +++ b/ets2panda/ast_verifier/ASTVerifier.h @@ -108,7 +108,7 @@ public: } } - void Verify(std::string_view phaseName); + void Verify(std::string_view phaseName) noexcept; void IntroduceNewInvariants(std::string_view occurredPhaseName) { diff --git a/ets2panda/compiler/base/lreference.cpp b/ets2panda/compiler/base/lreference.cpp index e466a11fa8bb73a2b3439847edfffff87a52764e..ba3a65053834728ae02975fe54c99bd8b9b9bf70 100644 --- a/ets2panda/compiler/base/lreference.cpp +++ b/ets2panda/compiler/base/lreference.cpp @@ -311,6 +311,7 @@ void ETSLReference::SetValueGetterSetter(const ir::MemberExpression *memberExpr) { ES2PANDA_ASSERT(memberExpr->PropVar() != nullptr); const auto *sig = memberExpr->PropVar()->TsType()->AsETSFunctionType()->FindSetter(); + ES2PANDA_ASSERT(sig != nullptr); auto argReg = etsg_->AllocReg(); etsg_->StoreAccumulator(Node(), argReg); @@ -343,8 +344,8 @@ void ETSLReference::SetValue() const return; } - if (memberExpr->PropVar() != nullptr && - memberExpr->PropVar()->TsType()->HasTypeFlag(checker::TypeFlag::GETTER_SETTER)) { + ES2PANDA_ASSERT(memberExpr->PropVar() != nullptr); + if (memberExpr->PropVar()->TsType()->HasTypeFlag(checker::TypeFlag::GETTER_SETTER)) { SetValueGetterSetter(memberExpr); return; } diff --git a/ets2panda/compiler/core/CFG.cpp b/ets2panda/compiler/core/CFG.cpp index 80177b220eb3808775a32f6e6b3bb8e905460b32..bcef1b23a3f6fd36cf44548a27313bcb22e38d20 100644 --- a/ets2panda/compiler/core/CFG.cpp +++ b/ets2panda/compiler/core/CFG.cpp @@ -201,6 +201,7 @@ CFG::BasicBlock *CFG::Build(ir::ScriptFunction *scriptFunctionNode) } BasicBlock *entryBB = CreateNewBB({}); + ES2PANDA_ASSERT(entryBB != nullptr); entryBB->SetFlag(BasicBlockFlags::ENTRY); functionNodeBBMap_[scriptFunctionNode] = entryBB; if (scriptFunctionNode->Id() != nullptr) { @@ -507,6 +508,7 @@ CFG::BasicBlock *CFG::Build(ir::WhileStatement *whileStatementNode, BasicBlock * { ++inLoop_; auto testBB = CreateNewBB({bb}); + ES2PANDA_ASSERT(testBB != nullptr); testBB->SetFlag(BasicBlockFlags::CONDITION); --inLoop_; auto falseBB = CreateNewBB({testBB}, {&falseLabel_}); @@ -515,6 +517,7 @@ CFG::BasicBlock *CFG::Build(ir::WhileStatement *whileStatementNode, BasicBlock * bb = Build(whileStatementNode->Test(), testBB); auto trueBB = CreateNewBB({bb}, {&trueLabel_}); trueBB = Build(whileStatementNode->Body(), trueBB); + ES2PANDA_ASSERT(trueBB != nullptr); trueBB->AddSuccessor(testBB); --inLoop_; return falseBB; @@ -525,12 +528,14 @@ CFG::BasicBlock *CFG::Build(ir::DoWhileStatement *doWhileStatementNode, BasicBlo ++inLoop_; auto bodyBB = CreateNewBB({bb}); auto testBB = CreateNewBB({}); + ES2PANDA_ASSERT(testBB != nullptr); testBB->SetFlag(BasicBlockFlags::CONDITION); --inLoop_; auto falseBB = CreateNewBB({testBB}, {&falseLabel_}); ++inLoop_; loopStmtJumpTargetMap_[doWhileStatementNode] = std::make_pair(testBB, falseBB); bb = Build(doWhileStatementNode->Body(), bodyBB); + ES2PANDA_ASSERT(bb != nullptr); testBB = Build(doWhileStatementNode->Test(), testBB); bb->AddSuccessor(testBB); AddBBEdge(testBB, bodyBB, &trueLabel_); @@ -636,6 +641,7 @@ CFG::BasicBlock *CFG::Build(ir::ForOfStatement *forOfStatementNode, BasicBlock * loopStmtJumpTargetMap_[forOfStatementNode] = std::make_pair(bb, nextBB); bb = Build(forOfStatementNode->Body(), bb); --inLoop_; + ES2PANDA_ASSERT(bb != nullptr); bb->AddSuccessor(loopBB); bb->AddSuccessor(nextBB); return nextBB; @@ -656,6 +662,7 @@ CFG::BasicBlock *CFG::Build(ir::ForUpdateStatement *forUpdateStatementNode, Basi testBB = Build(forUpdateStatementNode->Test(), testBB); auto bodyBB = Build(forUpdateStatementNode->Body(), trueBB); bodyBB = Build(forUpdateStatementNode->Update(), bodyBB); + ES2PANDA_ASSERT(bodyBB != nullptr); bodyBB->AddSuccessor(testBB); --inLoop_; return falseBB; @@ -667,6 +674,7 @@ CFG::BasicBlock *CFG::Build(ir::ForUpdateStatement *forUpdateStatementNode, Basi loopStmtJumpTargetMap_[forUpdateStatementNode] = std::make_pair(bodyStartBB, nextBB); auto bodyBB = Build(forUpdateStatementNode->Body(), bodyStartBB); bodyBB = Build(forUpdateStatementNode->Update(), bodyBB); + ES2PANDA_ASSERT(bodyBB != nullptr); bodyBB->AddSuccessor(bodyStartBB); --inLoop_; return nextBB; diff --git a/ets2panda/compiler/core/ETSCompiler.cpp b/ets2panda/compiler/core/ETSCompiler.cpp index a3fdfbe9ffa22278dd954c3f9742df233ce5de0f..9eec575447344449f3057650db98ec23dcbcfa8a 100644 --- a/ets2panda/compiler/core/ETSCompiler.cpp +++ b/ets2panda/compiler/core/ETSCompiler.cpp @@ -674,6 +674,7 @@ static void ConvertRestArguments(checker::ETSChecker *const checker, const ir::C elements.emplace_back(expr->Arguments()[i]); } auto *arrayExpression = checker->AllocNode(std::move(elements), checker->Allocator()); + ES2PANDA_ASSERT(arrayExpression != nullptr); arrayExpression->SetParent(const_cast(expr)); auto restType = signature->RestVar()->TsType()->AsETSArrayType(); arrayExpression->SetTsType(restType); diff --git a/ets2panda/compiler/core/ETSemitter.cpp b/ets2panda/compiler/core/ETSemitter.cpp index cc995bd35c1e99f78b20469d49d7bc441b9c6032..f741460c50f514caf52c3810070c65cd3a18230b 100644 --- a/ets2panda/compiler/core/ETSemitter.cpp +++ b/ets2panda/compiler/core/ETSemitter.cpp @@ -141,6 +141,7 @@ static pandasm::Function GenScriptFunction(const ir::ScriptFunction *scriptFunc, uint32_t accessFlags = 0; if (!scriptFunc->IsStaticBlock()) { const auto *methodDef = util::Helpers::GetContainingClassMethodDefinition(scriptFunc); + ES2PANDA_ASSERT(methodDef != nullptr); accessFlags |= TranslateModifierFlags(methodDef->Modifiers()); } if (scriptFunc->HasRestParameter()) { @@ -1036,6 +1037,7 @@ pandasm::AnnotationData ETSEmitter::GenAnnotationEnclosingMethod(const ir::Metho { GenAnnotationRecord(Signatures::ETS_ANNOTATION_ENCLOSING_METHOD); pandasm::AnnotationData enclosingMethod(Signatures::ETS_ANNOTATION_ENCLOSING_METHOD); + ES2PANDA_ASSERT(methodDef->Function() != nullptr); pandasm::AnnotationElement value( Signatures::ANNOTATION_KEY_VALUE, std::make_unique(pandasm::ScalarValue::Create( diff --git a/ets2panda/compiler/lowering/ets/asyncMethodLowering.cpp b/ets2panda/compiler/lowering/ets/asyncMethodLowering.cpp index ad6c0daeeb7e97a1d5974aefdf00e1bd2d8e9523..01d054a71719af0a6a204e77f7e8f90baa2264f2 100644 --- a/ets2panda/compiler/lowering/ets/asyncMethodLowering.cpp +++ b/ets2panda/compiler/lowering/ets/asyncMethodLowering.cpp @@ -129,11 +129,13 @@ ir::MethodDefinition *CreateAsyncProxy(checker::ETSChecker *checker, ir::MethodD { ES2PANDA_ASSERT(asyncMethod != nullptr); ir::ScriptFunction *asyncFunc = asyncMethod->Function(); + ES2PANDA_ASSERT(asyncFunc != nullptr); if (!asyncFunc->IsExternal()) { checker->VarBinder()->AsETSBinder()->GetRecordTable()->Signatures().push_back(asyncFunc->Scope()); } ir::MethodDefinition *implMethod = CreateAsyncImplMethod(checker, asyncMethod, classDef); + ES2PANDA_ASSERT(implMethod != nullptr && implMethod->Function() != nullptr && implMethod->Id() != nullptr); varbinder::FunctionScope *implFuncScope = implMethod->Function()->Scope(); for (auto *decl : asyncFunc->Scope()->Decls()) { auto res = asyncFunc->Scope()->Bindings().find(decl->Name()); @@ -170,8 +172,10 @@ void ComposeAsyncImplMethod(checker::ETSChecker *checker, ir::MethodDefinition * implMethod->Check(checker); node->SetAsyncPairMethod(implMethod); + ES2PANDA_ASSERT(node->Function() != nullptr); if (node->Function()->IsOverload()) { auto *baseOverloadImplMethod = node->BaseOverloadMethod()->AsyncPairMethod(); + ES2PANDA_ASSERT(implMethod->Function() != nullptr && baseOverloadImplMethod->Function() != nullptr); implMethod->Function()->Id()->SetVariable(baseOverloadImplMethod->Function()->Id()->Variable()); baseOverloadImplMethod->AddOverload(implMethod); } else { diff --git a/ets2panda/compiler/lowering/ets/boxingForLocals.cpp b/ets2panda/compiler/lowering/ets/boxingForLocals.cpp index dd2e41e0fc41440a6718879be6c8aaac2449c1d4..2a57b82c5c98a04f6f902d93a86484e444a9e372 100644 --- a/ets2panda/compiler/lowering/ets/boxingForLocals.cpp +++ b/ets2panda/compiler/lowering/ets/boxingForLocals.cpp @@ -152,6 +152,7 @@ static void HandleFunctionParam(public_lib::Context *ctx, ir::ETSParameterExpres auto *newDecl = allocator->New(newVarName.View(), newDeclarator); auto *newVar = allocator->New(newDecl, oldVar->Flags()); + ES2PANDA_ASSERT(newVar != nullptr); newVar->SetTsType(boxedType); newDeclarator->Id()->AsIdentifier()->SetVariable(newVar); @@ -162,6 +163,7 @@ static void HandleFunctionParam(public_lib::Context *ctx, ir::ETSParameterExpres auto *newDeclaration = util::NodeAllocator::ForceSetParent( allocator, ir::VariableDeclaration::VariableDeclarationKind::CONST, allocator, std::move(declVec)); + ES2PANDA_ASSERT(newDeclaration != nullptr); newDeclaration->SetParent(body); bodyStmts.insert(bodyStmts.begin(), newDeclaration); diff --git a/ets2panda/ir/base/scriptFunction.cpp b/ets2panda/ir/base/scriptFunction.cpp index f622829dd7a3a9f1117f4e8f9fbd5fd3c76cbaed..e0da9c96168c18f53e06aaabd8e4d603ce76d623 100644 --- a/ets2panda/ir/base/scriptFunction.cpp +++ b/ets2panda/ir/base/scriptFunction.cpp @@ -75,8 +75,11 @@ ScriptFunction *ScriptFunction::Clone(ArenaAllocator *allocator, AstNode *parent for (auto *param : Params()) { params.push_back(param->Clone(allocator, nullptr)->AsExpression()); } + AnnotationUsage *clonedAnnotationUsage; for (auto *annotationUsage : Annotations()) { - annotationUsages.push_back(annotationUsage->Clone(allocator, nullptr)->AsAnnotationUsage()); + clonedAnnotationUsage = annotationUsage->Clone(allocator, nullptr); + ES2PANDA_ASSERT(clonedAnnotationUsage != nullptr); + annotationUsages.push_back(clonedAnnotationUsage->AsAnnotationUsage()); } auto *res = util::NodeAllocator::ForceSetParent( allocator, allocator, diff --git a/ets2panda/ir/ts/tsArrayType.cpp b/ets2panda/ir/ts/tsArrayType.cpp index df02231c45885ee09dab190ac4ae9996a87e2870..edccc9fb56b432dcdd47cec6bae295c981a42890 100644 --- a/ets2panda/ir/ts/tsArrayType.cpp +++ b/ets2panda/ir/ts/tsArrayType.cpp @@ -119,8 +119,10 @@ TSArrayType *TSArrayType::Clone(ArenaAllocator *const allocator, AstNode *const if (!Annotations().empty()) { ArenaVector annotationUsages {allocator->Adapter()}; + AnnotationUsage *clonedAnnotationUsage; for (auto *annotationUsage : Annotations()) { - annotationUsages.push_back(annotationUsage->Clone(allocator, clone)->AsAnnotationUsage()); + clonedAnnotationUsage = annotationUsage->Clone(allocator, clone); + annotationUsages.push_back(clonedAnnotationUsage->AsAnnotationUsage()); } clone->SetAnnotations(std::move(annotationUsages)); } diff --git a/ets2panda/ir/ts/tsThisType.cpp b/ets2panda/ir/ts/tsThisType.cpp index fcc43a3102d43566ce96c3f0bda7653c5c4827d3..cd7167ee487c0f4ae46962d6c1e49c0d7f9ddfad 100644 --- a/ets2panda/ir/ts/tsThisType.cpp +++ b/ets2panda/ir/ts/tsThisType.cpp @@ -81,7 +81,7 @@ checker::Type *TSThisType::GetType([[maybe_unused]] checker::ETSChecker *checker TSThisType *TSThisType::Clone(ArenaAllocator *const allocator, AstNode *const parent) { auto *const clone = allocator->New(allocator); - + ES2PANDA_ASSERT(clone != nullptr); if (parent != nullptr) { clone->SetParent(parent); } @@ -89,8 +89,9 @@ TSThisType *TSThisType::Clone(ArenaAllocator *const allocator, AstNode *const pa if (!Annotations().empty()) { ArenaVector annotationUsages {allocator->Adapter()}; for (auto *annotationUsage : Annotations()) { - ES2PANDA_ASSERT(annotationUsage->Clone(allocator, clone) != nullptr); - annotationUsages.push_back(annotationUsage->Clone(allocator, clone)->AsAnnotationUsage()); + auto *clonedAnnotationUsage = annotationUsage->Clone(allocator, clone); + ES2PANDA_ASSERT(clonedAnnotationUsage != nullptr); + annotationUsages.push_back(clonedAnnotationUsage->AsAnnotationUsage()); } clone->SetAnnotations(std::move(annotationUsages)); } diff --git a/ets2panda/ir/ts/tsTupleType.cpp b/ets2panda/ir/ts/tsTupleType.cpp index 45d7df04c4cdedb9e838935ec1f0e3cef517bee6..cf30a74c3d1a6d906e2721bdc1316162f283d56d 100644 --- a/ets2panda/ir/ts/tsTupleType.cpp +++ b/ets2panda/ir/ts/tsTupleType.cpp @@ -117,6 +117,7 @@ checker::Type *TSTupleType::GetType(checker::TSChecker *checker) auto *memberVar = varbinder::Scope::CreateVar(checker->Allocator(), memberIndex, varbinder::VariableFlags::PROPERTY, it); + ES2PANDA_ASSERT(memberVar != nullptr); checker::ElementFlags memberFlag; if (it->IsTSNamedTupleMember()) {