From e3ffe7a20377763e976fe6e2d214d267ed80a4e2 Mon Sep 17 00:00:00 2001 From: Klimentieva Date: Tue, 22 Jul 2025 15:08:36 +0300 Subject: [PATCH] codecheck fix Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICO427 Change-Id: I07a96272af952ff93db4ed4a84e44d8269e8d6ee Signed-off-by: Klimentieva --- ets2panda/ir/base/catchClause.cpp | 10 ++++++---- ets2panda/parser/ETSparserExpressions.cpp | 3 +++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ets2panda/ir/base/catchClause.cpp b/ets2panda/ir/base/catchClause.cpp index c4c120f155..c11433d958 100644 --- a/ets2panda/ir/base/catchClause.cpp +++ b/ets2panda/ir/base/catchClause.cpp @@ -98,11 +98,13 @@ CatchClause::CatchClause(CatchClause const &other, ArenaAllocator *allocator) : { param_ = nullptr; body_ = nullptr; - if (other.param_ != nullptr && other.param_->Clone(allocator, this) != nullptr) { - param_ = other.param_->Clone(allocator, this)->AsExpression(); + auto *const cloneParam = other.param_ != nullptr ? other.param_->Clone(allocator, this) : nullptr; + auto *const cloneBody = other.body_ != nullptr ? other.body_->Clone(allocator, this) : nullptr; + if (cloneParam != nullptr) { + param_ = cloneParam->AsExpression(); } - if (other.body_ != nullptr && other.body_->Clone(allocator, this) != nullptr) { - body_ = other.body_->Clone(allocator, this)->AsBlockStatement(); + if (cloneBody != nullptr) { + body_ = cloneBody->AsBlockStatement(); } } diff --git a/ets2panda/parser/ETSparserExpressions.cpp b/ets2panda/parser/ETSparserExpressions.cpp index 55bb39d443..40d3293cb5 100644 --- a/ets2panda/parser/ETSparserExpressions.cpp +++ b/ets2panda/parser/ETSparserExpressions.cpp @@ -249,6 +249,7 @@ ir::Expression *ETSParser::ParsePropertyKey([[maybe_unused]] ExpressionParseFlag case lexer::TokenType::LITERAL_IDENT: { const util::StringView &ident = Lexer()->GetToken().Ident(); key = AllocNode(ident, Allocator()); + ES2PANDA_ASSERT(key != nullptr); key->SetRange(Lexer()->GetToken().Loc()); Lexer()->NextToken(); return key; @@ -256,6 +257,7 @@ ir::Expression *ETSParser::ParsePropertyKey([[maybe_unused]] ExpressionParseFlag case lexer::TokenType::LITERAL_STRING: { const util::StringView &string = Lexer()->GetToken().String(); key = AllocNode(string); + ES2PANDA_ASSERT(key != nullptr); key->SetRange(Lexer()->GetToken().Loc()); Lexer()->NextToken(); return key; @@ -266,6 +268,7 @@ ir::Expression *ETSParser::ParsePropertyKey([[maybe_unused]] ExpressionParseFlag } else { key = AllocNode(Lexer()->GetToken().GetNumber()); } + ES2PANDA_ASSERT(key != nullptr); key->SetRange(Lexer()->GetToken().Loc()); Lexer()->NextToken(); return key; -- Gitee