From d53b4f6980009006050e53711bda76f77b7afc2f Mon Sep 17 00:00:00 2001 From: Artem Udovichenko Date: Fri, 15 Dec 2023 14:33:34 +0300 Subject: [PATCH] Fix code style issues Issue: #I8R9EU Testing: CI Change-Id: I954475b2209cf26074f5fdb8e4cff41ed70a67a7 Signed-off-by: Artem Udovichenko --- ets2panda/checker/types/ets/etsEnumType.h | 4 ++-- ets2panda/checker/types/typeRelation.h | 2 +- ets2panda/compiler/base/lreference.h | 2 +- ets2panda/compiler/core/ETSGen.cpp | 8 ++++---- ets2panda/compiler/core/regAllocator.h | 4 ++-- ets2panda/parser/ETSparser.h | 8 ++++---- ets2panda/util/arktsconfig.cpp | 2 +- ets2panda/util/generateBin.h | 8 ++++---- ets2panda/util/helpers.h | 2 +- ets2panda/util/language.h | 6 +++--- ets2panda/varbinder/recordTable.h | 6 +++--- 11 files changed, 26 insertions(+), 26 deletions(-) diff --git a/ets2panda/checker/types/ets/etsEnumType.h b/ets2panda/checker/types/ets/etsEnumType.h index 26ac87f16d..2bd8c99d3e 100644 --- a/ets2panda/checker/types/ets/etsEnumType.h +++ b/ets2panda/checker/types/ets/etsEnumType.h @@ -80,9 +80,9 @@ public: [[nodiscard]] bool IsLiteralType() const noexcept; - [[nodiscard]] bool IsSameEnumType(const ETSEnumInterface *other) const noexcept; + [[nodiscard]] bool IsSameEnumType(const ETSEnumInterface *const other) const noexcept; - [[nodiscard]] bool IsSameEnumLiteralType(const ETSEnumInterface *other) const noexcept; + [[nodiscard]] bool IsSameEnumLiteralType(const ETSEnumInterface *const other) const noexcept; [[nodiscard]] bool IsEnumInstanceExpression(const ir::Expression *expression) const noexcept; diff --git a/ets2panda/checker/types/typeRelation.h b/ets2panda/checker/types/typeRelation.h index fa82ecd646..50a2403bbd 100644 --- a/ets2panda/checker/types/typeRelation.h +++ b/ets2panda/checker/types/typeRelation.h @@ -264,7 +264,7 @@ public: bool IsIdenticalTo(IndexInfo *source, IndexInfo *target); bool IsAssignableTo(Type *source, Type *target); bool IsComparableTo(Type *source, Type *target); - bool IsCastableTo(Type *source, Type *target); + bool IsCastableTo(Type *const source, Type *const target); bool IsSupertypeOf(Type *super, Type *sub); void RaiseError(const std::string &errMsg, const lexer::SourcePosition &loc) const; void RaiseError(std::initializer_list list, const lexer::SourcePosition &loc) const; diff --git a/ets2panda/compiler/base/lreference.h b/ets2panda/compiler/base/lreference.h index 8a21460f6d..35dc5c4edd 100644 --- a/ets2panda/compiler/base/lreference.h +++ b/ets2panda/compiler/base/lreference.h @@ -140,7 +140,7 @@ public: void GetValue() const; void SetValue() const; - static ETSLReference Create(CodeGen *cg, const ir::AstNode *node, bool isDeclaration); + static ETSLReference Create(CodeGen *const cg, const ir::AstNode *const node, const bool isDeclaration); static ReferenceKind ResolveReferenceKind(const varbinder::Variable *variable); private: diff --git a/ets2panda/compiler/core/ETSGen.cpp b/ets2panda/compiler/core/ETSGen.cpp index c659e48884..1949eabc51 100644 --- a/ets2panda/compiler/core/ETSGen.cpp +++ b/ets2panda/compiler/core/ETSGen.cpp @@ -644,10 +644,10 @@ void ETSGen::CreateLambdaObjectFromMemberReference(const ir::AstNode *node, ir:: } // NOLINTBEGIN(cppcoreguidelines-macro-usage, readability-container-size-empty) -#define CONV_LAMBDA_CTOR_ARG(idx) \ - ASSERT(idx < arguments.size()); \ - auto *paramType##idx = signature->Params()[idx]->TsType(); \ - auto ttctx##idx = TargetTypeContext(this, paramType##idx); \ +#define CONV_LAMBDA_CTOR_ARG(idx) \ + ASSERT((idx) < arguments.size()); \ + auto *paramType##idx = signature->Params()[(idx)]->TsType(); \ + auto ttctx##idx = TargetTypeContext(this, paramType##idx); \ ApplyConversion(node, paramType##idx) void ETSGen::InitLambdaObject(const ir::AstNode *node, checker::Signature *signature, std::vector &arguments) diff --git a/ets2panda/compiler/core/regAllocator.h b/ets2panda/compiler/core/regAllocator.h index f248c36597..287226291c 100644 --- a/ets2panda/compiler/core/regAllocator.h +++ b/ets2panda/compiler/core/regAllocator.h @@ -29,7 +29,7 @@ class CodeGen; class AllocatorBase { public: - explicit AllocatorBase(CodeGen *cg) noexcept; + explicit AllocatorBase(CodeGen *const cg) noexcept; NO_COPY_SEMANTIC(AllocatorBase); NO_MOVE_SEMANTIC(AllocatorBase); ~AllocatorBase() = default; @@ -60,7 +60,7 @@ private: class SimpleAllocator final : public AllocatorBase { public: - explicit SimpleAllocator(CodeGen *cg) noexcept; + explicit SimpleAllocator(CodeGen *const cg) noexcept; NO_COPY_SEMANTIC(SimpleAllocator); NO_MOVE_SEMANTIC(SimpleAllocator); ~SimpleAllocator() = default; diff --git a/ets2panda/parser/ETSparser.h b/ets2panda/parser/ETSparser.h index 89490be064..ca5fefcf6d 100644 --- a/ets2panda/parser/ETSparser.h +++ b/ets2panda/parser/ETSparser.h @@ -193,9 +193,9 @@ private: ir::TypeNode *ParseFunctionType(); ir::TypeNode *ParseETSTupleType(TypeAnnotationParsingOptions *options); std::pair CheckDefaultParameters(const ir::ScriptFunction *function) const; - ir::MethodDefinition *CreateProxyMethodDefinition(ir::MethodDefinition const *method, - ir::Identifier const *identNode); - ir::MethodDefinition *CreateProxyConstructorDefinition(ir::MethodDefinition const *method); + ir::MethodDefinition *CreateProxyMethodDefinition(ir::MethodDefinition const *const method, + ir::Identifier const *const identNode); + ir::MethodDefinition *CreateProxyConstructorDefinition(ir::MethodDefinition const *const method); void AddProxyOverloadToMethodWithDefaultParams(ir::MethodDefinition *method, ir::Identifier *identNode = nullptr); static std::string PrimitiveTypeToName(ir::PrimitiveType type); std::string GetNameForTypeNode(const ir::TypeNode *typeAnnotation, bool adjust = true) const; @@ -330,7 +330,7 @@ private: ir::Expression *ParsePotentialExpressionSequence(ir::Expression *expr, ExpressionParseFlags flags) override; - ir::ModifierFlags ParseTypeVarianceModifier(TypeAnnotationParsingOptions *options); + ir::ModifierFlags ParseTypeVarianceModifier(TypeAnnotationParsingOptions *const options); ir::ScriptFunction *AddInitMethod(ArenaVector &globalProperties); ir::Statement *ParseTopLevelStatement(StatementParsingFlags flags = StatementParsingFlags::NONE); diff --git a/ets2panda/util/arktsconfig.cpp b/ets2panda/util/arktsconfig.cpp index 0cde0b5691..3e84f1fd05 100644 --- a/ets2panda/util/arktsconfig.cpp +++ b/ets2panda/util/arktsconfig.cpp @@ -41,7 +41,7 @@ namespace fs = std::experimental::filesystem; // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define CHECK(cond, ret, msg) \ - if (!cond) { \ + if (!(cond)) { \ std::cerr << "ArkTsConfig error: " << msg << std::endl; \ return ret; \ } diff --git a/ets2panda/util/generateBin.h b/ets2panda/util/generateBin.h index a5a3456724..68977de892 100644 --- a/ets2panda/util/generateBin.h +++ b/ets2panda/util/generateBin.h @@ -13,12 +13,12 @@ * limitations under the License. */ +#ifndef ES2PANDA_UTIL_GENERATEBIN_H +#define ES2PANDA_UTIL_GENERATEBIN_H + #include "parser/program/program.h" #include "util/options.h" -#ifndef ES2PANDA_UTIL_GENERATE_BIN_H -#define ES2PANDA_UTIL_GENREATE_BIN_H - namespace panda::es2panda::util { using ReporterFun = std::function; @@ -27,4 +27,4 @@ int GenerateProgram(panda::pandasm::Program *prog, const util::Options *options, } // namespace panda::es2panda::util -#endif +#endif // ES2PANDA_UTIL_GENERATEBIN_H diff --git a/ets2panda/util/helpers.h b/ets2panda/util/helpers.h index 6b8a9d030c..f3f0b927de 100644 --- a/ets2panda/util/helpers.h +++ b/ets2panda/util/helpers.h @@ -142,7 +142,7 @@ public: static const uint32_t INVALID_INDEX = 4294967295L; static std::string CreateEscapedString(const std::string &str); - static std::string UTF16toUTF8(char16_t c); + static std::string UTF16toUTF8(const char16_t c); template static void LogDebug(Elements &&...elems); diff --git a/ets2panda/util/language.h b/ets2panda/util/language.h index 3d4b224177..631d1e1722 100644 --- a/ets2panda/util/language.h +++ b/ets2panda/util/language.h @@ -48,7 +48,7 @@ public: // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define TO_STR(e, s, d) \ if (id_ == Id::e) { \ - return s; \ + return (s); \ } LANGUAGES(TO_STR) #undef TO_STR @@ -59,7 +59,7 @@ public: { // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define FROM_STR(e, s, d) \ - if (str == s) { \ + if (str == (s)) { \ return Language(Id::e); \ } LANGUAGES(FROM_STR) @@ -77,7 +77,7 @@ public: // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define TO_DYN(e, s, d) \ if (id_ == Id::e) { \ - return d; \ + return (d); \ } LANGUAGES(TO_DYN) #undef TO_DYN diff --git a/ets2panda/varbinder/recordTable.h b/ets2panda/varbinder/recordTable.h index d3281653b3..7dd5e555e2 100644 --- a/ets2panda/varbinder/recordTable.h +++ b/ets2panda/varbinder/recordTable.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef ES2PANDA_recordTable_RECORD_TABLE_H -#define ES2PANDA_recordTable_RECORD_TABLE_H +#ifndef ES2PANDA_VARBINDER_RECORDTABLE_H +#define ES2PANDA_VARBINDER_RECORDTABLE_H #include "macros.h" #include "utils/arena_containers.h" @@ -186,4 +186,4 @@ private: } // namespace panda::es2panda::varbinder -#endif +#endif // ES2PANDA_VARBINDER_RECORDTABLE_H -- Gitee