From ef90b48a9b809308daea8c282bd5c8ddde622b05 Mon Sep 17 00:00:00 2001 From: jiangkaiwen Date: Wed, 21 Sep 2022 12:01:23 +0800 Subject: [PATCH] Fix codecheck warnings of the 0913 branch 1. Override modifies virtual functions 2. The function declaration is consistent with the defined parameters 3. Namespace encapsulates functions that do not need to be exported 4. Single parameter constructors are declared explicit Issue:I5S8D8 Signed-off-by: jiangkaiwen Change-Id: Ic705c5cdd0ba6881adc611cde1c10245ee7278ae --- es2panda/compiler/core/compileQueue.h | 10 +++--- es2panda/es2panda.h | 2 +- es2panda/parser/parserImpl.h | 2 +- es2panda/util/symbolTable.h | 4 +-- ts2panda/ts2abc/main.cpp | 50 ++++++++++++++------------- 5 files changed, 35 insertions(+), 33 deletions(-) diff --git a/es2panda/compiler/core/compileQueue.h b/es2panda/compiler/core/compileQueue.h index 17392fe4a0..fe1f0da290 100644 --- a/es2panda/compiler/core/compileQueue.h +++ b/es2panda/compiler/core/compileQueue.h @@ -55,7 +55,7 @@ public: explicit CompileFunctionJob(CompilerContext *context) : context_(context) {}; NO_COPY_SEMANTIC(CompileFunctionJob); NO_MOVE_SEMANTIC(CompileFunctionJob); - ~CompileFunctionJob() = default; + ~CompileFunctionJob() override = default; binder::FunctionScope *Scope() const { @@ -79,7 +79,7 @@ public: explicit CompileModuleRecordJob(CompilerContext *context) : context_(context) {}; NO_COPY_SEMANTIC(CompileModuleRecordJob); NO_MOVE_SEMANTIC(CompileModuleRecordJob); - ~CompileModuleRecordJob() = default; + ~CompileModuleRecordJob() override = default; void Run() override; @@ -95,7 +95,7 @@ public: : src_(src), options_(options), progsInfo_(progsInfo), symbolTable_(symbolTable), allocator_(allocator) {}; NO_COPY_SEMANTIC(CompileFileJob); NO_MOVE_SEMANTIC(CompileFileJob); - ~CompileFileJob() = default; + ~CompileFileJob() override = default; void Run() override; @@ -140,7 +140,7 @@ public: NO_COPY_SEMANTIC(CompileFuncQueue); NO_MOVE_SEMANTIC(CompileFuncQueue); - ~CompileFuncQueue() = default; + ~CompileFuncQueue() override = default; void Schedule() override; @@ -158,7 +158,7 @@ public: NO_COPY_SEMANTIC(CompileFileQueue); NO_MOVE_SEMANTIC(CompileFileQueue); - ~CompileFileQueue() = default; + ~CompileFileQueue() override = default; void Schedule() override; diff --git a/es2panda/es2panda.h b/es2panda/es2panda.h index c6144e2e6f..9478bef35b 100644 --- a/es2panda/es2panda.h +++ b/es2panda/es2panda.h @@ -163,7 +163,7 @@ public: panda::pandasm::Program *Compile(const SourceFile &input, const CompilerOptions &options, util::SymbolTable *symbolTable = nullptr); - panda::pandasm::Program *CompileFile(CompilerOptions &options, SourceFile *src, util::SymbolTable *symbolTable_); + panda::pandasm::Program *CompileFile(CompilerOptions &options, SourceFile *src, util::SymbolTable *symbolTable); static int CompileFiles(CompilerOptions &options, std::map *cacheProgs, diff --git a/es2panda/parser/parserImpl.h b/es2panda/parser/parserImpl.h index 974a6a0baa..ff4a6e6653 100644 --- a/es2panda/parser/parserImpl.h +++ b/es2panda/parser/parserImpl.h @@ -282,7 +282,7 @@ private: ir::Statement *ParseClassProperty(ClassElmentDescriptor *desc, const ArenaVector &properties, ir::Expression *propName, ir::Expression *typeAnnotation, ArenaVector &&decorators, bool isDeclare); - void ParseClassKeyModifiers(ClassElmentDescriptor *descy); + void ParseClassKeyModifiers(ClassElmentDescriptor *desc); void CheckClassGeneratorMethod(ClassElmentDescriptor *desc); void CheckClassPrivateIdentifier(ClassElmentDescriptor *desc); ir::Expression *ParseClassKeyAnnotation(); diff --git a/es2panda/util/symbolTable.h b/es2panda/util/symbolTable.h index 518a1c7142..863f71f177 100644 --- a/es2panda/util/symbolTable.h +++ b/es2panda/util/symbolTable.h @@ -33,8 +33,8 @@ public: ArenaMap> lexenv; // lexenv: > ArenaMap classHash; - OriginFunctionInfo(ArenaAllocator *allocator) : lexenv(allocator->Adapter()), - classHash(allocator->Adapter()) {} + explicit OriginFunctionInfo(ArenaAllocator *allocator) : lexenv(allocator->Adapter()), + classHash(allocator->Adapter()) {} }; SymbolTable(const std::string &inputSymbolTable, const std::string &dumpSymbolTable) diff --git a/ts2panda/ts2abc/main.cpp b/ts2panda/ts2abc/main.cpp index c284060058..3968658c84 100644 --- a/ts2panda/ts2abc/main.cpp +++ b/ts2panda/ts2abc/main.cpp @@ -20,33 +20,35 @@ #include "ts2abc_options.h" #include "ts2abc.h" -int Preprocess(const panda::ts2abc::Options &options, const panda::PandArgParser &argParser, std::string &output, - std::string &data, const std::string &usage) -{ - std::string input; - if (!options.GetCompileByPipeArg()) { - input = options.GetTailArg1(); - output = options.GetTailArg2(); - if (input.empty() || output.empty()) { - std::cerr << "Incorrect args number" << std::endl; - std::cerr << "Usage example: ts2abc test.json test.abc"<< std::endl; - std::cerr << usage << std::endl; - std::cerr << argParser.GetHelpString(); - return panda::ts2abc::RETURN_FAILED; - } +namespace { + int Preprocess(const panda::ts2abc::Options &options, const panda::PandArgParser &argParser, std::string &output, + std::string &data, const std::string &usage) + { + std::string input; + if (!options.GetCompileByPipeArg()) { + input = options.GetTailArg1(); + output = options.GetTailArg2(); + if (input.empty() || output.empty()) { + std::cerr << "Incorrect args number" << std::endl; + std::cerr << "Usage example: ts2abc test.json test.abc"<< std::endl; + std::cerr << usage << std::endl; + std::cerr << argParser.GetHelpString(); + return panda::ts2abc::RETURN_FAILED; + } - if (!panda::ts2abc::HandleJsonFile(input, data)) { - return panda::ts2abc::RETURN_FAILED; - } - } else { - output = options.GetTailArg1(); - if (output.empty()) { - std::cerr << usage << std::endl; - std::cerr << argParser.GetHelpString(); - return panda::ts2abc::RETURN_FAILED; + if (!panda::ts2abc::HandleJsonFile(input, data)) { + return panda::ts2abc::RETURN_FAILED; + } + } else { + output = options.GetTailArg1(); + if (output.empty()) { + std::cerr << usage << std::endl; + std::cerr << argParser.GetHelpString(); + return panda::ts2abc::RETURN_FAILED; + } } + return panda::ts2abc::RETURN_SUCCESS; } - return panda::ts2abc::RETURN_SUCCESS; } int main(int argc, const char *argv[]) -- Gitee