diff --git a/ets2panda/checker/ETSAnalyzer.cpp b/ets2panda/checker/ETSAnalyzer.cpp index 716609bc6d72f12ae724ccf726be9ec6f9bb0e48..4498536bb1f300d01c8b1a2ba89667e544d50c3f 100644 --- a/ets2panda/checker/ETSAnalyzer.cpp +++ b/ets2panda/checker/ETSAnalyzer.cpp @@ -3478,7 +3478,8 @@ checker::Type *ETSAnalyzer::Check(ir::ForOfStatement *const st) const static bool HasMissingInitOrType(ir::VariableDeclaration *varDecl, ETSChecker *checker) { for (auto *decl : varDecl->Declarators()) { - if (decl->Id()->IsIdentifier() && !decl->Id()->AsIdentifier()->TypeAnnotation() && !decl->Init()) { + if (decl->Id()->IsIdentifier() && (decl->Id()->AsIdentifier()->TypeAnnotation() == nullptr) && + (decl->Init() == nullptr)) { auto *ident = decl->Id()->AsIdentifier(); checker->LogError(diagnostic::MISSING_INIT_OR_TYPE, {}, ident->Start()); return true; diff --git a/ets2panda/checker/ets/function.cpp b/ets2panda/checker/ets/function.cpp index 7034998575815c6518c0c4014ccf070c8b323e2e..2643ee7f1b29e25283309e2b118bf9162aa1d565 100644 --- a/ets2panda/checker/ets/function.cpp +++ b/ets2panda/checker/ets/function.cpp @@ -233,7 +233,7 @@ static void ResetInferredTypeInArrowBody(ir::AstNode *body, ETSChecker *checker, std::function doNode = [&](ir::AstNode *node) { if (node->IsIdentifier()) { auto *id = node->AsIdentifier(); - if (!inferredVarSet.count(id->Variable())) { + if (inferredVarSet.count(id->Variable()) == 0U) { return; } diff --git a/ets2panda/checker/ets/typeCreation.cpp b/ets2panda/checker/ets/typeCreation.cpp index 5fd4e60ce56757d80e59e749dc3be8123fe064a2..e9fa26308f58a54379107de036c4787763b43164 100644 --- a/ets2panda/checker/ets/typeCreation.cpp +++ b/ets2panda/checker/ets/typeCreation.cpp @@ -414,7 +414,8 @@ ETSObjectType *ETSChecker::CreateETSObjectType( if (declNode->IsClassDefinition() && (declNode->AsClassDefinition()->IsEnumTransformed())) { if (declNode->AsClassDefinition()->IsIntEnumTransformed()) { return allocator->New(allocator, name, internalName, declNode, relation); - } else if (declNode->AsClassDefinition()->IsDoubleEnumTransformed()) { + } + if (declNode->AsClassDefinition()->IsDoubleEnumTransformed()) { return ProgramAllocator()->New(ProgramAllocator(), name, internalName, declNode, Relation()); } diff --git a/ets2panda/compiler/core/ETSemitter.cpp b/ets2panda/compiler/core/ETSemitter.cpp index 533858140318458728d94d75366ec0dd1a279a44..ce5ba4ffed1a9ed42a0dbde04652c024c93b0a7b 100644 --- a/ets2panda/compiler/core/ETSemitter.cpp +++ b/ets2panda/compiler/core/ETSemitter.cpp @@ -102,6 +102,7 @@ static uint32_t TranslateModifierFlags(ir::ModifierFlags modifierFlags) namespace detail { // #29438 +// NOLINTNEXTLINE (fuchsia-statically-constructed-objects, cert-err58-cpp) static const std::set AOT_WORKAROUND_BLACKLIST { "std.core.String", "std.core.String[]", "std.core.Object", "std.core.Object[]", "std.core.StringBuilder", }; @@ -148,6 +149,7 @@ public: } std::swap(toEmit_, diff); } + ~EmitterDependencies() = default; private: std::unordered_set reachable_ { @@ -265,9 +267,7 @@ ETSEmitter::ETSEmitter(const public_lib::Context *context) { } -ETSEmitter::~ETSEmitter() { - // for PImpl -}; +ETSEmitter::~ETSEmitter() = default; std::string const &ETSEmitter::AddDependence(std::string const &str) { @@ -749,7 +749,7 @@ void ETSEmitter::GenClassRecord(const ir::ClassDefinition *classDef, bool extern } if (!annotations.empty() && !classDef->IsLazyImportObjectClass()) { - classRecord.metadata->AddAnnotations(std::move(annotations)); + classRecord.metadata->AddAnnotations(annotations); } Program()->AddToRecordTable(std::move(classRecord)); @@ -979,7 +979,8 @@ static pandasm::AnnotationElement ProcessETSEnumType(std::string &baseName, cons auto enumValue = static_cast(initValue->AsNumberLiteral()->Number().GetInt()); auto intEnumValue = pandasm::ScalarValue::Create(enumValue); return pandasm::AnnotationElement {baseName, std::make_unique(intEnumValue)}; - } else if (type->IsETSDoubleEnumType()) { + } + if (type->IsETSDoubleEnumType()) { auto enumValue = initValue->AsNumberLiteral()->Number().GetDouble(); auto doubleEnumValue = pandasm::ScalarValue::Create(enumValue); return pandasm::AnnotationElement {baseName, std::make_unique(doubleEnumValue)}; diff --git a/ets2panda/compiler/core/ETSemitter.h b/ets2panda/compiler/core/ETSemitter.h index 0346d0b60b0a8675e2e9864ecab43d31ab97667c..bf20b188143ac03ff4248d6c62c3aa716cd6a5eb 100644 --- a/ets2panda/compiler/core/ETSemitter.h +++ b/ets2panda/compiler/core/ETSemitter.h @@ -74,7 +74,7 @@ protected: namespace detail { class EmitterDependencies; -} +} // namespace detail class ETSEmitter : public Emitter { public: @@ -92,7 +92,7 @@ public: std::string const &AddDependence(std::string const &str); private: - void EmitRecordTable(varbinder::RecordTable *recordTable, bool externalize, bool isTraverseExternalsPhase); + void EmitRecordTable(varbinder::RecordTable *table, bool programIsExternal, bool traverseExternals); void GenGlobalArrayRecord(const checker::ETSArrayType *arrayType); void GenGlobalUnionRecord(util::StringView assemblerType); std::vector GenAnnotations(const ir::ClassDefinition *classDef); diff --git a/ets2panda/compiler/lowering/ets/boxingForLocals.cpp b/ets2panda/compiler/lowering/ets/boxingForLocals.cpp index 9ef91f8d7a8ef496c3e1a5ccfe07cb478caa6653..74f2bfa462c39cfe282a91eac8d210dfef774860 100644 --- a/ets2panda/compiler/lowering/ets/boxingForLocals.cpp +++ b/ets2panda/compiler/lowering/ets/boxingForLocals.cpp @@ -199,7 +199,7 @@ static ir::AstNode *HandleVariableDeclarator(public_lib::Context *ctx, ir::Varia auto *scope = oldVar->GetScope(); auto *type = oldVar->TsType(); auto *boxedType = checker->GlobalBuiltinBoxType(type); - bool inForInit = declarator->Parent() && declarator->Parent()->Parent() && + bool inForInit = (declarator->Parent() != nullptr) && (declarator->Parent()->Parent() != nullptr) && declarator->Parent()->Parent()->IsForUpdateStatement(); if (inForInit && oldVar->HasFlag(varbinder::VariableFlags::PER_ITERATION)) { return declarator; diff --git a/ets2panda/compiler/lowering/ets/lambdaLowering.cpp b/ets2panda/compiler/lowering/ets/lambdaLowering.cpp index 333700f333d689afd1d404be033c4d8fe89eb247..100d4e5cfa0d4fa5241f1b16cff4b9f57e8dc108 100644 --- a/ets2panda/compiler/lowering/ets/lambdaLowering.cpp +++ b/ets2panda/compiler/lowering/ets/lambdaLowering.cpp @@ -386,13 +386,14 @@ static ir::MethodDefinition *CheckCalleeMethodCtx(public_lib::Context *ctx, Lamb ir::ScriptFunction *func, ir::MethodDefinition *method) { auto *varBinder = ctx->GetChecker()->VarBinder()->AsETSBinder(); - auto bctx = info->calleeClass + auto bctx = info->calleeClass != nullptr ? varbinder::BoundContext {varBinder->GetRecordTable(), info->calleeClass->Definition(), true} : varbinder::BoundContext {varBinder->GetRecordTable(), info->calleeInterface, true}; varBinder->ResolveReferencesForScopeWithContext(func, func->Scope()); - auto *objType = info->calleeClass ? info->calleeClass->Definition()->TsType()->AsETSObjectType() - : info->calleeInterface->TsType()->AsETSObjectType(); - auto checkerStatus = info->calleeClass ? checker::CheckerStatus::IN_CLASS : checker::CheckerStatus::IN_INTERFACE; + auto *objType = info->calleeClass != nullptr ? info->calleeClass->Definition()->TsType()->AsETSObjectType() + : info->calleeInterface->TsType()->AsETSObjectType(); + auto checkerStatus = + info->calleeClass != nullptr ? checker::CheckerStatus::IN_CLASS : checker::CheckerStatus::IN_INTERFACE; auto checkerCtx = checker::SavedCheckerContext(ctx->GetChecker(), checkerStatus, objType); method->Check(ctx->GetChecker()->AsETSChecker()); return method; @@ -405,12 +406,12 @@ static ir::MethodDefinition *SetUpCalleeMethod(public_lib::Context *ctx, LambdaI auto *allocator = ctx->allocator; auto *varBinder = ctx->GetChecker()->VarBinder()->AsETSBinder(); - auto *objType = info->calleeClass ? info->calleeClass->Definition()->TsType()->AsETSObjectType() - : info->calleeInterface->TsType()->AsETSObjectType(); + auto *objType = info->calleeClass != nullptr ? info->calleeClass->Definition()->TsType()->AsETSObjectType() + : info->calleeInterface->TsType()->AsETSObjectType(); auto *funcScope = func->Scope(); auto *paramScope = funcScope->ParamScope(); - auto isStatic = ((info->callReceiver != nullptr || info->calleeInterface) ? ir::ModifierFlags::NONE - : ir::ModifierFlags::STATIC); + auto isStatic = ((info->callReceiver != nullptr || info->calleeInterface != nullptr) ? ir::ModifierFlags::NONE + : ir::ModifierFlags::STATIC); auto modifierFlags = ir::ModifierFlags::PUBLIC | isStatic | cmInfo->auxModifierFlags; auto *calleeNameId = allocator->New(cmInfo->calleeName, allocator); @@ -421,7 +422,7 @@ static ir::MethodDefinition *SetUpCalleeMethod(public_lib::Context *ctx, LambdaI auto *funcExpr = util::NodeAllocator::ForceSetParent(allocator, func); auto *method = util::NodeAllocator::ForceSetParent( allocator, ir::MethodDefinitionKind::METHOD, calleeNameClone, funcExpr, modifierFlags, allocator, false); - if (info->calleeClass) { + if (info->calleeClass != nullptr) { info->calleeClass->Definition()->EmplaceBody(method); method->SetParent(info->calleeClass->Definition()); } else { @@ -455,8 +456,8 @@ static ir::MethodDefinition *CreateCalleeMethod(public_lib::Context *ctx, ir::Ar auto *varBinder = ctx->GetChecker()->VarBinder()->AsETSBinder(); auto *checker = ctx->GetChecker()->AsETSChecker(); - auto *classScope = info->calleeClass ? info->calleeClass->Definition()->Scope()->AsClassScope() - : info->calleeInterface->Scope()->AsClassScope(); + auto *classScope = info->calleeClass != nullptr ? info->calleeClass->Definition()->Scope()->AsClassScope() + : info->calleeInterface->Scope()->AsClassScope(); auto *oldTypeParams = (info->enclosingFunction != nullptr) ? info->enclosingFunction->TypeParams() : nullptr; auto enclosingScope = @@ -477,7 +478,6 @@ static ir::MethodDefinition *CreateCalleeMethod(public_lib::Context *ctx, ir::Ar auto *returnType = cmInfo->forcedReturnType != nullptr ? cmInfo->forcedReturnType : alternative; auto returnTypeAnnotation = allocator->New(returnType, allocator); - auto funcFlags = ir::ScriptFunctionFlags::METHOD | cmInfo->auxFunctionFlags; auto modifierFlags = cmInfo->auxModifierFlags | ir::ModifierFlags::PUBLIC | (info->callReceiver != nullptr ? ir::ModifierFlags::NONE : ir::ModifierFlags::STATIC); @@ -486,11 +486,12 @@ static ir::MethodDefinition *CreateCalleeMethod(public_lib::Context *ctx, ir::Ar ISS {cmInfo->body, ir::FunctionSignature(newTypeParams, std::move(params), returnTypeAnnotation, lambda->Function()->HasReceiver()), - funcFlags, modifierFlags}); + ir::ScriptFunctionFlags::METHOD | cmInfo->auxFunctionFlags, modifierFlags}); auto *funcScope = cmInfo->body == nullptr ? allocator->New(allocator, paramScope) : cmInfo->body->Scope()->AsFunctionScope(); ES2PANDA_ASSERT(funcScope); - auto *tsType = info->calleeClass ? info->calleeClass->Definition()->TsType() : info->calleeInterface->TsType(); + auto *tsType = + info->calleeClass != nullptr ? info->calleeClass->Definition()->TsType() : info->calleeInterface->TsType(); funcScope->BindName(tsType->AsETSObjectType()->AssemblerName()); func->SetScope(funcScope); ProcessCalleeMethodBody(cmInfo->body, checker, paramScope, &substitution, varMap); @@ -760,6 +761,7 @@ static ir::Expression *SetRestIdentOfCallArguments(public_lib::Context *ctx, Lam auto restType = lciInfo->lambdaSignature->RestVar()->TsType(); if (restType->IsETSTupleType()) { ArenaVector tupleElements(allocator->Adapter()); + // NOLINTNEXTLINE (bugprone-too-small-loop-variable) for (std::uint16_t i = 0; i < restType->AsETSTupleType()->GetTupleSize(); ++i) { auto ident = allocator->New(lciInfo->restParameterIdentifier, allocator); auto number = allocator->New(lexer::Number(i)); diff --git a/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.cpp b/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.cpp index 29e91fdc6d278057e3369e8d35414f8563e7d58a..7f2327787b13a6bea091f15b1ba367e9e07e61dc 100644 --- a/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.cpp +++ b/ets2panda/compiler/lowering/scopesInit/scopesInitPhase.cpp @@ -160,11 +160,12 @@ void ScopesInitPhase::VisitForUpdateStatement(ir::ForUpdateStatement *forUpdateS // CC-OFFNXT(G.FMT.06-CPP) project code style VarBinder(), forUpdateStmt->Scope()->DeclScope()); CallNode(forUpdateStmt->Init()); - if (auto *init = forUpdateStmt->Init(); init && init->IsVariableDeclaration()) { + if (auto *init = forUpdateStmt->Init(); (init != nullptr) && init->IsVariableDeclaration()) { auto *vd = init->AsVariableDeclaration(); for (auto *decl : vd->Declarators()) { - if (!decl->Id()->IsIdentifier()) + if (!decl->Id()->IsIdentifier()) { continue; + } auto *id = decl->Id()->AsIdentifier(); if (auto *var = id->Variable()) { var->AddFlag(varbinder::VariableFlags::PER_ITERATION); diff --git a/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp b/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp index ea6dedaa9f7e8b377d7b93010d975ab4b0212a9f..d2187be6e784b683954365914958f3e165adab2e 100644 --- a/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp +++ b/ets2panda/declgen_ets2ts/declgenEts2Ts.cpp @@ -2502,9 +2502,11 @@ bool TSDeclGen::IsImport(const ir::AstNode *specifier) { if (specifier->IsImportNamespaceSpecifier()) { return IsImport(specifier->AsImportNamespaceSpecifier()->Local()); - } else if (specifier->IsImportDefaultSpecifier()) { + } + if (specifier->IsImportDefaultSpecifier()) { return IsImport(specifier->AsImportDefaultSpecifier()->Local()); - } else if (specifier->IsImportSpecifier()) { + } + if (specifier->IsImportSpecifier()) { return IsImport(specifier->AsImportSpecifier()->Local()); } return false; @@ -2582,11 +2584,14 @@ bool TSDeclGen::IsDependency(const ir::AstNode *decl) if (decl->IsTSTypeAliasDeclaration()) { return IsDependency(decl->AsTSTypeAliasDeclaration()->TypeAnnotation()->TsType()); - } else if (decl->IsClassDeclaration()) { + } + if (decl->IsClassDeclaration()) { return IsDependency(decl->AsClassDeclaration()->Definition()->TsType()); - } else if (decl->IsClassDefinition()) { + } + if (decl->IsClassDefinition()) { return IsDependency(decl->AsClassDefinition()->TsType()); - } else if (decl->IsTSInterfaceDeclaration()) { + } + if (decl->IsTSInterfaceDeclaration()) { return IsDependency(decl->AsTSInterfaceDeclaration()->TsType()); } @@ -2606,7 +2611,8 @@ bool TSDeclGen::IsDependency(const checker::Type *tsType) return false; } return IsDependency(typeName); - } else if (tsType->IsETSUnionType()) { + } + if (tsType->IsETSUnionType()) { const auto unionType = tsType->AsETSUnionType(); bool isDependency = false; GenSeparated( diff --git a/ets2panda/evaluate/entityDeclarator.cpp b/ets2panda/evaluate/entityDeclarator.cpp index 02631fd53dc8ae873c6a7f4811fbfdc58a8f7478..51edc590590ae9fcef27dba56e249d7f26798c14 100644 --- a/ets2panda/evaluate/entityDeclarator.cpp +++ b/ets2panda/evaluate/entityDeclarator.cpp @@ -85,7 +85,7 @@ ir::ETSImportDeclaration *EntityDeclarator::CreateIrImport(util::StringView path auto *imported = checker->AllocNode(classImportedName, allocator); auto *spec = checker->AllocNode(imported, local); ArenaVector specifiers(1, spec, allocator->Adapter()); - + // NOLINTNEXTLINE (performance-move-const-arg) return checker->AllocNode(source, std::move(importMetadata), std::move(specifiers)); } diff --git a/ets2panda/ir/base/methodDefinition.cpp b/ets2panda/ir/base/methodDefinition.cpp index 276232f512a2929f7c6c0fe1512fd4456e1dee46..55dd339d2acd456546c7640478cdfc8f0ee1a78a 100644 --- a/ets2panda/ir/base/methodDefinition.cpp +++ b/ets2panda/ir/base/methodDefinition.cpp @@ -207,10 +207,7 @@ static bool IsNamespaceTransformed(const MethodDefinition *method) // handle overloads parent = parent->Parent(); } - if (parent->IsClassDefinition() && parent->AsClassDefinition()->IsNamespaceTransformed()) { - return true; - } - return false; + return parent->IsClassDefinition() && parent->AsClassDefinition()->IsNamespaceTransformed(); } void MethodDefinition::DumpPrefix(ir::SrcDumper *dumper) const diff --git a/ets2panda/ir/ets/etsImportDeclaration.h b/ets2panda/ir/ets/etsImportDeclaration.h index 598b06f9d8cfa4b630d580b32e7cc5c83361b5ca..7216e93cda40c105d6f06986fc75b2e34ccd4e86 100644 --- a/ets2panda/ir/ets/etsImportDeclaration.h +++ b/ets2panda/ir/ets/etsImportDeclaration.h @@ -29,7 +29,7 @@ class ETSImportDeclaration : public ImportDeclaration { public: ETSImportDeclaration(ir::StringLiteral *importPath, util::ImportPathManager::ImportMetadata &&importMetadata, ArenaVector &&specifiers, const ImportKinds importKinds = ImportKinds::ALL) - : ImportDeclaration(importPath, std::move(specifiers), importKinds), importMetadata_(std::move(importMetadata)) + : ImportDeclaration(importPath, std::move(specifiers), importKinds), importMetadata_(importMetadata) { SetType(AstNodeType::ETS_IMPORT_DECLARATION); } diff --git a/ets2panda/ir/ets/etsIntrinsicNode.cpp b/ets2panda/ir/ets/etsIntrinsicNode.cpp index 82944360eb56d240c4070ac3267b852246a0f105..ce5bc58839fcedafb935aee56d525ffaa9f6ff65 100644 --- a/ets2panda/ir/ets/etsIntrinsicNode.cpp +++ b/ets2panda/ir/ets/etsIntrinsicNode.cpp @@ -55,7 +55,7 @@ class EtsIntrinsicInfo { public: static EtsIntrinsicInfo const *For(util::StringView id) { - if (auto it = infos_.find(id); it != infos_.end()) { + if (auto it = INFOS.find(id); it != INFOS.end()) { return it->second.get(); } return nullptr; @@ -84,6 +84,8 @@ public: EtsIntrinsicInfo() = default; virtual ~EtsIntrinsicInfo() = default; + NO_COPY_SEMANTIC(EtsIntrinsicInfo); + NO_MOVE_SEMANTIC(EtsIntrinsicInfo); protected: virtual void CompileImpl(compiler::ETSGen *etsg, ETSIntrinsicNode const *intrin) const = 0; @@ -116,7 +118,7 @@ private: using InfosMap = std::unordered_map>; static InfosMap InitIntrinsicInfos(); - static const InfosMap infos_; + static const InfosMap INFOS; }; void ETSIntrinsicNode::Compile([[maybe_unused]] compiler::PandaGen *pg) const {} @@ -290,7 +292,7 @@ public: return "anyldbyidx"; } - virtual checker::Type *ExpectedTypeAt(checker::ETSChecker *checker, [[maybe_unused]] size_t idx) const override + checker::Type *ExpectedTypeAt(checker::ETSChecker *checker, [[maybe_unused]] size_t idx) const override { if (idx == 1U) { return checker->GlobalDoubleType(); @@ -332,7 +334,7 @@ public: return "anystbyidx"; } - virtual checker::Type *ExpectedTypeAt(checker::ETSChecker *checker, [[maybe_unused]] size_t idx) const override + checker::Type *ExpectedTypeAt(checker::ETSChecker *checker, [[maybe_unused]] size_t idx) const override { if (idx == 1U) { return checker->GlobalDoubleType(); @@ -446,7 +448,7 @@ public: checker::Type *Check(checker::ETSChecker *checker, ETSIntrinsicNode *intrin) const override { CheckParams(checker, intrin); - if (intrin->Arguments().size() < 1U) { + if (intrin->Arguments().empty()) { return InvalidateIntrinsic(checker, intrin); } return intrin->SetTsType(checker->GlobalETSAnyType()); @@ -478,7 +480,7 @@ public: checker::Type *Check(checker::ETSChecker *checker, ETSIntrinsicNode *intrin) const override { CheckParams(checker, intrin); - if (intrin->Arguments().size() < 1U) { + if (intrin->Arguments().empty()) { return InvalidateIntrinsic(checker, intrin); } return intrin->SetTsType(checker->GlobalETSAnyType()); @@ -566,8 +568,8 @@ public: etsg->EmitAnyIsinstance(intrin, typeReg); } }; - -const EtsIntrinsicInfo::InfosMap EtsIntrinsicInfo::infos_ = EtsIntrinsicInfo::InitIntrinsicInfos(); +// NOLINTNEXTLINE (cert-err58-cpp) +const EtsIntrinsicInfo::InfosMap EtsIntrinsicInfo::INFOS = EtsIntrinsicInfo::InitIntrinsicInfos(); EtsIntrinsicInfo::InfosMap EtsIntrinsicInfo::InitIntrinsicInfos() { diff --git a/ets2panda/ir/srcDump.cpp b/ets2panda/ir/srcDump.cpp index d87e3dd148314dc62b95c3f1a29d533f2b6e49cd..5baba33b42a9ecfae45de059256bd797e46790f9 100644 --- a/ets2panda/ir/srcDump.cpp +++ b/ets2panda/ir/srcDump.cpp @@ -57,7 +57,7 @@ void SrcDumper::Endl([[maybe_unused]] size_t num) static bool OnlySpaces(const std::string &s) { for (char c : s) { - if (!std::isspace(c)) { + if (std::isspace(c) == 0) { return false; } } diff --git a/ets2panda/ir/srcDump.h b/ets2panda/ir/srcDump.h index 59bbf15500fd443e843347fe6960dc6f5916a9c5..87c7db1cda59eaf89fc61042fd3d4388f47e8bf3 100644 --- a/ets2panda/ir/srcDump.h +++ b/ets2panda/ir/srcDump.h @@ -72,6 +72,8 @@ public: { *ambientDeclPtr_ = prev_; } + NO_COPY_SEMANTIC(AmbientContextGuard); + NO_MOVE_SEMANTIC(AmbientContextGuard); private: bool *ambientDeclPtr_; diff --git a/ets2panda/ir/ts/tsInterfaceBody.cpp b/ets2panda/ir/ts/tsInterfaceBody.cpp index cdfe00e7719f34cda928a72915ff421b89d888d5..c98011586e72d10d5c8542bde8639559aae31870 100644 --- a/ets2panda/ir/ts/tsInterfaceBody.cpp +++ b/ets2panda/ir/ts/tsInterfaceBody.cpp @@ -24,8 +24,7 @@ namespace ark::es2panda::ir { void TSInterfaceBody::TransformChildren(const NodeTransformer &cb, std::string_view transformationName) { - for (size_t ix = 0; ix < body_.size(); ix++) { - auto *&it = body_[ix]; + for (auto &it : body_) { if (auto *transformedNode = cb(it); it != transformedNode) { it->SetTransformedNode(transformationName, transformedNode); it = transformedNode; diff --git a/ets2panda/ir/ts/tsTypeAliasDeclaration.cpp b/ets2panda/ir/ts/tsTypeAliasDeclaration.cpp index d19433ee842fc84703ecc01460eb4a0347d1f644..77f8bfe85383d5056295f6b212ee7e11de9de604 100644 --- a/ets2panda/ir/ts/tsTypeAliasDeclaration.cpp +++ b/ets2panda/ir/ts/tsTypeAliasDeclaration.cpp @@ -170,7 +170,7 @@ void TSTypeAliasDeclaration::CopyTo(AstNode *other) const otherImpl->typeParams_ = typeParams_; otherImpl->typeParamTypes_ = typeParamTypes_; - AnnotatedStatement::CopyTo(other); + AnnotatedStatement::CopyTo(other); // NOLINT (bugprone-parent-virtual-call) } void TSTypeAliasDeclaration::EmplaceTypeParamterTypes(checker::Type *typeParamTypes) diff --git a/ets2panda/lexer/lexer.h b/ets2panda/lexer/lexer.h index 464dd2a0e64e47ff388391efaea2b3cc5dc14ffc..caeaa89aacdcc17be9b0836dd39f10f38c5aa656 100644 --- a/ets2panda/lexer/lexer.h +++ b/ets2panda/lexer/lexer.h @@ -272,12 +272,12 @@ public: NextTokenFlags DefaultNextTokenFlags() const { - return defaultNextTokenFlags; + return defaultNextTokenFlags_; } void SetDefaultNextTokenFlags(NextTokenFlags flags) { - defaultNextTokenFlags = flags; + defaultNextTokenFlags_ = flags; } protected: @@ -392,7 +392,7 @@ private: util::StringView source_; LexerPosition pos_; util::DiagnosticEngine &diagnosticEngine_; - NextTokenFlags defaultNextTokenFlags = NextTokenFlags::NONE; + NextTokenFlags defaultNextTokenFlags_ = NextTokenFlags::NONE; }; class TemplateLiteralParserContext { diff --git a/ets2panda/lsp/include/node_matchers.h b/ets2panda/lsp/include/node_matchers.h index 6fdadbebb2ae7c83b83f620bd5826a2cb7f574fd..c523431858c51c9414b8cbf78bad2469df72cafb 100644 --- a/ets2panda/lsp/include/node_matchers.h +++ b/ets2panda/lsp/include/node_matchers.h @@ -20,7 +20,7 @@ #include #include "ir/astNode.h" #include "api.h" - +// NOLINTNEXTLINE (cppcoreguidelines-macro-usage) #define DEFINE_SIMPLE_HANDLER(FunctionName, NodeType, NameAccessor, NodeTypeEnum) \ void FunctionName(ir::AstNode *node, std::vector &result) \ { \ diff --git a/ets2panda/lsp/src/get_adjusted_location.cpp b/ets2panda/lsp/src/get_adjusted_location.cpp index ca98bf9534bd399a7a25a9f14502ed53678a7c52..6884083073d90c384e912e9d77dbb75261977bab 100644 --- a/ets2panda/lsp/src/get_adjusted_location.cpp +++ b/ets2panda/lsp/src/get_adjusted_location.cpp @@ -275,10 +275,10 @@ std::optional GetAdjustedLocationForFunction(AstNode *node, ArenaAllo if (fn == nullptr) { return std::nullopt; } - - constexpr bool kSkipModifiers = false; + // CC-OFFNXT(G.NAM.03-CPP) project code style + constexpr bool K_SKIP_MODIFIERS = false; ArenaVector dummy(allocator->Adapter()); - AstNode *id = FindFirstIdentifier(fn, kSkipModifiers, dummy); + AstNode *id = FindFirstIdentifier(fn, K_SKIP_MODIFIERS, dummy); return (id != nullptr) ? std::optional {id} : std::nullopt; } diff --git a/ets2panda/parser/program/DeclarationCache.h b/ets2panda/parser/program/DeclarationCache.h index b245bb860b0caf5dfb2b0e7dcc60409d11772a3f..2f8501a3ffecc9b1e1ad289c96ab8ea6f35c6d66 100644 --- a/ets2panda/parser/program/DeclarationCache.h +++ b/ets2panda/parser/program/DeclarationCache.h @@ -49,12 +49,12 @@ public: NO_MOVE_SEMANTIC(UniqueSpinMutex); // Standard library 'Lockable' requirements implementation - void lock(); // CC-OFF(G.NAM.03-CPP) project code style - void unlock(); // CC-OFF(G.NAM.03-CPP) project code style - bool try_lock(); // CC-OFF(G.NAM.03-CPP) project code style + void lock(); // CC-OFF(G.NAM.03-CPP) project code style // NOLINT(readability-identifier-naming) + void unlock(); // CC-OFF(G.NAM.03-CPP) project code style // NOLINT(readability-identifier-naming) + bool try_lock(); // CC-OFF(G.NAM.03-CPP) project code style // NOLINT(readability-identifier-naming) protected: - std::atomic_int64_t spin_ {LOCK_OFF}; + std::atomic_int64_t spin_ {LOCK_OFF}; // NOLINT(misc-non-private-member-variables-in-classes) }; //--------------------------------------------------------------------------------------------------------------------// @@ -73,9 +73,9 @@ public: NO_MOVE_SEMANTIC(ReadWriteSpinMutex); // Standard library 'SharedLockable' requirements implementation - void lock_shared(); // CC-OFF(G.NAM.03-CPP) project code style - void unlock_shared(); // CC-OFF(G.NAM.03-CPP) project code style - bool try_lock_shared(); // CC-OFF(G.NAM.03-CPP) project code style + void lock_shared(); // CC-OFF(G.NAM.03-CPP) project code style // NOLINT(readability-identifier-naming) + void unlock_shared(); // CC-OFF(G.NAM.03-CPP) project code style // NOLINT(readability-identifier-naming) + bool try_lock_shared(); // CC-OFF(G.NAM.03-CPP) project code style // NOLINT(readability-identifier-naming) }; using DeclarationType = std::shared_ptr; @@ -84,7 +84,7 @@ class DeclarationCache final { struct Tag {}; public: - inline static DeclarationType const ABSENT {}; + inline static DeclarationType const ABSENT {}; // NOLINT(fuchsia-statically-constructed-objects) DeclarationCache() = delete; ~DeclarationCache(); @@ -118,6 +118,7 @@ private: private: private: inline static std::shared_mutex globalGuard_ {}; + // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) inline static std::shared_ptr globalDeclarationCache_ = nullptr; private: diff --git a/ets2panda/test/unit/annotations/standard_test.cpp b/ets2panda/test/unit/annotations/standard_test.cpp index db443ec3e8361626a23f33c796ad15b43969ba49..60df721cdc234f75a85908e7ee894f0ec6ae8dcd 100644 --- a/ets2panda/test/unit/annotations/standard_test.cpp +++ b/ets2panda/test/unit/annotations/standard_test.cpp @@ -25,10 +25,11 @@ namespace ark::es2panda::compiler::test { namespace { -using namespace ::test::utils::literals; +using namespace ::test::utils::literals; // NOLINT // In case of an error, the test will display the actual initialization list, // which you need to copy and paste to update the variable value. -static pandasm::Program::LiteralArrayTableT const EXPECTED_LITERAL_ARRAY = { +// NOLINTNEXTLINE (cert-err58-cpp) +pandasm::Program::LiteralArrayTableT const EXPECTED_LITERAL_ARRAY = { {"ETSGLOBAL%%annotation-ClassAuthor-color-8", LA({{0x0_LT, 2_U8}, {0x2_LT, 0_U32}, {0x0_LT, 2_U8}, {0x2_LT, 1_U32}})}, {"ETSGLOBAL%%annotation-ClassAuthor-mutiArray-12", diff --git a/ets2panda/test/unit/extern_flag_test.cpp b/ets2panda/test/unit/extern_flag_test.cpp index c34c198647200fd7e8228c3ac99097ee1f363d0e..9a48e6083b62e878f0887830b5b10988bb7dbf44 100644 --- a/ets2panda/test/unit/extern_flag_test.cpp +++ b/ets2panda/test/unit/extern_flag_test.cpp @@ -40,15 +40,19 @@ inline bool RecordExternalFlag(ark::pandasm::Record const &record) } struct SaveFmtFlags final { - explicit SaveFmtFlags(std::ostream &s) : os {s}, oldFlags {s.flags()} {} + explicit SaveFmtFlags(std::ostream &s) : os_ {s}, oldFlags_ {s.flags()} {} ~SaveFmtFlags() { - os.setf(oldFlags); + os_.setf(oldFlags_); } + NO_COPY_SEMANTIC(SaveFmtFlags); + NO_MOVE_SEMANTIC(SaveFmtFlags); private: - std::ostream &os; - std::ios_base::fmtflags oldFlags; + // CC-OFFNXT(G.NAM.03-CPP) project code style + std::ostream &os_; + // CC-OFFNXT(G.NAM.03-CPP) project code style + std::ios_base::fmtflags oldFlags_; }; } // namespace @@ -75,7 +79,7 @@ std::ostream &operator<<(std::ostream &s, const Record &arg) namespace ark::es2panda::compiler::test { -MATCHER_P(ExternAttribute, flag, "") +MATCHER_P(ExternAttribute, flag, "") // NOLINT (misc-non-private-member-variables-in-classes) { bool value = arg.metadata->GetAttribute("external"); *result_listener << "'external' attribute is " << value; @@ -113,16 +117,16 @@ protected: void CheckRecordExternalFlag(std::string recordName, bool externFlag = true) { ASSERT_NE(program_, nullptr); - using namespace ::testing; - auto const matcher = Contains(Pair(recordName, ExternAttribute(externFlag))); + using ::testing::Contains, ::testing::Pair; + auto const matcher = Contains(Pair(std::move(recordName), ExternAttribute(externFlag))); EXPECT_THAT(program_->recordTable, matcher); } void CheckFunctionExternalFlag(std::string functionName, bool isStatic = false, bool externFlag = true) { ASSERT_NE(program_, nullptr); - using namespace ::testing; - auto const matcher = Contains(Pair(functionName, ExternAttribute(externFlag))); + using ::testing::Contains, ::testing::Pair; + auto const matcher = Contains(Pair(std::move(functionName), ExternAttribute(externFlag))); if (isStatic) { EXPECT_THAT(program_->functionStaticTable, matcher); } else { @@ -133,8 +137,8 @@ protected: void CheckRecordNotExists(std::string name) { ASSERT_NE(program_, nullptr); - using namespace ::testing; - EXPECT_THAT(program_->recordTable, Not(Contains(Key(name)))); + using ::testing::Contains, ::testing::Pair, ::testing::Not, ::testing::Key; + EXPECT_THAT(program_->recordTable, Not(Contains(Key(std::move(name))))); } private: diff --git a/ets2panda/test/unit/lsp/forgotten_this_property_access_test.cpp b/ets2panda/test/unit/lsp/forgotten_this_property_access_test.cpp index 114cf5169d51c7ff85d878df1d0492ddb7f34abc..afbcd9bc56a7bf681158c6fcfcfe0ee1d1fe8d77 100644 --- a/ets2panda/test/unit/lsp/forgotten_this_property_access_test.cpp +++ b/ets2panda/test/unit/lsp/forgotten_this_property_access_test.cpp @@ -126,9 +126,9 @@ console.log(name + " is " + age); auto ctxInternal = reinterpret_cast(ctx); const auto &diagnostics = ctxInternal->diagnosticEngine->GetDiagnosticStorage(ark::es2panda::util::DiagnosticType::SEMANTIC); - - constexpr size_t expectedDiagnosticCount = 2; - ASSERT_GE(diagnostics.size(), expectedDiagnosticCount); + // CC-OFFNXT(G.NAM.03-CPP) project code style + constexpr size_t EXPECTED_DIAGNOSTIC_COUNT = 2; + ASSERT_GE(diagnostics.size(), EXPECTED_DIAGNOSTIC_COUNT); std::string expectedFileName = "ForgottenThisPropertyAccess_Multiple.ets"; const size_t start1 = LineColToPos(ctx, 5, 13); diff --git a/ets2panda/test/unit/lsp/get_node_await_expression_test.cpp b/ets2panda/test/unit/lsp/get_node_await_expression_test.cpp index fa580e734dd66f817f39ecfbe8b6a00992690778..8965ae61d97b99380104f9b75000971bf9a15b88 100644 --- a/ets2panda/test/unit/lsp/get_node_await_expression_test.cpp +++ b/ets2panda/test/unit/lsp/get_node_await_expression_test.cpp @@ -73,7 +73,7 @@ TEST_F(LspGetAwaitExpressionTests, GetAnyAwaitExpression) auto res = lspApi->getDefinitionDataFromNode(contexts_, nodeInfoPtrs); std::string extractedText(sourceCode_.substr(res.start, res.length)); - ASSERT_NE(extractedText.find("p"), std::string::npos); + ASSERT_NE(extractedText.find('p'), std::string::npos); } TEST_F(LspGetAwaitExpressionTests, GetAwaitExpressionByAnotherParameterName) diff --git a/ets2panda/test/unit/lsp/get_node_ts_type_reference_test.cpp b/ets2panda/test/unit/lsp/get_node_ts_type_reference_test.cpp index cad83d55cbf9269c1923732eed822ded17a9b83d..d3e480cb22026653949876b58af14b61cce5c729 100755 --- a/ets2panda/test/unit/lsp/get_node_ts_type_reference_test.cpp +++ b/ets2panda/test/unit/lsp/get_node_ts_type_reference_test.cpp @@ -21,8 +21,6 @@ #include namespace { -using ark::es2panda::lsp::Initializer; - class LspGetNodeTSTypeReferenceTests : public LSPAPITests {}; TEST_F(LspGetNodeTSTypeReferenceTests, GetTSTypeReference_TEST1) diff --git a/ets2panda/test/unit/lsp/quick_info_api_test.cpp b/ets2panda/test/unit/lsp/quick_info_api_test.cpp index 67ebc36f98f0bc58efe0eec1d989f46e70f468eb..a340cc3668feba1348180ce5d5a7593e3632171a 100644 --- a/ets2panda/test/unit/lsp/quick_info_api_test.cpp +++ b/ets2panda/test/unit/lsp/quick_info_api_test.cpp @@ -17,6 +17,7 @@ #include "lsp_api_test.h" #include "lsp/include/internal_api.h" #include +#include namespace { using ark::es2panda::lsp::Initializer; @@ -470,10 +471,11 @@ TEST_F(LspQuickInfoTests, GetQuickInfoAtPositionClass) auto context = reinterpret_cast(ctx); const ark::es2panda::ir::AstNode *ast = context->parserProgram->Ast(); - const auto *structDefNode = ast->FindChild( + auto *structDefNode = ast->FindChild( [](const auto *node) { return node->IsClassDefinition() && node->Parent()->IsETSStructDeclaration(); }); - initializer.ClassDefinitionSetFromStructModifier(ctx, (es2panda_AstNode *)structDefNode); - auto isFromStruct = initializer.ClassDefinitionIsFromStructConst(ctx, (es2panda_AstNode *)structDefNode); + initializer.ClassDefinitionSetFromStructModifier(ctx, reinterpret_cast(structDefNode)); + auto isFromStruct = + initializer.ClassDefinitionIsFromStructConst(ctx, reinterpret_cast(structDefNode)); ASSERT_EQ(isFromStruct, true); auto quickInfo3 = lspApi->getQuickInfoAtPosition("GetQuickInfoAtPositionClass.ets", ctx, offset1); AssertQuickInfo(expectedQuickInfo1, quickInfo3); diff --git a/ets2panda/test/unit/lsp/remove_accidental_call_parentheses_test.cpp b/ets2panda/test/unit/lsp/remove_accidental_call_parentheses_test.cpp index e152797ada636c7836390fe870bd8d30429236db..02c6cad5691ada2f1aff678ea11020f392c7bfde 100644 --- a/ets2panda/test/unit/lsp/remove_accidental_call_parentheses_test.cpp +++ b/ets2panda/test/unit/lsp/remove_accidental_call_parentheses_test.cpp @@ -28,7 +28,7 @@ const size_t IGNORE_MALFORMED_CALL_IDX = 42; const size_t SKIP_VALID_METHOD_CALL_IDX = 77; using ark::es2panda::lsp::codefixes::REMOVE_ACCIDENTAL_CALL_PARENTHESES; constexpr auto ERROR_CODES = REMOVE_ACCIDENTAL_CALL_PARENTHESES.GetSupportedCodeNumbers(); -class FixRemoveCallParens_AtPos_Tests : public LSPAPITests { +class FixRemoveCallParensAtPosTests : public LSPAPITests { public: class NullCancellationToken : public ark::es2panda::lsp::HostCancellationToken { public: @@ -45,7 +45,7 @@ public: } }; -TEST_F(FixRemoveCallParens_AtPos_Tests, RemovesParenthesesFromGetterCall) +TEST_F(FixRemoveCallParensAtPosTests, RemovesParenthesesFromGetterCall) { ark::es2panda::lsp::Initializer initializer; const std::string sourceCode = R"( @@ -72,7 +72,7 @@ const name = user.name(); initializer.DestroyContext(ctx); } -TEST_F(FixRemoveCallParens_AtPos_Tests, IgnoreMalformedCallExpressions) +TEST_F(FixRemoveCallParensAtPosTests, IgnoreMalformedCallExpressions) { ark::es2panda::lsp::Initializer initializer; const std::string sourceCode = R"( @@ -91,7 +91,7 @@ const z = obj.value(; initializer.DestroyContext(ctx); } -TEST_F(FixRemoveCallParens_AtPos_Tests, RemoveParensFromNonFunctionPropertyCall) +TEST_F(FixRemoveCallParensAtPosTests, RemoveParensFromNonFunctionPropertyCall) { ark::es2panda::lsp::Initializer initializer; const std::string sourceCode = R"( @@ -121,7 +121,7 @@ const z = obj.value() initializer.DestroyContext(ctx); } -TEST_F(FixRemoveCallParens_AtPos_Tests, SkipsValidMethodCall) +TEST_F(FixRemoveCallParensAtPosTests, SkipsValidMethodCall) { ark::es2panda::lsp::Initializer initializer; const std::string sourceCode = R"( diff --git a/ets2panda/test/unit/rest_parameter_flag_test.cpp b/ets2panda/test/unit/rest_parameter_flag_test.cpp index 8296fd1f990fac91f4a94d6fefbeefea63193a55..f49c7f1d739922837d93e5475506757a0c7e6de3 100644 --- a/ets2panda/test/unit/rest_parameter_flag_test.cpp +++ b/ets2panda/test/unit/rest_parameter_flag_test.cpp @@ -334,7 +334,7 @@ TEST_F(RestParameterTest, abstract_function_with_rest_parameter_1) TEST_F(RestParameterTest, external_function_with_rest_parameter_0) { SetCurrentProgram(""); - using namespace ::testing; + using ::testing::Contains, ::testing::Key, ::testing::Eq; EXPECT_THAT(program_->functionInstanceTable, Contains(Key(Eq("std.core.Object[].:std.core.Object[];i32;void;")))); } diff --git a/ets2panda/test/unit/source_file_message/source_file_message_test.cpp b/ets2panda/test/unit/source_file_message/source_file_message_test.cpp index f09554d6395248d65fcce0199dd55c73a3ff9fa4..30b6d2b52450eda6c61f865ccd4b6343d1871185 100644 --- a/ets2panda/test/unit/source_file_message/source_file_message_test.cpp +++ b/ets2panda/test/unit/source_file_message/source_file_message_test.cpp @@ -38,7 +38,7 @@ TEST_F(SourceFileMsgTest, source_file_msg_test) )"; auto program = GetCurrentProgram(text); - const auto &recordTable = program.get()->recordTable; + const auto &recordTable = program->recordTable; auto sourceFile = recordTable.find("ETSGLOBAL"); ASSERT_EQ(sourceFile->second.sourceFile, "dummy.ets"); } diff --git a/ets2panda/test/unit/union_emit_test.cpp b/ets2panda/test/unit/union_emit_test.cpp index 8aacea12524d529853067dcd3fc0870e256a4ed1..c74fe9820389aad5e844059b367f939d93a3a35d 100644 --- a/ets2panda/test/unit/union_emit_test.cpp +++ b/ets2panda/test/unit/union_emit_test.cpp @@ -23,7 +23,6 @@ #include "assembly-function.h" #include "assembly-program.h" -#include "gmock/gmock.h" #include "test/utils/asm_test.h" namespace ark::pandasm { diff --git a/ets2panda/test/unit/union_normalisation_test.h b/ets2panda/test/unit/union_normalisation_test.h index 7b999d5620729a16e277191a1acfbfa686140917..8b0261d5d51373f5ece9db1616b2c52e6ba93cc8 100644 --- a/ets2panda/test/unit/union_normalisation_test.h +++ b/ets2panda/test/unit/union_normalisation_test.h @@ -34,9 +34,7 @@ public: ~UnionNormalizationTest() override { - if (publicContext_->phaseManager != nullptr) { - delete publicContext_->phaseManager; - } + delete publicContext_->phaseManager; } static void SetUpTestCase() diff --git a/ets2panda/test/utils/asm_test.cpp b/ets2panda/test/utils/asm_test.cpp index ec4c49ea20645539b0a2f5af4ac3d9545b8618f5..2184c15906940d9272d54e6bcb324ea8cf2aa552 100644 --- a/ets2panda/test/utils/asm_test.cpp +++ b/ets2panda/test/utils/asm_test.cpp @@ -18,8 +18,6 @@ #include #include -#include - #include "asm_test.h" #include "assembly-field.h" #include "assembly-literals.h" @@ -35,7 +33,7 @@ namespace ark::pandasm { namespace { template -struct LiteralOverloaded : Ts... { +struct LiteralOverloaded : Ts... { // NOLINT (fuchsia-multiple-inheritance) using Ts::operator()...; }; diff --git a/ets2panda/test/utils/asm_test.h b/ets2panda/test/utils/asm_test.h index a68bba34da174249a28f30ad4227159345c3bbd6..16bd5809d93ed581ae464535c39e1fd3ebbd05b9 100644 --- a/ets2panda/test/utils/asm_test.h +++ b/ets2panda/test/utils/asm_test.h @@ -51,7 +51,7 @@ namespace test::utils { namespace literals { -inline ::ark::panda_file::LiteralTag operator""_LT(unsigned long long value) +inline ::ark::panda_file::LiteralTag operator""_LT(unsigned long long value) // NOLINT { return ::ark::panda_file::LiteralTag(value); } @@ -61,22 +61,22 @@ inline ::ark::pandasm::LiteralArray LA(::ark::pandasm::LiteralArray::LiteralVect return ::ark::pandasm::LiteralArray {std::move(value)}; } -inline uint8_t operator""_U8(unsigned long long value) +inline uint8_t operator""_U8(unsigned long long value) // NOLINT { return uint8_t(value); } -inline uint16_t operator""_U16(unsigned long long value) +inline uint16_t operator""_U16(unsigned long long value) // NOLINT { return uint16_t(value); } -inline uint32_t operator""_U32(unsigned long long value) +inline uint32_t operator""_U32(unsigned long long value) // NOLINT { return uint32_t(value); } -inline uint64_t operator""_U64(unsigned long long value) +inline uint64_t operator""_U64(unsigned long long value) // NOLINT { return uint64_t(value); } diff --git a/ets2panda/test/utils/checker_test.h b/ets2panda/test/utils/checker_test.h index de62d43764ef68294086a483ac35711d74580f04..8fb0411c620eb65b788e5ec4a44ecbc37daddc2a 100644 --- a/ets2panda/test/utils/checker_test.h +++ b/ets2panda/test/utils/checker_test.h @@ -53,9 +53,7 @@ public: ~CheckerTest() override { - if (publicContext_->phaseManager != nullptr) { - delete publicContext_->phaseManager; - } + delete publicContext_->phaseManager; } static void SetUpTestCase() diff --git a/ets2panda/util/importPathManager.cpp b/ets2panda/util/importPathManager.cpp index a7f93fb25ed3037df329aea407d1c799953a7a5d..a3cfa770dd818006651fb0483bef18b846b3df50 100644 --- a/ets2panda/util/importPathManager.cpp +++ b/ets2panda/util/importPathManager.cpp @@ -149,8 +149,8 @@ std::string_view ImportPathManager::TryImportFromDeclarationCache(std::string_vi } const std::string etsSuffix = ".ets"; const std::string dEtsSuffix = ".d.ets"; - const auto &rootDir = ArkTSConfig().get()->RootDir(); - const auto &cacheDir = ArkTSConfig().get()->CacheDir(); + const auto &rootDir = ArkTSConfig()->RootDir(); + const auto &cacheDir = ArkTSConfig()->CacheDir(); if (cacheDir.empty() || rootDir.empty()) { return resolvedImportPath; } @@ -540,7 +540,7 @@ util::StringView ImportPathManager::FormModuleNameSolelyByAbsolutePath(const uti } // should be implemented with a stable name -> path mapping list -static std::optional TryFormModuleName(std::string filePath, std::string_view unitName, +static std::optional TryFormModuleName(const std::string &filePath, std::string_view unitName, std::string_view unitPath, std::string_view cachePath) { if (cachePath.empty() && filePath.rfind(unitPath, 0) != 0) { diff --git a/ets2panda/varbinder/ETSBinder.cpp b/ets2panda/varbinder/ETSBinder.cpp index 1e7d1b087eecfc27cca8ca77be653403d47ba63d..75973449a369c61a92240d8a9b30dcc92e058252 100644 --- a/ets2panda/varbinder/ETSBinder.cpp +++ b/ets2panda/varbinder/ETSBinder.cpp @@ -60,16 +60,16 @@ void ETSBinder::LookupTypeArgumentReferences(ir::ETSTypeReference *typeRef) bool ETSBinder::IsSpecialName(const util::StringView &name) { - constexpr std::array specialKeywords = {compiler::Signatures::ANY_TYPE_NAME, compiler::Signatures::ANY, - compiler::Signatures::UNDEFINED, compiler::Signatures::NULL_LITERAL}; + constexpr std::array SPECIAL_KEYWORDS = {compiler::Signatures::ANY_TYPE_NAME, compiler::Signatures::ANY, + compiler::Signatures::UNDEFINED, compiler::Signatures::NULL_LITERAL}; - constexpr std::array utilityTypes = { + constexpr std::array UTILITY_TYPES = { compiler::Signatures::READONLY_TYPE_NAME, compiler::Signatures::PARTIAL_TYPE_NAME, compiler::Signatures::REQUIRED_TYPE_NAME, compiler::Signatures::FIXED_ARRAY_TYPE_NAME, compiler::Signatures::AWAITED_TYPE_NAME}; - return std::find(specialKeywords.begin(), specialKeywords.end(), name.Utf8()) != specialKeywords.end() || - std::find(utilityTypes.begin(), utilityTypes.end(), name.Utf8()) != utilityTypes.end(); + return std::find(SPECIAL_KEYWORDS.begin(), SPECIAL_KEYWORDS.end(), name.Utf8()) != SPECIAL_KEYWORDS.end() || + std::find(UTILITY_TYPES.begin(), UTILITY_TYPES.end(), name.Utf8()) != UTILITY_TYPES.end(); } static bool IsAnyOrUnknown(ETSBinder *binder, const util::StringView &name, const lexer::SourcePosition &pos)