From 169c5f6e5918a0a48a184f88ef9662954e22f2e4 Mon Sep 17 00:00:00 2001 From: jiangkaiwen Date: Fri, 3 Feb 2023 18:00:38 +0800 Subject: [PATCH] Fix codecheck warnings of the monthly branch 1.The position of function parameters is consistent Issue:I6BVB5 Signed-off-by: jiangkaiwen Change-Id: I1985f3fba12aa6c32ff1364bd0e8b326d211485e --- es2panda/ir/expressions/literals/regExpLiteral.cpp | 1 - es2panda/lexer/lexer.cpp | 2 ++ es2panda/parser/expressionParser.cpp | 1 - es2panda/parser/statementParser.cpp | 2 ++ es2panda/scripts/gen_isa.sh | 2 +- es2panda/scripts/gen_keywords.sh | 2 +- es2panda/test/runner.py | 13 ++++++------- es2panda/util/base64.cpp | 5 ++++- es2panda/util/concurrent.cpp | 2 +- test262/run_sunspider.py | 4 ++-- 10 files changed, 19 insertions(+), 15 deletions(-) diff --git a/es2panda/ir/expressions/literals/regExpLiteral.cpp b/es2panda/ir/expressions/literals/regExpLiteral.cpp index b87cd4ab3d..f20ab4c534 100644 --- a/es2panda/ir/expressions/literals/regExpLiteral.cpp +++ b/es2panda/ir/expressions/literals/regExpLiteral.cpp @@ -56,7 +56,6 @@ void RegExpLiteral::Compile(compiler::PandaGen *pg) const checker::Type *RegExpLiteral::Check(checker::Checker *checker) const { - // TODO(aszilagyi); return checker->GlobalAnyType(); } diff --git a/es2panda/lexer/lexer.cpp b/es2panda/lexer/lexer.cpp index bd7b785c80..529ddea26a 100644 --- a/es2panda/lexer/lexer.cpp +++ b/es2panda/lexer/lexer.cpp @@ -249,6 +249,8 @@ void Lexer::ScanNumberLeadingZero() case LEX_CHAR_8: case LEX_CHAR_9: { ThrowError("Invalid octal digit"); + + [[fallthrough]]; } default: { break; diff --git a/es2panda/parser/expressionParser.cpp b/es2panda/parser/expressionParser.cpp index ed568b4c80..6058ff530c 100644 --- a/es2panda/parser/expressionParser.cpp +++ b/es2panda/parser/expressionParser.cpp @@ -616,7 +616,6 @@ ir::Expression *ParserImpl::ParseCoverParenthesizedExpressionAndArrowParameterLi if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_ARROW) { lexer_->Rewind(startPos); return expr; - // ThrowSyntaxError("'=>' expected."); } return ParseArrowFunctionExpression(expr, nullptr, returnTypeAnnotation, false); diff --git a/es2panda/parser/statementParser.cpp b/es2panda/parser/statementParser.cpp index 1768922cea..f5c91da85a 100644 --- a/es2panda/parser/statementParser.cpp +++ b/es2panda/parser/statementParser.cpp @@ -132,6 +132,8 @@ bool ParserImpl::IsLabelFollowedByIterationStatement() lexer_->NextToken(); return IsLabelFollowedByIterationStatement(); } + + [[fallthrough]]; } default: return false; diff --git a/es2panda/scripts/gen_isa.sh b/es2panda/scripts/gen_isa.sh index 28ab703f1b..28a7938f7d 100755 --- a/es2panda/scripts/gen_isa.sh +++ b/es2panda/scripts/gen_isa.sh @@ -45,7 +45,7 @@ do esac done -if [ ! -d ${OUTDIR} ]; then +if [ ! -d "${OUTDIR}" ]; then mkdir -p ${OUTDIR} fi echo "${GENERATOR} --template ${TEMPLATE} --data ${DATA} --output ${OUTDIR}/${OUTPUT} --require ${REQUIRE}" diff --git a/es2panda/scripts/gen_keywords.sh b/es2panda/scripts/gen_keywords.sh index 43f4069f46..5fd915a446 100755 --- a/es2panda/scripts/gen_keywords.sh +++ b/es2panda/scripts/gen_keywords.sh @@ -39,7 +39,7 @@ do esac done -if [ ! -d ${OUTDIR} ]; then +if [ ! -d "${OUTDIR}" ]; then mkdir -p ${OUTDIR} fi diff --git a/es2panda/test/runner.py b/es2panda/test/runner.py index 1920314b73..ea03d3ac80 100755 --- a/es2panda/test/runner.py +++ b/es2panda/test/runner.py @@ -222,7 +222,7 @@ class Test262Test(Test): cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=runner.cmd_env) try: - out, err = process.communicate(runner.args.es2panda_timeout) + output_res, err = process.communicate(runner.args.es2panda_timeout) except subprocess.TimeoutExpired: process.kill() self.passed = False @@ -230,7 +230,7 @@ class Test262Test(Test): self.error = self.fail_kind.name return self - out = out.decode("utf-8", errors="ignore") + out = output_res.decode("utf-8", errors="ignore") err = err.decode("utf-8", errors="ignore") self.passed, need_exec = runner.util.validate_parse_result( process.returncode, err, desc, out) @@ -742,8 +742,6 @@ class TSCRunner(Runner): files = glob(glob_expression, recursive=True) files = fnmatch.filter(files, ts_suite_dir + '**' + self.args.filter) - failed_references = open(path.join(self.test_root, 'test_tsc_ignore_list.txt'), 'r').read() - for f in files: test_name = path.basename(f.split(".ts")[0]) negative_references = path.join( @@ -763,9 +761,10 @@ class TSCRunner(Runner): if is_negative or "filename" in test.options: continue - if self.args.skip: - if path.relpath(f, self.tsc_path) in failed_references: - continue + with open(path.join(self.test_root, 'test_tsc_ignore_list.txt'), 'r') as failed_references: + if self.args.skip: + if path.relpath(f, self.tsc_path) in failed_references.read(): + continue self.tests.append(test) diff --git a/es2panda/util/base64.cpp b/es2panda/util/base64.cpp index 2e691df234..d727917242 100644 --- a/es2panda/util/base64.cpp +++ b/es2panda/util/base64.cpp @@ -77,7 +77,10 @@ std::string Base64Decode(const std::string &base64String) decodedStrLen -= std::string("=").length(); } std::string decodedRes = std::string(decodedStrLen, '\0'); - int firstChar, secondChar, thirdChar, fourthChar = 0; + int firstChar = 0; + int secondChar = 0; + int thirdChar = 0; + int fourthChar = 0; for (size_t i = 0, j = 0; i < strLen - 2; i += TRANSFORMED_CHAR_NUM, j += TO_TRANSFORM_CHAR_NUM) { firstChar = decodeTable[static_cast(base64String[i])]; secondChar = decodeTable[static_cast(base64String[i + 1])]; diff --git a/es2panda/util/concurrent.cpp b/es2panda/util/concurrent.cpp index d6959c30ed..3b5e953e1c 100644 --- a/es2panda/util/concurrent.cpp +++ b/es2panda/util/concurrent.cpp @@ -97,7 +97,7 @@ void Concurrent::ThrowInvalidConcurrentFunction(const lexer::LineIndex &lineInde } void Concurrent::VerifyImportVarForConcurrentFunction(const lexer::LineIndex &lineIndex, const ir::AstNode *node, - const binder::ScopeFindResult &result) + const binder::ScopeFindResult &result) { if (!result.crossConcurrent) { return; diff --git a/test262/run_sunspider.py b/test262/run_sunspider.py index ce5bce3555..949ecd3f17 100755 --- a/test262/run_sunspider.py +++ b/test262/run_sunspider.py @@ -128,7 +128,7 @@ def exec_command(cmd_args, timeout=DEFAULT_TIMEOUT): code_format = 'gbk' try: - (msg, errs) = proc.communicate(timeout=timeout) + (output_res, errs) = proc.communicate(timeout=timeout) ret_code = proc.poll() if errs.decode(code_format, 'ignore') != '': @@ -141,7 +141,7 @@ def exec_command(cmd_args, timeout=DEFAULT_TIMEOUT): msg += f"error: {str(errs.decode(code_format,'ignore'))}" else: code = 0 - msg = str(msg.decode(code_format, 'ignore')) + msg = str(output_res.decode(code_format, 'ignore')) except subprocess.TimeoutExpired: proc.kill() -- Gitee