diff --git a/binder/binder.h b/binder/binder.h index 28f4b038d2ecfe000b020cd6552496d5d681d9d0..10d52ef951c5dca86d64509b83724fa55e8b4b6e 100644 --- a/binder/binder.h +++ b/binder/binder.h @@ -50,10 +50,10 @@ public: void IdentifierAnalysis(); template - T *AddDecl(const lexer::SourcePosition &pos, Args &&... args); + T *AddDecl(const lexer::SourcePosition &pos, Args &&...args); template - T *AddTsDecl(const lexer::SourcePosition &pos, Args &&... args); + T *AddTsDecl(const lexer::SourcePosition &pos, Args &&...args); ParameterDecl *AddParamDecl(const ir::AstNode *param); @@ -144,7 +144,7 @@ template class LexicalScope { public: template - explicit LexicalScope(Binder *binder, Args &&... args) + explicit LexicalScope(Binder *binder, Args &&...args) : LexicalScope(binder->Allocator()->New(binder->Allocator(), binder->scope_, std::forward(args)...), binder) { @@ -183,7 +183,7 @@ private: }; template -T *Binder::AddTsDecl(const lexer::SourcePosition &pos, Args &&... args) +T *Binder::AddTsDecl(const lexer::SourcePosition &pos, Args &&...args) { T *decl = Allocator()->New(std::forward(args)...); @@ -195,7 +195,7 @@ T *Binder::AddTsDecl(const lexer::SourcePosition &pos, Args &&... args) } template -T *Binder::AddDecl(const lexer::SourcePosition &pos, Args &&... args) +T *Binder::AddDecl(const lexer::SourcePosition &pos, Args &&...args) { T *decl = Allocator()->New(std::forward(args)...); diff --git a/binder/scope.h b/binder/scope.h index 9621858f36bc2b887ed1fcbdbfc61b26cdb6b729..881abfb48ec6e46b012a7ed05f2cb1b43acdbad8 100644 --- a/binder/scope.h +++ b/binder/scope.h @@ -179,7 +179,7 @@ public: } template - T *NewDecl(ArenaAllocator *allocator, Args &&... args); + T *NewDecl(ArenaAllocator *allocator, Args &&...args); template VariableType *AddDecl(ArenaAllocator *allocator, util::StringView name, VariableFlags flags); @@ -189,7 +189,7 @@ public: const ir::AstNode *node); template - void PropagateBinding(ArenaAllocator *allocator, util::StringView name, Args &&... args); + void PropagateBinding(ArenaAllocator *allocator, util::StringView name, Args &&...args); VariableMap &Bindings() { @@ -691,7 +691,7 @@ bool VariableScope::AddLexical(ArenaAllocator *allocator, Variable *currentVaria } template -T *Scope::NewDecl(ArenaAllocator *allocator, Args &&... args) +T *Scope::NewDecl(ArenaAllocator *allocator, Args &&...args) { T *decl = allocator->New(std::forward(args)...); decls_.push_back(decl); @@ -726,7 +726,7 @@ VariableType *Scope::CreateVar(ArenaAllocator *allocator, util::StringView name, } template -void Scope::PropagateBinding(ArenaAllocator *allocator, util::StringView name, Args &&... args) +void Scope::PropagateBinding(ArenaAllocator *allocator, util::StringView name, Args &&...args) { auto res = bindings_.find(name); if (res == bindings_.end()) { diff --git a/compiler/core/pandagen.h b/compiler/core/pandagen.h index 6041544cfb62254a1200217d303753fa5f8646dc..ee623bd7fb247d7adb176af4a116a57d9a680fb5 100644 --- a/compiler/core/pandagen.h +++ b/compiler/core/pandagen.h @@ -76,7 +76,6 @@ public: explicit PandaGen(ArenaAllocator *allocator, CompilerContext *context, binder::FunctionScope *scope) : allocator_(allocator), context_(context), - builder_(nullptr), debugInfo_(allocator_), topScope_(scope), scope_(topScope_), @@ -387,7 +386,7 @@ public: private: ArenaAllocator *allocator_; CompilerContext *context_; - FunctionBuilder *builder_; + FunctionBuilder *builder_ {nullptr}; DebugInfo debugInfo_; binder::FunctionScope *topScope_; binder::Scope *scope_; diff --git a/compiler/core/regAllocator.h b/compiler/core/regAllocator.h index ec7bfefc6382d6886e243e69f430db24178f97a5..da5eeffecfb7646ce4fdbc314bf26d6dddc792a6 100644 --- a/compiler/core/regAllocator.h +++ b/compiler/core/regAllocator.h @@ -39,13 +39,13 @@ protected: ArenaAllocator *Allocator() const; template - T *Alloc(const ir::AstNode *node, Args &&... args) + T *Alloc(const ir::AstNode *node, Args &&...args) { return Allocator()->New(node, std::forward(args)...); } template - void Add(const ir::AstNode *node, Args &&... args) + void Add(const ir::AstNode *node, Args &&...args) { return PushBack(Alloc(node, std::forward(args)...)); } @@ -67,7 +67,7 @@ public: } template - void Emit(const ir::AstNode *node, Args &&... args) + void Emit(const ir::AstNode *node, Args &&...args) { Add(node, std::forward(args)...); } @@ -134,7 +134,7 @@ public: ~RegAllocator() = default; template - void Emit(const ir::AstNode *node, Args &&... args) + void Emit(const ir::AstNode *node, Args &&...args) { auto *ins = Alloc(node, std::forward(args)...); Run(ins); @@ -152,7 +152,7 @@ public: ~RangeRegAllocator() = default; template - void Emit(const ir::AstNode *node, VReg rangeStart, size_t argCount, Args &&... args) + void Emit(const ir::AstNode *node, VReg rangeStart, size_t argCount, Args &&...args) { auto *ins = Alloc(node, std::forward(args)...); Run(ins, rangeStart, argCount); diff --git a/ir/astDump.cpp b/ir/astDump.cpp index acf37c7a810573771499467b9bee437e1459dd46..fceef8a07d6403e62feb7cf0480780cf407393f2 100644 --- a/ir/astDump.cpp +++ b/ir/astDump.cpp @@ -22,7 +22,7 @@ namespace panda::es2panda::ir { -AstDumper::AstDumper(const BlockStatement *program, util::StringView sourceCode) : index_(sourceCode), indent_(0) +AstDumper::AstDumper(const BlockStatement *program, util::StringView sourceCode) : index_(sourceCode) { SerializeObject(reinterpret_cast(program)); } diff --git a/ir/astDump.h b/ir/astDump.h index ece0397babc56562c32c74e1cf5f62297cf41b65..76564e60914ade1060711dcaadcd1749f5a06422 100644 --- a/ir/astDump.h +++ b/ir/astDump.h @@ -199,7 +199,7 @@ private: lexer::LineIndex index_; std::stringstream ss_; - int32_t indent_; + int32_t indent_ {0}; }; } // namespace panda::es2panda::ir diff --git a/ir/base/scriptFunction.h b/ir/base/scriptFunction.h index b0b1e9403e127baf55fd80de9eb388a02eb1a3ca..3e3a35ed94b630cf718840c0b840a5645e111ea6 100644 --- a/ir/base/scriptFunction.h +++ b/ir/base/scriptFunction.h @@ -43,7 +43,6 @@ public: ir::ScriptFunctionFlags flags, bool declare) : AstNode(AstNodeType::SCRIPT_FUNCTION), scope_(scope), - id_(nullptr), params_(std::move(params)), typeParams_(typeParams), body_(body), @@ -152,7 +151,7 @@ public: private: binder::FunctionScope *scope_; - Identifier *id_; + Identifier *id_ {nullptr}; ArenaVector params_; TSTypeParameterDeclaration *typeParams_; AstNode *body_; diff --git a/ir/expressions/arrayExpression.h b/ir/expressions/arrayExpression.h index bd9265db3a83fe204f35433952b95276fabb3161..895ba8493a6bd4bf03385739e57ba12dbe4dfd6d 100644 --- a/ir/expressions/arrayExpression.h +++ b/ir/expressions/arrayExpression.h @@ -34,7 +34,7 @@ namespace panda::es2panda::ir { class ArrayExpression : public Expression { public: explicit ArrayExpression(AstNodeType nodeType, ArenaVector &&elements, bool trailingComma) - : Expression(nodeType), elements_(std::move(elements)), typeAnnotation_(nullptr), trailingComma_(trailingComma) + : Expression(nodeType), elements_(std::move(elements)), trailingComma_(trailingComma) { } @@ -84,7 +84,7 @@ public: private: ArenaVector elements_; - Expression *typeAnnotation_; + Expression *typeAnnotation_ {nullptr}; bool isDeclaration_ {}; bool trailingComma_; bool optional_ {false}; diff --git a/ir/expressions/objectExpression.h b/ir/expressions/objectExpression.h index d09eec73d006f31d0a4aa9dd6e0e35b89852368e..741db11cd4ea56d50e3d6de3160fdde919ce11fd 100644 --- a/ir/expressions/objectExpression.h +++ b/ir/expressions/objectExpression.h @@ -39,10 +39,7 @@ namespace panda::es2panda::ir { class ObjectExpression : public Expression { public: explicit ObjectExpression(AstNodeType nodeType, ArenaVector &&properties, bool trailingComma) - : Expression(nodeType), - properties_(std::move(properties)), - typeAnnotation_(nullptr), - trailingComma_(trailingComma) + : Expression(nodeType), properties_(std::move(properties)), trailingComma_(trailingComma) { } @@ -84,7 +81,7 @@ private: void CompileRemainingProperties(compiler::PandaGen *pg, const util::BitSet *compiled, compiler::VReg objReg) const; ArenaVector properties_; - Expression *typeAnnotation_; + Expression *typeAnnotation_ {nullptr}; bool isDeclaration_ {}; bool trailingComma_ {}; bool optional_ {false}; diff --git a/ir/ts/tsMappedType.cpp b/ir/ts/tsMappedType.cpp index 7be2950b1057f39ea839231201912c59ab1367bf..9fd99c5a71ea2b5571e8553940b766b072514ec0 100644 --- a/ir/ts/tsMappedType.cpp +++ b/ir/ts/tsMappedType.cpp @@ -30,16 +30,15 @@ void TSMappedType::Iterate(const NodeTraverser &cb) const void TSMappedType::Dump(ir::AstDumper *dumper) const { - dumper->Add( - {{"type", "TSMappedType"}, - {"typeParameter", typeParameter_}, - {"typeAnnotation", AstDumper::Optional(typeAnnotation_)}, - {"readonly", readonly_ == MappedOption::NO_OPTS - ? AstDumper::Optional(false) - : readonly_ == MappedOption::PLUS ? AstDumper::Optional("+") : AstDumper::Optional("-")}, - {"optional", optional_ == MappedOption::NO_OPTS - ? AstDumper::Optional(false) - : optional_ == MappedOption::PLUS ? AstDumper::Optional("+") : AstDumper::Optional("-")}}); + dumper->Add({{"type", "TSMappedType"}, + {"typeParameter", typeParameter_}, + {"typeAnnotation", AstDumper::Optional(typeAnnotation_)}, + {"readonly", readonly_ == MappedOption::NO_OPTS ? AstDumper::Optional(false) + : readonly_ == MappedOption::PLUS ? AstDumper::Optional("+") + : AstDumper::Optional("-")}, + {"optional", optional_ == MappedOption::NO_OPTS ? AstDumper::Optional(false) + : optional_ == MappedOption::PLUS ? AstDumper::Optional("+") + : AstDumper::Optional("-")}}); } void TSMappedType::Compile([[maybe_unused]] compiler::PandaGen *pg) const {} diff --git a/ir/ts/tsParameterProperty.cpp b/ir/ts/tsParameterProperty.cpp index a1583d5a6a8d75887c2355684e9fd37c00ad3916..23cf6dc433e9df876a53ebe7b2cb223bd77a6d05 100644 --- a/ir/ts/tsParameterProperty.cpp +++ b/ir/ts/tsParameterProperty.cpp @@ -26,17 +26,15 @@ void TSParameterProperty::Iterate(const NodeTraverser &cb) const void TSParameterProperty::Dump(ir::AstDumper *dumper) const { - dumper->Add( - {{"type", "TSParameterProperty"}, - {"accessibility", accessibility_ == AccessibilityOption::PUBLIC - ? "public" - : accessibility_ == AccessibilityOption::PRIVATE - ? "private" - : accessibility_ == AccessibilityOption::PROTECTED ? "protected" : "undefined"}, - {"readonly", readonly_}, - {"static", static_}, - {"export", export_}, - {"parameter", parameter_}}); + dumper->Add({{"type", "TSParameterProperty"}, + {"accessibility", accessibility_ == AccessibilityOption::PUBLIC ? "public" + : accessibility_ == AccessibilityOption::PRIVATE ? "private" + : accessibility_ == AccessibilityOption::PROTECTED ? "protected" + : "undefined"}, + {"readonly", readonly_}, + {"static", static_}, + {"export", export_}, + {"parameter", parameter_}}); } void TSParameterProperty::Compile([[maybe_unused]] compiler::PandaGen *pg) const {} diff --git a/lexer/regexp/regexp.cpp b/lexer/regexp/regexp.cpp index 7058ffc8eac32fa5cf216ab7e11c02fc044d1519..6140f2940ab13a35c0f49226124cef34a4282353 100644 --- a/lexer/regexp/regexp.cpp +++ b/lexer/regexp/regexp.cpp @@ -29,7 +29,7 @@ RegExp::RegExp(util::StringView p, util::StringView f, RegExpFlags reFlags) : pa } RegExpParser::RegExpParser(const RegExp &re, ArenaAllocator *allocator) - : re_(re), allocator_ {allocator}, iter_(re_.patternStr), capturingGroupCount_(0) + : re_(re), allocator_ {allocator}, iter_(re_.patternStr) { } diff --git a/lexer/regexp/regexp.h b/lexer/regexp/regexp.h index 513c3405188ab5dcaed74db76a1fedf6fa150b8e..e6a4be21a052bcfede31cc667133316df6c9af6c 100644 --- a/lexer/regexp/regexp.h +++ b/lexer/regexp/regexp.h @@ -96,7 +96,7 @@ private: RegExp re_; ArenaAllocator *allocator_ {}; util::StringView::Iterator iter_; - uint32_t capturingGroupCount_; + uint32_t capturingGroupCount_ {0}; std::unordered_set groupNames_; }; diff --git a/parser/parserImpl.cpp b/parser/parserImpl.cpp index 6ecfc77b84dcbe26126be64ed45012ace09a8a34..87204a430fb3992a882b68eb80f0ec50d7c4f0cb 100644 --- a/parser/parserImpl.cpp +++ b/parser/parserImpl.cpp @@ -3208,10 +3208,12 @@ bool ParserImpl::CurrentTokenIsModifier(char32_t nextCp) const void ParserImpl::ThrowParameterModifierError(ir::ModifierFlags status) const { - ThrowSyntaxError( - {"'", status & ir::ModifierFlags::STATIC ? "static" : status & ir::ModifierFlags::ASYNC ? "async" : "declare", - "' modifier cannot appear on a parameter."}, - lexer_->GetToken().Start()); + ThrowSyntaxError({"'", + status & ir::ModifierFlags::STATIC ? "static" + : status & ir::ModifierFlags::ASYNC ? "async" + : "declare", + "' modifier cannot appear on a parameter."}, + lexer_->GetToken().Start()); } void ParserImpl::ThrowSyntaxError(std::string_view errorMessage) const diff --git a/parser/parserImpl.h b/parser/parserImpl.h index e73468a66427f1e910a1fc4261bc6cc2c7e85ebe..2d8f1fa250875db003f5aaacde389495e0fabe2d 100644 --- a/parser/parserImpl.h +++ b/parser/parserImpl.h @@ -195,7 +195,7 @@ private: [[noreturn]] void ThrowSyntaxError(std::string_view errorMessage, const lexer::SourcePosition &pos) const; template - T *AllocNode(Args &&... args) + T *AllocNode(Args &&...args) { auto ret = program_.Allocator()->New(std::forward(args)...); if (ret == nullptr) { @@ -555,7 +555,7 @@ private: class SavedParserContext { public: template - explicit SavedParserContext(ParserImpl *parser, Args &&... args) : parser_(parser), prev_(parser->context_) + explicit SavedParserContext(ParserImpl *parser, Args &&...args) : parser_(parser), prev_(parser->context_) { parser_->context_ = ParserContext(&prev_, std::forward(args)...); } diff --git a/typescript/types/tupleType.cpp b/typescript/types/tupleType.cpp index 58b4acc91f0d964ed04c7bd478121063b5acd5b2..d0a8597ee4e8f40aeaa3c44f4ca2817a6a0d7fcf 100644 --- a/typescript/types/tupleType.cpp +++ b/typescript/types/tupleType.cpp @@ -19,7 +19,7 @@ namespace panda::es2panda::checker { -TupleTypeIterator::TupleTypeIterator(TupleType *tuple) : tupleType_(tuple), iter_(0) {} +TupleTypeIterator::TupleTypeIterator(TupleType *tuple) : tupleType_(tuple) {} Type *TupleTypeIterator::Next() { diff --git a/typescript/types/tupleType.h b/typescript/types/tupleType.h index 241cf60ad5067240a0c5950a20c0ffd661a3278c..e64a7009f5cb401e5a4e3f789eabf4c056f2243b 100644 --- a/typescript/types/tupleType.h +++ b/typescript/types/tupleType.h @@ -36,7 +36,7 @@ public: private: TupleType *tupleType_; - uint32_t iter_; + uint32_t iter_ {0}; }; using NamedTupleMemberPool = std::unordered_map; diff --git a/typescript/types/type.cpp b/typescript/types/type.cpp index 2b1d8a3647922f326e245f0b4b2967d8124c22a9..38c732ac7a4b971d98c169c7a498df66d6b1f0ae 100644 --- a/typescript/types/type.cpp +++ b/typescript/types/type.cpp @@ -21,7 +21,7 @@ namespace panda::es2panda::checker { -Type::Type(TypeFlag flag) : typeFlags_(flag), variable_(nullptr) +Type::Type(TypeFlag flag) : typeFlags_(flag) { static uint64_t typeId = 0; id_ = ++typeId; diff --git a/typescript/types/type.h b/typescript/types/type.h index 058c2ec7d16890a4ce9c25b6e6afce029bc04f13..7c5f311646903e06fda4a87648d2851c263db4b8 100644 --- a/typescript/types/type.h +++ b/typescript/types/type.h @@ -89,7 +89,7 @@ public: protected: TypeFlag typeFlags_; - binder::Variable *variable_; // Variable associated with the type if any + binder::Variable *variable_ {nullptr}; // Variable associated with the type if any uint64_t id_; }; diff --git a/typescript/types/typeRelation.cpp b/typescript/types/typeRelation.cpp index 6f9d638e7152cbe61fe8b6d6b9f69b26b9523f1a..7bee1301e243d1cd6840946ffdf474a510d78a2e 100644 --- a/typescript/types/typeRelation.cpp +++ b/typescript/types/typeRelation.cpp @@ -26,7 +26,7 @@ const Type *AsSrc::GetType() const return type_; } -TypeRelation::TypeRelation(Checker *checker) : checker_(checker), result_(RelationResult::FALSE) {} +TypeRelation::TypeRelation(Checker *checker) : checker_(checker) {} bool TypeRelation::IsTrue() const { diff --git a/typescript/types/typeRelation.h b/typescript/types/typeRelation.h index 27bc93180bd8746f0dffe02d55cd6633ec1775ce..9591841a371c0b4afd0c495945fff2bd27bac1e1 100644 --- a/typescript/types/typeRelation.h +++ b/typescript/types/typeRelation.h @@ -104,7 +104,7 @@ private: RelationType type) const; Checker *checker_; - RelationResult result_; + RelationResult result_ {RelationResult::FALSE}; }; } // namespace panda::es2panda::checker