From 04f33c548ef0dc6d8c4caa08f421b0c0f6152641 Mon Sep 17 00:00:00 2001 From: vagin ivan Date: Sun, 17 Jul 2022 22:31:17 +0300 Subject: [PATCH] Migrate from clang-9 to clang-14 Change-Id: I44f23d239026fed6568f0725fa64378536a47b9c --- CMakeLists.txt | 3 + compiler/optimizer/ir/dyn_datatype.h | 6 +- runtime/base/config.h | 42 ++++---- runtime/base/string_helper.cpp | 2 +- runtime/base/utf_helper.cpp | 2 +- runtime/class_linker/program_object-inl.h | 6 +- runtime/class_linker/program_object.h | 6 +- runtime/common.h | 6 +- runtime/ecma_class_linker_extension.h | 6 +- runtime/ecma_string.h | 6 +- runtime/ecma_vm.cpp | 2 - runtime/global_dictionary-inl.h | 6 +- runtime/global_dictionary.h | 6 +- runtime/ic/ic_runtime.cpp | 2 +- runtime/ic/property_box.h | 6 +- runtime/ic/proto_change_details.h | 6 +- runtime/interpreter/interpreter-inl.h | 1 - runtime/js_date.cpp | 6 +- runtime/js_generator_object.h | 6 +- runtime/js_locale.h | 5 +- runtime/js_object.h | 6 +- runtime/js_proxy.cpp | 4 +- runtime/js_serializer.h | 5 +- runtime/js_string_iterator.h | 6 +- runtime/js_symbol.h | 6 +- runtime/js_tagged_number.h | 6 +- runtime/js_tagged_value-inl.h | 10 +- runtime/mem/area.h | 6 +- runtime/mem/caddress_allocator.h | 4 +- runtime/mem/chunk.h | 2 +- runtime/mem/chunk_allocator.h | 2 +- runtime/mem/compress_collector.h | 6 +- runtime/mem/machine_code.h | 6 +- runtime/mem/mark_stack.h | 6 +- runtime/mem/mark_word.h | 6 +- runtime/mem/mem_manager-inl.h | 1 - runtime/mem/mix_space_collector.h | 6 +- runtime/mem/parallel_work_helper.h | 6 +- runtime/mem/region.h | 3 +- runtime/mem/region_factory.h | 2 +- runtime/mem/semi_space_collector.h | 6 +- runtime/mem/space.cpp | 5 +- runtime/mem/space.h | 2 +- runtime/napi/include/jsnapi.h | 11 +-- runtime/napi/jsnapi.cpp | 4 +- runtime/regexp/regexp_executor.cpp | 9 +- runtime/regexp/regexp_executor.h | 74 +++++++------- runtime/regexp/regexp_opcode.cpp | 109 ++++++++++++--------- runtime/regexp/regexp_opcode.h | 6 +- runtime/regexp/regexp_parser.cpp | 97 +++++++++--------- runtime/regexp/regexp_parser.h | 30 ++---- runtime/vmstat/caller_stat.h | 2 +- tests/runtime/common/js_function_test.cpp | 1 - tests/runtime/common/js_object_test.cpp | 2 - tests/runtime/common/tagged_value_test.cpp | 1 - 55 files changed, 273 insertions(+), 316 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 415d51bbf..e2ea6de66 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,10 @@ target_compile_definitions(arkcompiler PUBLIC -DENABLE_BYTECODE_OPT -DARK_INTRIN target_compile_definitions(arkbytecodeopt PUBLIC -DENABLE_BYTECODE_OPT -DARK_INTRINSIC_SET) set(ICU_ROOT ${PANDA_THIRD_PARTY_SOURCES_DIR}/icu) +set(ORIG_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-implicit-const-int-float-conversion -Wno-unknown-warning-option") add_subdirectory(${PANDA_THIRD_PARTY_CONFIG_DIR}/icu "${CMAKE_CURRENT_BINARY_DIR}/ark-third-party/icu") +set(CMAKE_CXX_FLAGS "${ORIG_CMAKE_CXX_FLAGS}") if(PANDA_WITH_TOOLCHAIN) add_subdirectory(assembler) diff --git a/compiler/optimizer/ir/dyn_datatype.h b/compiler/optimizer/ir/dyn_datatype.h index efc7767a6..0f9de45e0 100644 --- a/compiler/optimizer/ir/dyn_datatype.h +++ b/compiler/optimizer/ir/dyn_datatype.h @@ -20,8 +20,7 @@ #include "compiler/optimizer/ir/datatype.h" #include "ir-dyn-base-types.h" -namespace panda::compiler { -namespace ecmascript { +namespace panda::compiler::ecmascript { static inline panda::compiler::AnyBaseType NumericDataTypeToAnyType(panda::compiler::DataType::Type type) { switch (type) { @@ -116,7 +115,6 @@ static inline std::optional IsAnyTypeCanBeSubtypeOf(panda::compiler::AnyBa return false; } -} // namespace ecmascript -} // namespace panda::compiler +} // namespace panda::compiler::ecmascript #endif // PLUGINS_ECMASCRIPT_COMPILER_OPTIMIZER_IR_DYN_DATATYPE_H diff --git a/runtime/base/config.h b/runtime/base/config.h index d25346190..0b9b7d21f 100644 --- a/runtime/base/config.h +++ b/runtime/base/config.h @@ -17,12 +17,12 @@ #define ECMASCRIPT_BASE_CONFIG_H namespace panda::ecmascript { -#define ARK_INLINE __attribute__((always_inline)) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ARK_NOINLINE __attribute__((noinline)) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) +#define ARK_INLINE __attribute__((always_inline)) // NOLINT(cppcoreguidelines-macro-usage) +#define ARK_NOINLINE __attribute__((noinline)) // NOLINT(cppcoreguidelines-macro-usage) -#define ECMASCRIPT_ENABLE_DEBUG_MODE 0 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ECMASCRIPT_ENABLE_ARK_CONTAINER 0 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ECMASCRIPT_ENABLE_RUNTIME_STAT 1 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) +#define ECMASCRIPT_ENABLE_DEBUG_MODE 0 // NOLINT(cppcoreguidelines-macro-usage) +#define ECMASCRIPT_ENABLE_ARK_CONTAINER 0 // NOLINT(cppcoreguidelines-macro-usage) +#define ECMASCRIPT_ENABLE_RUNTIME_STAT 1 // NOLINT(cppcoreguidelines-macro-usage) /* * 1. close ic @@ -35,23 +35,23 @@ namespace panda::ecmascript { * 9. enable Proactively interrogating and collecting information in the call stack */ #if ECMASCRIPT_ENABLE_DEBUG_MODE -#define ECMASCRIPT_ENABLE_IC 0 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ECMASCRIPT_DISABLE_PARALLEL_GC 1 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ECMASCRIPT_ENABLE_GC_LOG 1 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ECMASCRIPT_ENABLE_ZAP_MEM 1 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ECMASCRIPT_SWITCH_GC_MODE_TO_COMPRESS_GC 1 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ECMASCRIPT_ENABLE_CAST_CHECK 1 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ECMASCRIPT_ENABLE_HEAP_VERIFY 1 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ECMASCRIPT_ENABLE_THREAD_CHECK 1 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) +#define ECMASCRIPT_ENABLE_IC 0 // NOLINT(cppcoreguidelines-macro-usage) +#define ECMASCRIPT_DISABLE_PARALLEL_GC 1 // NOLINT(cppcoreguidelines-macro-usage) +#define ECMASCRIPT_ENABLE_GC_LOG 1 // NOLINT(cppcoreguidelines-macro-usage) +#define ECMASCRIPT_ENABLE_ZAP_MEM 1 // NOLINT(cppcoreguidelines-macro-usage) +#define ECMASCRIPT_SWITCH_GC_MODE_TO_COMPRESS_GC 1 // NOLINT(cppcoreguidelines-macro-usage) +#define ECMASCRIPT_ENABLE_CAST_CHECK 1 // NOLINT(cppcoreguidelines-macro-usage) +#define ECMASCRIPT_ENABLE_HEAP_VERIFY 1 // NOLINT(cppcoreguidelines-macro-usage) +#define ECMASCRIPT_ENABLE_THREAD_CHECK 1 // NOLINT(cppcoreguidelines-macro-usage) #else -#define ECMASCRIPT_ENABLE_IC 1 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ECMASCRIPT_DISABLE_PARALLEL_GC 0 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ECMASCRIPT_ENABLE_GC_LOG 0 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ECMASCRIPT_ENABLE_ZAP_MEM 0 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ECMASCRIPT_SWITCH_GC_MODE_TO_COMPRESS_GC 0 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ECMASCRIPT_ENABLE_CAST_CHECK 0 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ECMASCRIPT_ENABLE_HEAP_VERIFY 0 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ECMASCRIPT_ENABLE_THREAD_CHECK 1 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) +#define ECMASCRIPT_ENABLE_IC 1 // NOLINT(cppcoreguidelines-macro-usage) +#define ECMASCRIPT_DISABLE_PARALLEL_GC 0 // NOLINT(cppcoreguidelines-macro-usage) +#define ECMASCRIPT_ENABLE_GC_LOG 0 // NOLINT(cppcoreguidelines-macro-usage) +#define ECMASCRIPT_ENABLE_ZAP_MEM 0 // NOLINT(cppcoreguidelines-macro-usage) +#define ECMASCRIPT_SWITCH_GC_MODE_TO_COMPRESS_GC 0 // NOLINT(cppcoreguidelines-macro-usage) +#define ECMASCRIPT_ENABLE_CAST_CHECK 0 // NOLINT(cppcoreguidelines-macro-usage) +#define ECMASCRIPT_ENABLE_HEAP_VERIFY 0 // NOLINT(cppcoreguidelines-macro-usage) +#define ECMASCRIPT_ENABLE_THREAD_CHECK 1 // NOLINT(cppcoreguidelines-macro-usage) #endif } // namespace panda::ecmascript diff --git a/runtime/base/string_helper.cpp b/runtime/base/string_helper.cpp index 8b32a7701..ef014d704 100644 --- a/runtime/base/string_helper.cpp +++ b/runtime/base/string_helper.cpp @@ -34,7 +34,7 @@ bool StringHelper::CheckDuplicate(EcmaString *string) return true; } bitSet.set(idx); - array++; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + array++; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) } } else { UNREACHABLE(); diff --git a/runtime/base/utf_helper.cpp b/runtime/base/utf_helper.cpp index e033f8876..bf5a8f682 100644 --- a/runtime/base/utf_helper.cpp +++ b/runtime/base/utf_helper.cpp @@ -207,7 +207,7 @@ std::pair ConvertUtf8ToUtf16Pair(const uint8_t *data, bool com if (combine) { uint32_t lead = ((codePoint >> (utf::PAIR_ELEMENT_WIDTH - utf::DATA_WIDTH)) + utf::U16_LEAD); uint32_t tail = ((codePoint & utf::MASK_10BIT) + utf::U16_TAIL) & utf::MASK_16BIT; - pair = U16_GET_SUPPLEMENTARY(lead, tail); // NOLINTNEXTLINE(hicpp-signed-bitwise) + pair = U16_GET_SUPPLEMENTARY(lead, tail); // NOLINT(hicpp-signed-bitwise) } else { pair |= ((codePoint >> (utf::PAIR_ELEMENT_WIDTH - utf::DATA_WIDTH)) + utf::U16_LEAD) << utf::PAIR_ELEMENT_WIDTH; pair |= ((codePoint & utf::MASK_10BIT) + utf::U16_TAIL) & utf::MASK_16BIT; diff --git a/runtime/class_linker/program_object-inl.h b/runtime/class_linker/program_object-inl.h index b4928850d..f96c1a625 100644 --- a/runtime/class_linker/program_object-inl.h +++ b/runtime/class_linker/program_object-inl.h @@ -19,8 +19,7 @@ #include "program_object.h" #include "plugins/ecmascript/runtime/mem/region_factory.h" -namespace panda { -namespace ecmascript { +namespace panda::ecmascript { const uint8_t *LexicalFunction::GetInstructions() const { JSTaggedValue inst = GetBytecode(); @@ -37,6 +36,5 @@ void Program::FreeMethodData(RegionFactory *factory) { factory->FreeBuffer(GetMethodsData()); } -} // namespace ecmascript -} // namespace panda +} // namespace panda::ecmascript #endif // ECMASCRIPT_CLASS_LINKER_PROGRAM_INL_H diff --git a/runtime/class_linker/program_object.h b/runtime/class_linker/program_object.h index ca1b58efb..17996eae4 100644 --- a/runtime/class_linker/program_object.h +++ b/runtime/class_linker/program_object.h @@ -19,8 +19,7 @@ #include "plugins/ecmascript/runtime/ecma_macros.h" #include "plugins/ecmascript/runtime/js_tagged_value-inl.h" -namespace panda { -namespace ecmascript { +namespace panda::ecmascript { class JSThread; class RegionFactory; @@ -79,6 +78,5 @@ public: inline JSTaggedValue GetObjectFromCache(uint32_t index) const; DECL_DUMP() }; -} // namespace ecmascript -} // namespace panda +} // namespace panda::ecmascript #endif // ECMASCRIPT_CLASS_LINKER_PROGRAM_H diff --git a/runtime/common.h b/runtime/common.h index d6b0677a8..4c13fee7f 100644 --- a/runtime/common.h +++ b/runtime/common.h @@ -18,8 +18,7 @@ #include "libpandabase/macros.h" -namespace panda { -namespace ecmascript { +namespace panda::ecmascript { enum BarrierMode { SKIP_BARRIER, WRITE_BARRIER, READ_BARRIER }; constexpr size_t NUM_MANDATORY_JSFUNC_ARGS = 3; @@ -34,7 +33,6 @@ constexpr size_t NUM_MANDATORY_JSFUNC_ARGS = 3; // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define DUMP_API_ATTR __attribute__((visibility("default"), used)) #endif -} // namespace ecmascript -} // namespace panda +} // namespace panda::ecmascript #endif // ECMASCRIPT_COMMON_H diff --git a/runtime/ecma_class_linker_extension.h b/runtime/ecma_class_linker_extension.h index 5252357fe..a74ea46e1 100644 --- a/runtime/ecma_class_linker_extension.h +++ b/runtime/ecma_class_linker_extension.h @@ -24,8 +24,7 @@ namespace panda::coretypes { class Class; // NOLINT(bugprone-forward-declaration-namespace) } // namespace panda::coretypes -namespace panda { -namespace ecmascript { +namespace panda::ecmascript { class EcmaVM; class EcmaClassLinkerExtension : public ClassLinkerExtension { public: @@ -103,7 +102,6 @@ private: EcmaVM *vm_ {nullptr}; }; -} // namespace ecmascript -} // namespace panda +} // namespace panda::ecmascript #endif // ECMASCRIPT_ECMA_CLASS_LINKER_EXTENSION_H diff --git a/runtime/ecma_string.h b/runtime/ecma_string.h index 8ef74a513..b49a488bb 100644 --- a/runtime/ecma_string.h +++ b/runtime/ecma_string.h @@ -25,8 +25,7 @@ #include "plugins/ecmascript/runtime/js_tagged_value.h" #include "plugins/ecmascript/runtime/mem/tagged_object.h" -namespace panda { -namespace ecmascript { +namespace panda::ecmascript { template class JSHandle; class EcmaVM; @@ -338,6 +337,5 @@ private: template static int32_t IndexOf(Span &lhsSp, Span &rhsSp, int32_t pos, int32_t max); }; -} // namespace ecmascript -} // namespace panda +} // namespace panda::ecmascript #endif // ECMASCRIPT_STRING_H diff --git a/runtime/ecma_vm.cpp b/runtime/ecma_vm.cpp index d26c0a9b0..fe51b3544 100644 --- a/runtime/ecma_vm.cpp +++ b/runtime/ecma_vm.cpp @@ -66,12 +66,10 @@ #include "runtime/mem/gc/reference-processor/empty_reference_processor.h" #include "runtime/mem/object_helpers.h" #include "plugins/ecmascript/runtime/compiler/ecmascript_runtime_interface.h" -#include "runtime/compiler.h" #include "handle_scope-inl.h" #include "include/coretypes/native_pointer.h" #include "include/runtime.h" -#include "include/runtime_notification.h" #include "include/method.h" #include "mem/internal_allocator.h" #include "trace/trace.h" diff --git a/runtime/global_dictionary-inl.h b/runtime/global_dictionary-inl.h index 5d9d2a166..ce7f9b88a 100644 --- a/runtime/global_dictionary-inl.h +++ b/runtime/global_dictionary-inl.h @@ -21,8 +21,7 @@ #include "plugins/ecmascript/runtime/mem/c_containers.h" #include "plugins/ecmascript/runtime/tagged_hash_table-inl.h" -namespace panda { -namespace ecmascript { +namespace panda::ecmascript { int GlobalDictionary::Hash(const JSTaggedValue &key) { if (key.IsHeapObject()) { @@ -180,7 +179,6 @@ void GlobalDictionary::InvalidateAndReplaceEntry(JSThread *thread, const JSHandl dictHandle->UpdateValue(thread, entry, newBox.GetTaggedValue()); dictHandle->GetBox(entry)->Clear(thread); } -} // namespace ecmascript -} // namespace panda +} // namespace panda::ecmascript #endif diff --git a/runtime/global_dictionary.h b/runtime/global_dictionary.h index 7c9373a14..bcdb4a4dc 100644 --- a/runtime/global_dictionary.h +++ b/runtime/global_dictionary.h @@ -23,8 +23,7 @@ #include "plugins/ecmascript/runtime/property_attributes.h" #include "plugins/ecmascript/runtime/tagged_hash_table.h" -namespace panda { -namespace ecmascript { +namespace panda::ecmascript { class GlobalDictionary : public OrderTaggedHashTable { public: using OrderHashTableT = OrderTaggedHashTable; @@ -88,6 +87,5 @@ private: static constexpr int ENTRY_DETAILS_INDEX = 2; static constexpr int ENTRY_SIZE = 3; }; -} // namespace ecmascript -} // namespace panda +} // namespace panda::ecmascript #endif diff --git a/runtime/ic/ic_runtime.cpp b/runtime/ic/ic_runtime.cpp index 49813b641..d7b719f7c 100644 --- a/runtime/ic/ic_runtime.cpp +++ b/runtime/ic/ic_runtime.cpp @@ -28,7 +28,7 @@ #include "plugins/ecmascript/runtime/object_factory-inl.h" #include "plugins/ecmascript/runtime/tagged_dictionary.h" namespace panda::ecmascript { -#define TRACE_IC 0 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) +#define TRACE_IC 0 // NOLINT(cppcoreguidelines-macro-usage) void ICRuntime::UpdateLoadHandler(const ObjectOperator &op, JSHandle key, JSHandle receiver) diff --git a/runtime/ic/property_box.h b/runtime/ic/property_box.h index 063d7e891..2bc856c83 100644 --- a/runtime/ic/property_box.h +++ b/runtime/ic/property_box.h @@ -21,8 +21,7 @@ #include "plugins/ecmascript/runtime/js_tagged_value.h" #include "plugins/ecmascript/runtime/property_attributes.h" -namespace panda { -namespace ecmascript { +namespace panda::ecmascript { class PropertyBox : public TaggedObject { public: static PropertyBox *Cast(ObjectHeader *object) @@ -44,7 +43,6 @@ public: DECL_VISIT_OBJECT(VALUE_OFFSET, SIZE) DECL_DUMP() }; -} // namespace ecmascript -} // namespace panda +} // namespace panda::ecmascript #endif diff --git a/runtime/ic/proto_change_details.h b/runtime/ic/proto_change_details.h index d2b329d8d..091820746 100644 --- a/runtime/ic/proto_change_details.h +++ b/runtime/ic/proto_change_details.h @@ -21,8 +21,7 @@ #include "plugins/ecmascript/runtime/js_tagged_value.h" #include "plugins/ecmascript/runtime/weak_vector.h" -namespace panda { -namespace ecmascript { +namespace panda::ecmascript { class ProtoChangeMarker : public TaggedObject { public: using HasChangedField = BitField; @@ -68,7 +67,6 @@ public: JSTaggedValue Get(uint32_t index); }; -} // namespace ecmascript -} // namespace panda +} // namespace panda::ecmascript #endif // ECMASCRIPT_IC_PROTOTYPE_CHANGE_DETAILS_H diff --git a/runtime/interpreter/interpreter-inl.h b/runtime/interpreter/interpreter-inl.h index 262428361..a438eb585 100644 --- a/runtime/interpreter/interpreter-inl.h +++ b/runtime/interpreter/interpreter-inl.h @@ -5,7 +5,6 @@ #ifndef PANDA_RUNTIME_ECMASCRIPT_INTERPRETER_INL_H #define PANDA_RUNTIME_ECMASCRIPT_INTERPRETER_INL_H -#include "plugins/ecmascript/runtime/class_linker/program_object-inl.h" #include "plugins/ecmascript/runtime/class_linker/program_object-inl.h" #include "plugins/ecmascript/runtime/ecma_string.h" #include "plugins/ecmascript/runtime/ecma_vm.h" diff --git a/runtime/js_date.cpp b/runtime/js_date.cpp index a88561f02..957c31d27 100644 --- a/runtime/js_date.cpp +++ b/runtime/js_date.cpp @@ -492,8 +492,7 @@ JSTaggedValue JSDate::Now() { // time from now is in ms. int64_t ans; - struct timeval tv { - }; + struct timeval tv {}; gettimeofday(&tv, nullptr); ans = static_cast(tv.tv_sec) * MS_PER_SECOND + (tv.tv_usec / MS_PER_SECOND); return JSTaggedValue(static_cast(ans)); @@ -581,8 +580,7 @@ int64_t JSDate::GetLocalOffsetFromOS(int64_t timeMs, bool isLocal) } timeMs /= JSDate::THOUSAND; time_t tv = std::time(reinterpret_cast(&timeMs)); - struct tm tm { - }; + struct tm tm {}; // localtime_r is only suitable for linux. struct tm *t = localtime_r(&tv, &tm); // tm_gmtoff includes any daylight savings offset. diff --git a/runtime/js_generator_object.h b/runtime/js_generator_object.h index 97cf93aa1..a00641643 100644 --- a/runtime/js_generator_object.h +++ b/runtime/js_generator_object.h @@ -18,8 +18,7 @@ #include "plugins/ecmascript/runtime/js_function.h" -namespace panda { -namespace ecmascript { +namespace panda::ecmascript { enum class JSGeneratorState { UNDEFINED = 0, SUSPENDED_START, @@ -95,7 +94,6 @@ public: DECL_VISIT_OBJECT_FOR_JS_OBJECT(JSObject, GENERATOR_STATE_OFFSET, SIZE) DECL_DUMP() }; -} // namespace ecmascript -} // namespace panda +} // namespace panda::ecmascript #endif // ECMASCRIPT_JS_GENERATOR_OBJECT_H diff --git a/runtime/js_locale.h b/runtime/js_locale.h index 47a0be226..33d4a5a9c 100644 --- a/runtime/js_locale.h +++ b/runtime/js_locale.h @@ -77,7 +77,7 @@ constexpr uint8_t INTL_INDEX_EIGHT = 8; class JSIntlIterator : public icu::Locale::Iterator { public: - JSIntlIterator(const JSHandle &data, uint32_t length) : length_(length), curIdx_(0) + JSIntlIterator(const JSHandle &data, uint32_t length) : length_(length) { for (uint32_t idx = 0; idx < length; idx++) { std::string str = base::StringHelper::ToStdString(EcmaString::Cast(data->Get(idx).GetTaggedObject())); @@ -475,8 +475,7 @@ public: const char *formalLocale = locale.getName(); UResourceBundle *localeRes = ures_open(packageName, formalLocale, &status); if (localeRes != nullptr && status == U_ZERO_ERROR) { - bool flag = (key == nullptr) ? true : false; - if (flag) { + if (key == nullptr) { res = true; } else { UResourceBundle *keyRes = ures_getByKey(localeRes, key, nullptr, &status); diff --git a/runtime/js_object.h b/runtime/js_object.h index 56ac39b44..d23dd1722 100644 --- a/runtime/js_object.h +++ b/runtime/js_object.h @@ -32,8 +32,7 @@ #include "plugins/ecmascript/runtime/property_attributes.h" #include "plugins/ecmascript/runtime/tagged_array.h" -namespace panda { -namespace ecmascript { +namespace panda::ecmascript { class ObjectOperator; class AccessorData; @@ -625,7 +624,6 @@ private: static uint32_t ComputeElementCapacity(uint32_t oldCapacity); static uint32_t ComputePropertyCapacity(uint32_t oldCapacity); }; -} // namespace ecmascript -} // namespace panda +} // namespace panda::ecmascript #endif diff --git a/runtime/js_proxy.cpp b/runtime/js_proxy.cpp index cc0a51425..7d60ce1f9 100644 --- a/runtime/js_proxy.cpp +++ b/runtime/js_proxy.cpp @@ -836,7 +836,7 @@ JSHandle JSProxy::OwnPropertyKeys(JSThread *thread, const JSHandle< // ES6 9.5.13 [[Call]] (thisArgument, argumentsList) JSTaggedValue JSProxy::CallInternal(JSThread *thread, const JSHandle &proxy, const JSHandle &thisArg, uint32_t argc, - const JSTaggedType argv[] // NOLINTNEXTLINE(modernize-avoid-c-arrays) + const JSTaggedType argv[] // NOLINT(modernize-avoid-c-arrays) ) { // step 1 ~ 4 get ProxyHandler and ProxyTarget @@ -875,7 +875,7 @@ JSTaggedValue JSProxy::CallInternal(JSThread *thread, const JSHandle &p // ES6 9.5.14 [[Construct]] ( argumentsList, newTarget) JSTaggedValue JSProxy::ConstructInternal(JSThread *thread, const JSHandle &proxy, uint32_t argc, - const JSTaggedType argv[], // NOLINTNEXTLINE(modernize-avoid-c-arrays) + const JSTaggedType argv[], // NOLINT(modernize-avoid-c-arrays) const JSHandle &newTarget) { // step 1 ~ 4 get ProxyHandler and ProxyTarget diff --git a/runtime/js_serializer.h b/runtime/js_serializer.h index b499dc590..99a12bf18 100644 --- a/runtime/js_serializer.h +++ b/runtime/js_serializer.h @@ -183,7 +183,7 @@ private: class SerializationData { public: - SerializationData() : dataSize_(0), value_(nullptr) {} + SerializationData() : value_(nullptr) {} ~SerializationData() = default; uint8_t *GetData() const @@ -206,8 +206,7 @@ private: free(ptr); } }; - // NOLINTNEXTLINE(modernize-use-default-member-init) - size_t dataSize_; + size_t dataSize_ {0}; std::unique_ptr value_; private: diff --git a/runtime/js_string_iterator.h b/runtime/js_string_iterator.h index 12a7fa6d3..1873c740b 100644 --- a/runtime/js_string_iterator.h +++ b/runtime/js_string_iterator.h @@ -21,8 +21,7 @@ #include "plugins/ecmascript/runtime/js_object.h" #include "plugins/ecmascript/runtime/js_tagged_value-inl.h" -namespace panda { -namespace ecmascript { +namespace panda::ecmascript { class JSStringIterator : public JSObject { public: CAST_CHECK(JSStringIterator, IsStringIterator); @@ -36,6 +35,5 @@ public: DECL_VISIT_OBJECT_FOR_JS_OBJECT(JSObject, ITERATED_STRING_OFFSET, SIZE) DECL_DUMP() }; -} // namespace ecmascript -} // namespace panda +} // namespace panda::ecmascript #endif // ECMASCRIPT_JS_STRING_ITERATOR_H diff --git a/runtime/js_symbol.h b/runtime/js_symbol.h index 50abe274b..de1fc4c78 100644 --- a/runtime/js_symbol.h +++ b/runtime/js_symbol.h @@ -19,8 +19,7 @@ #include "plugins/ecmascript/runtime/ecma_string.h" #include "plugins/ecmascript/runtime/js_object.h" -namespace panda { -namespace ecmascript { +namespace panda::ecmascript { class JSSymbol : public TaggedObject { public: static constexpr uint64_t IS_PRIVATE = 1U << 0U; @@ -157,6 +156,5 @@ public: DECL_VISIT_OBJECT(HASHFIELD_OFFSET, SIZE) }; -} // namespace ecmascript -} // namespace panda +} // namespace panda::ecmascript #endif // ECMASCRIPT_NAME_H diff --git a/runtime/js_tagged_number.h b/runtime/js_tagged_number.h index 79d87e073..9638311c8 100644 --- a/runtime/js_tagged_number.h +++ b/runtime/js_tagged_number.h @@ -23,8 +23,7 @@ #include "plugins/ecmascript/runtime/js_tagged_value.h" #include "plugins/ecmascript/runtime/object_factory.h" -namespace panda { -namespace ecmascript { +namespace panda::ecmascript { class JSTaggedNumber final : public JSTaggedValue { public: constexpr JSTaggedNumber() = default; @@ -169,6 +168,5 @@ public: private: constexpr explicit JSTaggedNumber(JSTaggedType v) : JSTaggedValue(v) {} }; -} // namespace ecmascript -} // namespace panda +} // namespace panda::ecmascript #endif // ECMASCRIPT_JS_NUMBER_H diff --git a/runtime/js_tagged_value-inl.h b/runtime/js_tagged_value-inl.h index 1f291ff7e..fb5ef74df 100644 --- a/runtime/js_tagged_value-inl.h +++ b/runtime/js_tagged_value-inl.h @@ -968,14 +968,14 @@ inline bool JSTaggedValue::StringToElementIndex(JSTaggedValue key, uint32_t *out auto strObj = static_cast(key.GetTaggedObject()); uint32_t len = strObj->GetLength(); - if (len == 0 || len > MAX_INDEX_LEN) { // NOLINTNEXTLINEreadability-magic-numbers) + if (len == 0 || len > MAX_INDEX_LEN) { return false; } uint32_t c; if (strObj->IsUtf16()) { - c = strObj->GetDataUtf16()[0]; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + c = strObj->GetDataUtf16()[0]; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) } else { - c = strObj->GetDataUtf8()[0]; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + c = strObj->GetDataUtf8()[0]; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) } uint64_t n = 0; if (c >= '0' && c <= '9') { @@ -990,9 +990,9 @@ inline bool JSTaggedValue::StringToElementIndex(JSTaggedValue key, uint32_t *out n = c - '0'; for (uint32_t i = 1; i < len; i++) { if (strObj->IsUtf16()) { - c = strObj->GetDataUtf16()[i]; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + c = strObj->GetDataUtf16()[i]; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) } else { - c = strObj->GetDataUtf8()[i]; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + c = strObj->GetDataUtf8()[i]; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) } if (c < '0' || c > '9') { return false; diff --git a/runtime/mem/area.h b/runtime/mem/area.h index 62ffccbbe..45eb23930 100644 --- a/runtime/mem/area.h +++ b/runtime/mem/area.h @@ -21,7 +21,7 @@ class Area { public: Area(uintptr_t begin, size_t capacity) // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) - : begin_(begin), end_(begin + capacity), next_(nullptr), prev_(nullptr) + : begin_(begin), end_(begin + capacity) { } ~Area() = default; @@ -68,8 +68,8 @@ private: } uintptr_t begin_; uintptr_t end_; - Area *next_; - Area *prev_; + Area *next_ {nullptr}; + Area *prev_ {nullptr}; }; } // namespace panda::ecmascript diff --git a/runtime/mem/caddress_allocator.h b/runtime/mem/caddress_allocator.h index bf7071d7b..dfecd6292 100644 --- a/runtime/mem/caddress_allocator.h +++ b/runtime/mem/caddress_allocator.h @@ -82,7 +82,7 @@ public: } template - void construct(U *p, Args &&... args) // NOLINT(readability-identifier-naming) + void construct(U *p, Args &&...args) // NOLINT(readability-identifier-naming) { if (p == nullptr) { return; @@ -114,7 +114,7 @@ public: } template - [[nodiscard]] S *New(Args &&... args) + [[nodiscard]] S *New(Args &&...args) { auto p = reinterpret_cast(Allocate(sizeof(S))); new (p) S(std::forward(args)...); diff --git a/runtime/mem/chunk.h b/runtime/mem/chunk.h index db033fd4f..434451ca8 100644 --- a/runtime/mem/chunk.h +++ b/runtime/mem/chunk.h @@ -59,7 +59,7 @@ public: } template - [[nodiscard]] T *New(Args &&... args) + [[nodiscard]] T *New(Args &&...args) { auto p = reinterpret_cast(Allocate(sizeof(T))); new (p) T(std::forward(args)...); diff --git a/runtime/mem/chunk_allocator.h b/runtime/mem/chunk_allocator.h index 69da46a4f..9ff36a147 100644 --- a/runtime/mem/chunk_allocator.h +++ b/runtime/mem/chunk_allocator.h @@ -91,7 +91,7 @@ public: void deallocate([[maybe_unused]] pointer p, [[maybe_unused]] size_type n) {} template - void construct(U *p, Args &&... args) // NOLINT(readability-identifier-naming) + void construct(U *p, Args &&...args) // NOLINT(readability-identifier-naming) { ::new (static_cast(p)) U(std::forward(args)...); } diff --git a/runtime/mem/compress_collector.h b/runtime/mem/compress_collector.h index 1cd68e77b..fa44094c2 100644 --- a/runtime/mem/compress_collector.h +++ b/runtime/mem/compress_collector.h @@ -19,8 +19,7 @@ #include "plugins/ecmascript/runtime/mem/parallel_work_helper.h" #include "plugins/ecmascript/runtime/mem/semi_space_collector.h" -namespace panda { -namespace ecmascript { +namespace panda::ecmascript { class Heap; class JSHClass; @@ -53,7 +52,6 @@ private: friend class WorkerHelper; friend class Heap; }; -} // namespace ecmascript -} // namespace panda +} // namespace panda::ecmascript #endif // ECMASCRIPT_MEM_COMPRESS_COLLECTOR_H diff --git a/runtime/mem/machine_code.h b/runtime/mem/machine_code.h index e1250ab26..44a2a3fd9 100644 --- a/runtime/mem/machine_code.h +++ b/runtime/mem/machine_code.h @@ -20,8 +20,7 @@ #include "plugins/ecmascript/runtime/js_tagged_value.h" #include "plugins/ecmascript/runtime/mem/tagged_object.h" -namespace panda { -namespace ecmascript { +namespace panda::ecmascript { class MachineCode : public TaggedObject { public: static MachineCode *Cast(ObjectHeader *object) @@ -75,7 +74,6 @@ public: NO_COPY_SEMANTIC(MachineCode); NO_MOVE_SEMANTIC(MachineCode); }; -} // namespace ecmascript -} // namespace panda +} // namespace panda::ecmascript #endif // PANDA_RUNTIME_ECMASCRIPT_MEM_MACHINE_CODE_H diff --git a/runtime/mem/mark_stack.h b/runtime/mem/mark_stack.h index ec0b6c187..2bbdd43fe 100644 --- a/runtime/mem/mark_stack.h +++ b/runtime/mem/mark_stack.h @@ -22,8 +22,7 @@ #include "plugins/ecmascript/runtime/mem/region_factory.h" #include "plugins/ecmascript/runtime/js_tagged_value.h" -namespace panda { -namespace ecmascript { +namespace panda::ecmascript { class Stack { public: Stack() = default; @@ -141,7 +140,6 @@ private: using MarkStack = ContinuousStack; using ProcessQueue = ContinuousStack; -} // namespace ecmascript -} // namespace panda +} // namespace panda::ecmascript #endif // ECMASCRIPT_MEM_MARK_STACK_H diff --git a/runtime/mem/mark_word.h b/runtime/mem/mark_word.h index eb830dc22..bcbcb6e45 100644 --- a/runtime/mem/mark_word.h +++ b/runtime/mem/mark_word.h @@ -22,8 +22,7 @@ #include "utils/bit_field.h" #include "libpandabase/mem/mem.h" -namespace panda { -namespace ecmascript { +namespace panda::ecmascript { class TaggedObject; class JSHClass; @@ -70,7 +69,6 @@ public: private: MarkWordType value_ {0}; }; -} // namespace ecmascript -} // namespace panda +} // namespace panda::ecmascript #endif // ECMASCRIPT_MEM_MARK_WORD_H diff --git a/runtime/mem/mem_manager-inl.h b/runtime/mem/mem_manager-inl.h index 54054aff9..90912ec98 100644 --- a/runtime/mem/mem_manager-inl.h +++ b/runtime/mem/mem_manager-inl.h @@ -24,7 +24,6 @@ #include "plugins/ecmascript/runtime/mem/heap-inl.h" #include "plugins/ecmascript/runtime/mem/object_xray.h" #include "plugins/ecmascript/runtime/js_hclass.h" -#include "plugins/ecmascript/runtime/js_hclass.h" namespace panda::ecmascript { TaggedObject *MemManager::AllocateYoungGenerationOrHugeObject(JSHClass *hclass) diff --git a/runtime/mem/mix_space_collector.h b/runtime/mem/mix_space_collector.h index 6160e68dc..59031fec9 100644 --- a/runtime/mem/mix_space_collector.h +++ b/runtime/mem/mix_space_collector.h @@ -27,8 +27,7 @@ #include "plugins/ecmascript/runtime/mem/remembered_set.h" #include "plugins/ecmascript/runtime/mem/semi_space_collector.h" -namespace panda { -namespace ecmascript { +namespace panda::ecmascript { class Heap; class JSHClass; @@ -64,7 +63,6 @@ private: friend class WorkerHelper; friend class Heap; }; -} // namespace ecmascript -} // namespace panda +} // namespace panda::ecmascript #endif // ECMASCRIPT_MEM_OLD_SAPACE_COLLECTOR_H diff --git a/runtime/mem/parallel_work_helper.h b/runtime/mem/parallel_work_helper.h index b62eeb016..f68542137 100644 --- a/runtime/mem/parallel_work_helper.h +++ b/runtime/mem/parallel_work_helper.h @@ -46,7 +46,7 @@ enum ParallelGCTaskPhase { class WorkNode { public: - explicit WorkNode(Stack *stack) : next_(nullptr), stack_(stack) {} + explicit WorkNode(Stack *stack) : stack_(stack) {} ~WorkNode() { delete stack_; @@ -90,13 +90,13 @@ public: } private: - WorkNode *next_; + WorkNode *next_ {nullptr}; Stack *stack_; }; class GlobalWorkList { public: - GlobalWorkList() : top_(nullptr) {} + GlobalWorkList() = default; ~GlobalWorkList() = default; NO_COPY_SEMANTIC(GlobalWorkList); diff --git a/runtime/mem/region.h b/runtime/mem/region.h index c1a0a9180..fe956eedd 100644 --- a/runtime/mem/region.h +++ b/runtime/mem/region.h @@ -50,7 +50,6 @@ public: Region(Space *space, Heap *heap, uintptr_t allocateBase, uintptr_t begin, uintptr_t end) : space_(space), heap_(heap), - flags_(0), allocateBase_(allocateBase), // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) begin_(begin), @@ -331,7 +330,7 @@ private: static constexpr double MOST_OBJECT_ALIVE_THRESHOLD_PERCENT = 0.8; Space *space_; Heap *heap_; - uintptr_t flags_; // Memory alignment, only low 32bits are used now + uintptr_t flags_ {0}; // Memory alignment, only low 32bits are used now uintptr_t allocateBase_; uintptr_t begin_; uintptr_t end_; diff --git a/runtime/mem/region_factory.h b/runtime/mem/region_factory.h index dcd232a0d..2718197c4 100644 --- a/runtime/mem/region_factory.h +++ b/runtime/mem/region_factory.h @@ -50,7 +50,7 @@ public: // implemented by AllocateBuffer template - std::enable_if_t, T *> New(Args &&... args) + std::enable_if_t, T *> New(Args &&...args) { void *p = AllocateBuffer(sizeof(T)); if (UNLIKELY(p == nullptr)) { diff --git a/runtime/mem/semi_space_collector.h b/runtime/mem/semi_space_collector.h index 03cdb1910..1c127ff74 100644 --- a/runtime/mem/semi_space_collector.h +++ b/runtime/mem/semi_space_collector.h @@ -30,8 +30,7 @@ #include "os/mutex.h" -namespace panda { -namespace ecmascript { +namespace panda::ecmascript { class Heap; class JSHClass; class WorkerHelper; @@ -74,7 +73,6 @@ private: friend class WorkerHelper; friend class Heap; }; -} // namespace ecmascript -} // namespace panda +} // namespace panda::ecmascript #endif // ECMASCRIPT_MEM_SEMI_SAPACE_COLLECTOR_H diff --git a/runtime/mem/space.cpp b/runtime/mem/space.cpp index a912ece7d..5dd04f6ce 100644 --- a/runtime/mem/space.cpp +++ b/runtime/mem/space.cpp @@ -31,8 +31,7 @@ Space::Space(Heap *heap, MemSpaceType spaceType, size_t initialCapacity, size_t regionFactory_(vm_->GetRegionFactory()), spaceType_(spaceType), initialCapacity_(initialCapacity), - maximumCapacity_(maximumCapacity), - committedSize_(0) + maximumCapacity_(maximumCapacity) { } @@ -124,7 +123,7 @@ size_t Space::GetHeapObjectSize() const } SemiSpace::SemiSpace(Heap *heap, size_t initialCapacity, size_t maximumCapacity) - : Space(heap, MemSpaceType::SEMI_SPACE, initialCapacity, maximumCapacity), ageMark_(0) + : Space(heap, MemSpaceType::SEMI_SPACE, initialCapacity, maximumCapacity) { } diff --git a/runtime/mem/space.h b/runtime/mem/space.h index 7a28d3c34..69b78779b 100644 --- a/runtime/mem/space.h +++ b/runtime/mem/space.h @@ -218,7 +218,7 @@ public: size_t GetAllocatedSizeSinceGC() const; private: - uintptr_t ageMark_; + uintptr_t ageMark_ {0}; }; class OldSpace : public Space { diff --git a/runtime/napi/include/jsnapi.h b/runtime/napi/include/jsnapi.h index 0646d45d6..1da1a7915 100644 --- a/runtime/napi/include/jsnapi.h +++ b/runtime/napi/include/jsnapi.h @@ -341,8 +341,7 @@ private: friend class Local; }; -class PUBLIC_API PrimitiveRef : public JSValueRef { -}; +class PUBLIC_API PrimitiveRef : public JSValueRef {}; class PUBLIC_API IntegerRef : public PrimitiveRef { public: @@ -545,11 +544,11 @@ public: }; using FunctionCallback = Local (*)(EcmaVM *, Local, - const Local[], // NOLINTNEXTLINE(modernize-avoid-c-arrays) + const Local[], // NOLINT(modernize-avoid-c-arrays) int32_t, void *); using FunctionCallbackWithNewTarget = Local (*)(EcmaVM *, Local, Local, - const Local[], // NOLINTNEXTLINE(modernize-avoid-c-arrays) + const Local[], // NOLINT(modernize-avoid-c-arrays) int32_t, void *); class PUBLIC_API FunctionRef : public ObjectRef { public: @@ -559,10 +558,10 @@ public: static Local NewClassFunction(EcmaVM *vm, FunctionCallbackWithNewTarget nativeFunc, Deleter deleter, void *data); Local Call(const EcmaVM *vm, Local thisObj, - const Local argv[], // NOLINTNEXTLINE(modernize-avoid-c-arrays) + const Local argv[], // NOLINT(modernize-avoid-c-arrays) int32_t length); Local Constructor(const EcmaVM *vm, - const Local argv[], // NOLINTNEXTLINE(modernize-avoid-c-arrays) + const Local argv[], // NOLINT(modernize-avoid-c-arrays) int32_t length); Local GetFunctionPrototype(const EcmaVM *vm); // Inherit Prototype from parent function diff --git a/runtime/napi/jsnapi.cpp b/runtime/napi/jsnapi.cpp index df698c84b..454a4edf2 100644 --- a/runtime/napi/jsnapi.cpp +++ b/runtime/napi/jsnapi.cpp @@ -936,7 +936,7 @@ Local FunctionRef::NewClassFunction(EcmaVM *vm, FunctionCallbackWit } Local FunctionRef::Call(const EcmaVM *vm, Local thisObj, - const Local argv[], // NOLINTNEXTLINE(modernize-avoid-c-arrays) + const Local argv[], // NOLINT(modernize-avoid-c-arrays) int32_t length) { JSThread *thread = vm->GetJSThread(); @@ -965,7 +965,7 @@ Local FunctionRef::Call(const EcmaVM *vm, Local thisObj, } Local FunctionRef::Constructor(const EcmaVM *vm, - const Local argv[], // NOLINTNEXTLINE(modernize-avoid-c-arrays) + const Local argv[], // NOLINT(modernize-avoid-c-arrays) int32_t length) { JSThread *thread = vm->GetJSThread(); diff --git a/runtime/regexp/regexp_executor.cpp b/runtime/regexp/regexp_executor.cpp index 1001c72b6..292c01948 100644 --- a/runtime/regexp/regexp_executor.cpp +++ b/runtime/regexp/regexp_executor.cpp @@ -238,8 +238,7 @@ void RegExpExecutor::HandleOpSaveReset(const DynChunk &byteCode, uint8_t opCode) uint32_t catpureStartIndex = byteCode.GetU8(GetCurrentPC() + SAVE_RESET_START); uint32_t catpureEndIndex = byteCode.GetU8(GetCurrentPC() + SAVE_RESET_END); for (uint32_t i = catpureStartIndex; i <= catpureEndIndex; i++) { - CaptureState *captureState = - &captureResultList_[i]; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + CaptureState *captureState = &captureResultList_[i]; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) captureState->captureStart = nullptr; captureState->captureEnd = nullptr; } @@ -655,9 +654,9 @@ MatchResult RegExpExecutor::GetResult(const JSThread *thread, bool isSuccess) co void RegExpExecutor::PushRegExpState(StateType type, uint32_t pc) { ReAllocStack(stateStackLen_ + 1); - auto state = reinterpret_cast( - stateStack_ + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) - stateStackLen_ * stateSize_); + auto state = + reinterpret_cast(stateStack_ + // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) + stateStackLen_ * stateSize_); state->type_ = type; state->currentPc_ = pc; state->currentStack_ = currentStack_; diff --git a/runtime/regexp/regexp_executor.h b/runtime/regexp/regexp_executor.h index b21a20e94..bc5923343 100644 --- a/runtime/regexp/regexp_executor.h +++ b/runtime/regexp/regexp_executor.h @@ -106,16 +106,16 @@ public: const uint8_t *cptr = *pp; if (!isWideChar_) { c = *cptr; - *pp += 1; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + *pp += 1; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) } else { - uint16_t c1 = *(uint16_t *)cptr; // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) + uint16_t c1 = *(uint16_t *)cptr; // NOLINT(cppcoreguidelines-pro-type-cstyle-cast) c = c1; - cptr += WIDE_CHAR_SIZE; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + cptr += WIDE_CHAR_SIZE; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) if (U16_IS_LEAD(c) && IsUtf16() && cptr < end) { - c1 = *(uint16_t *)cptr; // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) + c1 = *(uint16_t *)cptr; // NOLINT(cppcoreguidelines-pro-type-cstyle-cast) if (U16_IS_TRAIL(c1)) { - c = U16_GET_SUPPLEMENTARY(c, c1); // NOLINTNEXTLINE(hicpp-signed-bitwise) - cptr += WIDE_CHAR_SIZE; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + c = U16_GET_SUPPLEMENTARY(c, c1); // NOLINT(hicpp-signed-bitwise) + cptr += WIDE_CHAR_SIZE; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) } } *pp = cptr; @@ -130,13 +130,13 @@ public: if (!isWideChar_) { c = *cptr; } else { - uint16_t c1 = *(uint16_t *)cptr; // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) + uint16_t c1 = *(uint16_t *)cptr; // NOLINT(cppcoreguidelines-pro-type-cstyle-cast) c = c1; - cptr += WIDE_CHAR_SIZE; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + cptr += WIDE_CHAR_SIZE; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) if (U16_IS_LEAD(c) && IsUtf16() && cptr < end) { - c1 = *(uint16_t *)cptr; // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) + c1 = *(uint16_t *)cptr; // NOLINT(cppcoreguidelines-pro-type-cstyle-cast) if (U16_IS_TRAIL(c1)) { - c = U16_GET_SUPPLEMENTARY(c, c1); // NOLINTNEXTLINE(hicpp-signed-bitwise) + c = U16_GET_SUPPLEMENTARY(c, c1); // NOLINT(hicpp-signed-bitwise) } } } @@ -147,14 +147,14 @@ public: { const uint8_t *cptr = *pp; if (!isWideChar_) { - *pp += 1; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + *pp += 1; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) } else { - uint16_t c1 = *(uint16_t *)cptr; // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) - cptr += WIDE_CHAR_SIZE; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + uint16_t c1 = *(uint16_t *)cptr; // NOLINT(cppcoreguidelines-pro-type-cstyle-cast) + cptr += WIDE_CHAR_SIZE; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) if (U16_IS_LEAD(c1) && IsUtf16() && cptr < end) { - c1 = *(uint16_t *)cptr; // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) + c1 = *(uint16_t *)cptr; // NOLINT(cppcoreguidelines-pro-type-cstyle-cast) if (U16_IS_TRAIL(c1)) { - cptr += WIDE_CHAR_SIZE; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + cptr += WIDE_CHAR_SIZE; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) } } *pp = cptr; @@ -166,15 +166,16 @@ public: uint32_t c; const uint8_t *cptr = p; if (!isWideChar_) { - c = *(cptr - 1); // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + c = *(cptr - 1); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) } else { - cptr -= WIDE_CHAR_SIZE; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) - uint16_t c1 = *(uint16_t *)cptr; // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) + cptr -= WIDE_CHAR_SIZE; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) + uint16_t c1 = *reinterpret_cast(cptr); c = c1; if (U16_IS_TRAIL(c) && IsUtf16() && cptr > start) { - c1 = ((uint16_t *)cptr)[-1]; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + c1 = (reinterpret_cast(cptr))[-1]; if (U16_IS_LEAD(c1)) { - c = U16_GET_SUPPLEMENTARY(c1, c); // NOLINTNEXTLINE(hicpp-signed-bitwise) + c = U16_GET_SUPPLEMENTARY(c1, c); // NOLINT(hicpp-signed-bitwise) } } } @@ -186,18 +187,20 @@ public: uint32_t c; const uint8_t *cptr = *pp; if (!isWideChar_) { - c = *(cptr - 1); // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) - cptr -= 1; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + c = *(cptr - 1); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) + cptr -= 1; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) *pp = cptr; } else { - cptr -= WIDE_CHAR_SIZE; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) - uint16_t c1 = *(uint16_t *)cptr; // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) + cptr -= WIDE_CHAR_SIZE; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) + uint16_t c1 = *reinterpret_cast(cptr); c = c1; if (U16_IS_TRAIL(c) && IsUtf16() && cptr > start) { - c1 = ((uint16_t *)cptr)[-1]; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + c1 = (reinterpret_cast(cptr))[-1]; if (U16_IS_LEAD(c1)) { - c = U16_GET_SUPPLEMENTARY(c1, c); // NOLINTNEXTLINE(hicpp-signed-bitwise) - cptr -= WIDE_CHAR_SIZE; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + c = U16_GET_SUPPLEMENTARY(c1, c); // NOLINT(hicpp-signed-bitwise) + cptr -= WIDE_CHAR_SIZE; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) } } *pp = cptr; @@ -209,15 +212,17 @@ public: { const uint8_t *cptr = *pp; if (!isWideChar_) { - cptr -= 1; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + cptr -= 1; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) *pp = cptr; } else { - cptr -= WIDE_CHAR_SIZE; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) - uint16_t c1 = *(uint16_t *)cptr; // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) + cptr -= WIDE_CHAR_SIZE; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) + uint16_t c1 = *reinterpret_cast(cptr); if (U16_IS_TRAIL(c1) && IsUtf16() && cptr > start) { - c1 = ((uint16_t *)cptr)[-1]; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + c1 = (reinterpret_cast(cptr))[-1]; if (U16_IS_LEAD(c1)) { - cptr -= WIDE_CHAR_SIZE; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + cptr -= WIDE_CHAR_SIZE; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) } } *pp = cptr; @@ -300,9 +305,8 @@ public: RegExpState *PeekRegExpState() const { ASSERT(stateStackLen_ >= 1); - return reinterpret_cast( - stateStack_ + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) - (stateStackLen_ - 1) * stateSize_); + return reinterpret_cast(stateStack_ + // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) + (stateStackLen_ - 1) * stateSize_); } void ReAllocStack(uint32_t stackLen); diff --git a/runtime/regexp/regexp_opcode.cpp b/runtime/regexp/regexp_opcode.cpp index f1c56839f..a25a6dbf5 100644 --- a/runtime/regexp/regexp_opcode.cpp +++ b/runtime/regexp/regexp_opcode.cpp @@ -20,43 +20,64 @@ namespace panda::ecmascript { using CaptureState = RegExpExecutor::CaptureState; -static SaveStartOpCode g_saveStartOpcode = SaveStartOpCode(); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) -static SaveEndOpCode g_saveEndOpcode = SaveEndOpCode(); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) -static CharOpCode g_charOpcode = CharOpCode(); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) -static GotoOpCode g_gotoOpcode = GotoOpCode(); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) -static SplitNextOpCode g_splitNextOpcode = SplitNextOpCode(); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) -static SplitFirstOpCode g_splitFirstOpcode = - SplitFirstOpCode(); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) -static MatchOpCode g_matchOpcode = MatchOpCode(); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) -static LoopOpCode g_loopOpcode = LoopOpCode(); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) -static LoopGreedyOpCode g_loopGreedyOpcode = - LoopGreedyOpCode(); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) -static PushCharOpCode g_pushCharOpcode = PushCharOpCode(); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) -static CheckCharOpCode g_checkCharOpcode = CheckCharOpCode(); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) -static PushOpCode g_pushOpcode = PushOpCode(); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) -static PopOpCode g_popOpcode = PopOpCode(); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) -static SaveResetOpCode g_saveResetOpcode = SaveResetOpCode(); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) -static LineStartOpCode g_lineStartOpcode = LineStartOpCode(); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) -static LineEndOpCode g_lineEndOpcode = LineEndOpCode(); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) -static WordBoundaryOpCode g_wordBoundaryOpcode = - WordBoundaryOpCode(); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) -static NotWordBoundaryOpCode g_notWordBoundaryOpcode = - NotWordBoundaryOpCode(); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) -static AllOpCode g_allOpcode = AllOpCode(); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) -static DotsOpCode g_dotsOpcode = DotsOpCode(); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) -static MatchAheadOpCode g_matchAheadOpcode = - MatchAheadOpCode(); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) -static NegativeMatchAheadOpCode g_negativeMatchAheadOpcode = - NegativeMatchAheadOpCode(); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) -static MatchEndOpCode g_matchEndOpcode = MatchEndOpCode(); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) -static PrevOpCode g_prevOpcode = PrevOpCode(); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) -static RangeOpCode g_rangeOpcode = RangeOpCode(); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) -static BackReferenceOpCode g_backreferenceOpcode = - BackReferenceOpCode(); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) -static BackwardBackReferenceOpCode g_backwardBackreferenceOpcode = - BackwardBackReferenceOpCode(); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) -static Char32OpCode g_char32Opcode = Char32OpCode(); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) -static Range32OpCode g_range32Opcode = Range32OpCode(); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +static SaveStartOpCode g_saveStartOpcode = SaveStartOpCode(); +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +static SaveEndOpCode g_saveEndOpcode = SaveEndOpCode(); +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +static CharOpCode g_charOpcode = CharOpCode(); +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +static GotoOpCode g_gotoOpcode = GotoOpCode(); +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +static SplitNextOpCode g_splitNextOpcode = SplitNextOpCode(); +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +static SplitFirstOpCode g_splitFirstOpcode = SplitFirstOpCode(); +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +static MatchOpCode g_matchOpcode = MatchOpCode(); +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +static LoopOpCode g_loopOpcode = LoopOpCode(); +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +static LoopGreedyOpCode g_loopGreedyOpcode = LoopGreedyOpCode(); +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +static PushCharOpCode g_pushCharOpcode = PushCharOpCode(); +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +static CheckCharOpCode g_checkCharOpcode = CheckCharOpCode(); +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +static PushOpCode g_pushOpcode = PushOpCode(); +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +static PopOpCode g_popOpcode = PopOpCode(); +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +static SaveResetOpCode g_saveResetOpcode = SaveResetOpCode(); +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +static LineStartOpCode g_lineStartOpcode = LineStartOpCode(); +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +static LineEndOpCode g_lineEndOpcode = LineEndOpCode(); +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +static WordBoundaryOpCode g_wordBoundaryOpcode = WordBoundaryOpCode(); +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +static NotWordBoundaryOpCode g_notWordBoundaryOpcode = NotWordBoundaryOpCode(); +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +static AllOpCode g_allOpcode = AllOpCode(); +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +static DotsOpCode g_dotsOpcode = DotsOpCode(); +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +static MatchAheadOpCode g_matchAheadOpcode = MatchAheadOpCode(); +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +static NegativeMatchAheadOpCode g_negativeMatchAheadOpcode = NegativeMatchAheadOpCode(); +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +static MatchEndOpCode g_matchEndOpcode = MatchEndOpCode(); +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +static PrevOpCode g_prevOpcode = PrevOpCode(); +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +static RangeOpCode g_rangeOpcode = RangeOpCode(); +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +static BackReferenceOpCode g_backreferenceOpcode = BackReferenceOpCode(); +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +static BackwardBackReferenceOpCode g_backwardBackreferenceOpcode = BackwardBackReferenceOpCode(); +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +static Char32OpCode g_char32Opcode = Char32OpCode(); +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +static Range32OpCode g_range32Opcode = Range32OpCode(); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) static std::vector g_intrinsicSet = { &g_saveStartOpcode, @@ -120,7 +141,7 @@ void RegExpOpCode::DumpRegExpOpCode(std::ostream &out, const DynChunk &buf) uint32_t SaveStartOpCode::EmitOpCode(DynChunk *buf, uint32_t para) const { - auto capture = static_cast(para & 0xffU); // NOLINTNEXTLINE(readability-magic-numbers) + auto capture = static_cast(para & 0xffU); // NOLINT(readability-magic-numbers) buf->EmitChar(GetOpCode()); buf->EmitChar(capture); return GetDynChunkfSize(*buf); @@ -135,7 +156,7 @@ uint32_t SaveStartOpCode::DumpOpCode(std::ostream &out, const DynChunk &buf, uin uint32_t SaveEndOpCode::EmitOpCode(DynChunk *buf, uint32_t para) const { - auto capture = static_cast(para & 0xffU); // NOLINTNEXTLINE(readability-magic-numbers) + auto capture = static_cast(para & 0xffU); // NOLINT(readability-magic-numbers) buf->EmitChar(GetOpCode()); buf->EmitChar(capture); return GetDynChunkfSize(*buf); @@ -150,7 +171,7 @@ uint32_t SaveEndOpCode::DumpOpCode(std::ostream &out, const DynChunk &buf, uint3 uint32_t CharOpCode::EmitOpCode(DynChunk *buf, uint32_t para) const { - auto paraChar = static_cast(para & 0xffffU); // NOLINTNEXTLINE(readability-magic-numbers) + auto paraChar = static_cast(para & 0xffffU); // NOLINT(readability-magic-numbers) buf->EmitChar(GetOpCode()); buf->EmitU16(paraChar); return GetDynChunkfSize(*buf); @@ -319,8 +340,8 @@ uint32_t CheckCharOpCode::DumpOpCode(std::ostream &out, const DynChunk &buf, uin uint32_t SaveResetOpCode::InsertOpCode(DynChunk *buf, uint32_t offset, uint32_t start, uint32_t end) const { - auto captureStart = static_cast(start & 0xffU); // NOLINTNEXTLINE(readability-magic-numbers) - auto captureEnd = static_cast(end & 0xffU); // NOLINTNEXTLINE(readability-magic-numbers) + auto captureStart = static_cast(start & 0xffU); // NOLINT(readability-magic-numbers) + auto captureEnd = static_cast(end & 0xffU); // NOLINT(readability-magic-numbers) buf->Insert(offset, GetSize()); buf->PutU8(offset, GetOpCode()); buf->PutU8(offset + RegExpOpCode::OP_SIZE_ONE, captureStart); @@ -540,7 +561,7 @@ uint32_t PrevOpCode::DumpOpCode(std::ostream &out, [[maybe_unused]] const DynChu uint32_t BackReferenceOpCode::EmitOpCode(DynChunk *buf, uint32_t para) const { - auto capture = static_cast(para & 0xffU); // NOLINTNEXTLINE(readability-magic-numbers) + auto capture = static_cast(para & 0xffU); // NOLINT(readability-magic-numbers) buf->EmitChar(GetOpCode()); buf->EmitChar(capture); return GetDynChunkfSize(*buf); @@ -555,7 +576,7 @@ uint32_t BackReferenceOpCode::DumpOpCode(std::ostream &out, const DynChunk &buf, uint32_t BackwardBackReferenceOpCode::EmitOpCode(DynChunk *buf, uint32_t para) const { - auto capture = static_cast(para & 0xffU); // NOLINTNEXTLINE(readability-magic-numbers) + auto capture = static_cast(para & 0xffU); // NOLINT(readability-magic-numbers) buf->EmitChar(GetOpCode()); buf->EmitChar(capture); return GetDynChunkfSize(*buf); diff --git a/runtime/regexp/regexp_opcode.h b/runtime/regexp/regexp_opcode.h index 198ed1ffe..6cf830d09 100644 --- a/runtime/regexp/regexp_opcode.h +++ b/runtime/regexp/regexp_opcode.h @@ -20,8 +20,7 @@ #include "plugins/ecmascript/runtime/regexp/dyn_chunk.h" -namespace panda { -namespace ecmascript { +namespace panda::ecmascript { class RegExpOpCode { public: enum : uint8_t { @@ -448,6 +447,5 @@ public: uint32_t DumpOpCode(std::ostream &out, const DynChunk &buf, uint32_t offset) const override; uint32_t InsertOpCode(DynChunk *buf, const RangeSet &rangeSet) const; }; -} // namespace ecmascript -} // namespace panda +} // namespace panda::ecmascript #endif diff --git a/runtime/regexp/regexp_parser.cpp b/runtime/regexp/regexp_parser.cpp index f09378b9f..e972e9b2a 100644 --- a/runtime/regexp/regexp_parser.cpp +++ b/runtime/regexp/regexp_parser.cpp @@ -25,45 +25,46 @@ #define _NO_DEBUG_ namespace panda::ecmascript { -static RangeSet g_rangeD(0x30, 0x39); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +// NOLINTNEXTLINE(fuchsia-statically-constructed-objects) +static RangeSet g_rangeD(0x30, 0x39); // NOLINT(readability-magic-numbers) // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) static RangeSet g_rangeS({ - std::pair(0x0009, 0x000D), // NOLINTNEXTLINE(readability-magic-numbers) - std::pair(0x0020, 0x0020), // NOLINTNEXTLINE(readability-magic-numbers) - std::pair(0x00A0, 0x00A0), // NOLINTNEXTLINE(readability-magic-numbers) - std::pair(0x1680, 0x1680), // NOLINTNEXTLINE(readability-magic-numbers) - std::pair(0x2000, 0x200A), // NOLINTNEXTLINE(readability-magic-numbers) + std::pair(0x0009, 0x000D), // NOLINT(readability-magic-numbers) + std::pair(0x0020, 0x0020), // NOLINT(readability-magic-numbers) + std::pair(0x00A0, 0x00A0), // NOLINT(readability-magic-numbers) + std::pair(0x1680, 0x1680), // NOLINT(readability-magic-numbers) + std::pair(0x2000, 0x200A), // NOLINT(readability-magic-numbers) /* 2028;LINE SEPARATOR;Zl;0;WS;;;;;N;;;;; */ /* 2029;PARAGRAPH SEPARATOR;Zp;0;B;;;;;N;;;;; */ - std::pair(0x2028, 0x2029), // NOLINTNEXTLINE(readability-magic-numbers) - std::pair(0x202F, 0x202F), // NOLINTNEXTLINE(readability-magic-numbers) - std::pair(0x205F, 0x205F), // NOLINTNEXTLINE(readability-magic-numbers) - std::pair(0x3000, 0x3000), // NOLINTNEXTLINE(readability-magic-numbers) + std::pair(0x2028, 0x2029), // NOLINT(readability-magic-numbers) + std::pair(0x202F, 0x202F), // NOLINT(readability-magic-numbers) + std::pair(0x205F, 0x205F), // NOLINT(readability-magic-numbers) + std::pair(0x3000, 0x3000), // NOLINT(readability-magic-numbers) /* FEFF;ZERO WIDTH NO-BREAK SPACE;Cf;0;BN;;;;;N;BYTE ORDER MARK;;;; */ - std::pair(0xFEFF, 0xFEFF), // NOLINTNEXTLINE(readability-magic-numbers) + std::pair(0xFEFF, 0xFEFF), // NOLINT(readability-magic-numbers) }); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) static RangeSet g_rangeW({ - std::pair(0x0030, 0x0039), // NOLINTNEXTLINE(readability-magic-numbers) - std::pair(0x0041, 0x005A), // NOLINTNEXTLINE(readability-magic-numbers) - std::pair(0x005F, 0x005F), // NOLINTNEXTLINE(readability-magic-numbers) - std::pair(0x0061, 0x007A), // NOLINTNEXTLINE(readability-magic-numbers) + std::pair(0x0030, 0x0039), // NOLINT(readability-magic-numbers) + std::pair(0x0041, 0x005A), // NOLINT(readability-magic-numbers) + std::pair(0x005F, 0x005F), // NOLINT(readability-magic-numbers) + std::pair(0x0061, 0x007A), // NOLINT(readability-magic-numbers) }); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) static RangeSet g_regexpIdentifyStart({ - std::pair(0x0024, 0x0024), // NOLINTNEXTLINE(readability-magic-numbers) - std::pair(0x0041, 0x005A), // NOLINTNEXTLINE(readability-magic-numbers) - std::pair(0x0061, 0x007A), // NOLINTNEXTLINE(readability-magic-numbers) + std::pair(0x0024, 0x0024), // NOLINT(readability-magic-numbers) + std::pair(0x0041, 0x005A), // NOLINT(readability-magic-numbers) + std::pair(0x0061, 0x007A), // NOLINT(readability-magic-numbers) }); // NOLINTNEXTLINE(fuchsia-statically-constructed-objects) static RangeSet g_regexpIdentifyContinue({ - std::pair(0x0024, 0x0024), // NOLINTNEXTLINE(readability-magic-numbers) - std::pair(0x0030, 0x0039), // NOLINTNEXTLINE(readability-magic-numbers) - std::pair(0x0041, 0x005A), // NOLINTNEXTLINE(readability-magic-numbers) - std::pair(0x0061, 0x007A), // NOLINTNEXTLINE(readability-magic-numbers) + std::pair(0x0024, 0x0024), // NOLINT(readability-magic-numbers) + std::pair(0x0030, 0x0039), // NOLINT(readability-magic-numbers) + std::pair(0x0041, 0x005A), // NOLINT(readability-magic-numbers) + std::pair(0x0061, 0x007A), // NOLINT(readability-magic-numbers) }); void RegExpParser::Parse() @@ -172,9 +173,9 @@ bool RegExpParser::ParseUnicodeEscape(uint32_t *value) // In the latter case, the number of hex digits between { } is arbitrary. // \ and u have already been read. if (c0_ == '{' && IsUtf16()) { - uint8_t *start = pc_ - 1; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + uint8_t *start = pc_ - 1; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) Advance(); - if (ParseUnlimitedLengthHexNumber(0x10FFFF, value)) { // NOLINTNEXTLINE(readability-magic-numbers) + if (ParseUnlimitedLengthHexNumber(0x10FFFF, value)) { // NOLINT(readability-magic-numbers) if (c0_ == '}') { Advance(); return true; @@ -188,12 +189,12 @@ bool RegExpParser::ParseUnicodeEscape(uint32_t *value) bool result = ParseHexEscape(UNICODE_HEX_VALUE, value); if (result && IsUtf16() && U16_IS_LEAD(*value) && c0_ == '\\') { // Attempt to read trail surrogate. - uint8_t *start = pc_ - 1; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + uint8_t *start = pc_ - 1; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) if (*pc_ == 'u') { Advance(UNICODE_HEX_ADVANCE); uint32_t trail; if (ParseHexEscape(UNICODE_HEX_VALUE, &trail) && U16_IS_TRAIL(trail)) { - *value = U16_GET_SUPPLEMENTARY((*value), (trail)); // NOLINTNEXTLINE(hicpp-signed-bitwise) + *value = U16_GET_SUPPLEMENTARY((*value), (trail)); // NOLINT(hicpp-signed-bitwise) return true; } } @@ -205,7 +206,7 @@ bool RegExpParser::ParseUnicodeEscape(uint32_t *value) bool RegExpParser::ParseHexEscape(int length, uint32_t *value) { - uint8_t *start = pc_ - 1; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + uint8_t *start = pc_ - 1; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) uint32_t val = 0; for (int i = 0; i < length; ++i) { uint32_t c = c0_; @@ -368,7 +369,7 @@ void RegExpParser::ParseAlternative(bool isBackward) ParseError("nothing to repeat"); return; case '{': { - uint8_t *begin = pc_ - 1; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + uint8_t *begin = pc_ - 1; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) int dummy; if (ParserIntervalQuantifier(&dummy, &dummy)) { ParseError("nothing to repeat"); @@ -402,9 +403,9 @@ void RegExpParser::ParseAlternative(bool isBackward) UChar32 c; int32_t length = end_ - pc_ + 1; // NOLINTNEXTLINE(hicpp-signed-bitwise) - U8_NEXT(pc_, i, length, c); // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + U8_NEXT(pc_, i, length, c); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) matchedChar = c; - pc_ += i; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + pc_ += i; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) } if (IsIgnoreCase()) { matchedChar = Canonicalize(matchedChar, IsUtf16()); @@ -431,10 +432,10 @@ void RegExpParser::ParseAlternative(bool isBackward) size_t termSize = end - atomBcStart; size_t moveSize = end - start; buffer_.Expand(end + termSize); - if (memmove_s(buffer_.buf_ + start + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) - termSize, // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + if (memmove_s(buffer_.buf_ + start + // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) + termSize, // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) moveSize, - buffer_.buf_ + start, // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + buffer_.buf_ + start, // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) moveSize) != EOK) { LOG_ECMA(FATAL) << "memmove_s failed"; UNREACHABLE(); @@ -461,7 +462,7 @@ int RegExpParser::FindGroupName(const CString &name) if (len == nameLen && memcmp(name.c_str(), p, nameLen) == 0) { return captureIndex; } - p += len + 1; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + p += len + 1; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) captureIndex++; } return -1; @@ -542,7 +543,7 @@ bool RegExpParser::ParseAssertionCapture(int *captureIndex, bool isBackward) // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) PrintF("group name %s", name.c_str()); Advance(); - goto parseCapture; // NOLINTNEXTLINE(cppcoreguidelines-avoid-goto) + goto parseCapture; // NOLINT(cppcoreguidelines-avoid-goto) } break; // (?:Disjunction[?U, ?N]) @@ -688,7 +689,7 @@ void RegExpParser::ParseQuantifier(size_t atomBcStart, int captureStart, int cap max = 1; break; case '{': { - uint8_t *start = pc_ - 1; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + uint8_t *start = pc_ - 1; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) if (!ParserIntervalQuantifier(&min, &max)) { pc_ = start; Advance(); // back to '{' @@ -772,9 +773,9 @@ bool RegExpParser::ParseGroupSpecifier(const uint8_t **pp, CString &name) } name += static_cast(c); } - c = *++p; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + c = *++p; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) } - p++; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + p++; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) *pp = p; return true; } @@ -784,10 +785,10 @@ int RegExpParser::ParseCaptureCount(const char *groupName) const uint8_t *p; int captureIndex = 1; CString name; - for (p = base_; p < end_; p++) { // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + for (p = base_; p < end_; p++) { // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) switch (*p) { case '(': { - if (p[1] == '?') { // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + if (p[1] == '?') { // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) if (p[CAPTURE_CONUT_ADVANCE - 1] == '<' && p[CAPTURE_CONUT_ADVANCE] != '!' && // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) @@ -808,14 +809,14 @@ int RegExpParser::ParseCaptureCount(const char *groupName) } } break; case '\\': - p++; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + p++; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) break; case '[': while (p < end_ && *p != ']') { if (*p == '\\') { - p++; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + p++; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) } - p++; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + p++; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) } break; default: @@ -970,11 +971,11 @@ int RegExpParser::ParseCharacterEscape() if ((c0_ >= 'A' && c0_ <= 'Z') || (c0_ >= 'a' && c0_ <= 'z')) { // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) PrintF("ControlLetter %c\n", c0_); - result = static_cast(c0_) & 0x1f; // NOLINTNEXTLINE(readability-magic-numbers) + result = static_cast(c0_) & 0x1fU; // NOLINT(readability-magic-numbers) Advance(); } else { if (!IsUtf16()) { - pc_--; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + pc_--; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) result = '\\'; } else { ParseError("Invalid control letter"); @@ -985,7 +986,7 @@ int RegExpParser::ParseCharacterEscape() case '0': // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) PrintF("CharacterEscape 0 [lookahead ∉ DecimalDigit]\n"); - if (IsUtf16() && !(*pc_ >= '0' && *pc_ <= '9')) { // NOLINTNEXTLINE(readability-magic-numbers) + if (IsUtf16() && !(*pc_ >= '0' && *pc_ <= '9')) { // NOLINT(readability-magic-numbers) Advance(); result = 0; break; @@ -1142,8 +1143,8 @@ uint32_t RegExpParser::ParseClassAtom(RangeSet *atom) default: uint32_t value = c0_; int u16_size = 0; - if (c0_ > INT8_MAX) { // NOLINTNEXTLINE(readability-magic-numbers) - pc_ -= 1; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + if (c0_ > INT8_MAX) { // NOLINT(readability-magic-numbers) + pc_ -= 1; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) auto u16_result = base::utf_helper::ConvertUtf8ToUtf16Pair(pc_, true); value = u16_result.first; u16_size = u16_result.second; diff --git a/runtime/regexp/regexp_parser.h b/runtime/regexp/regexp_parser.h index e83172f6c..6dc705be1 100644 --- a/runtime/regexp/regexp_parser.h +++ b/runtime/regexp/regexp_parser.h @@ -51,19 +51,7 @@ public: static constexpr uint32_t UNICODE_HEX_ADVANCE = 2; static constexpr uint32_t CAPTURE_CONUT_ADVANCE = 3; - explicit RegExpParser(Chunk *chunk) - : base_(nullptr), - pc_(nullptr), - end_(nullptr), - flags_(0), - c0_(KEY_EOF), - captureCount_(0), - stackCount_(0), - isError_(false), - buffer_(chunk), - groupNames_(chunk) - { - } + explicit RegExpParser(Chunk *chunk) : c0_(KEY_EOF), buffer_(chunk), groupNames_(chunk) {} ~RegExpParser() { @@ -217,15 +205,15 @@ private: } void PrintF(const char *fmt, ...); - uint8_t *base_; - uint8_t *pc_; - uint8_t *end_; - uint32_t flags_; + uint8_t *base_ {nullptr}; + uint8_t *pc_ {nullptr}; + uint8_t *end_ {nullptr}; + uint32_t flags_ {0}; int c0_; - int captureCount_; - int stackCount_; - bool isError_; - char errorMsg_[TMP_BUF_SIZE] = {0}; // NOLINTNEXTLINE(modernize-avoid-c-arrays) + int captureCount_ {0}; + int stackCount_ {0}; + bool isError_ {false}; + char errorMsg_[TMP_BUF_SIZE] = {0}; // NOLINT(modernize-avoid-c-arrays) DynChunk buffer_; DynChunk groupNames_; }; diff --git a/runtime/vmstat/caller_stat.h b/runtime/vmstat/caller_stat.h index 0771a690f..a8cd57359 100644 --- a/runtime/vmstat/caller_stat.h +++ b/runtime/vmstat/caller_stat.h @@ -18,7 +18,7 @@ #include #include -#include // NOLINTNEXTLINE(modernize-deprecated-headers) +#include #include "plugins/ecmascript/runtime/mem/c_string.h" #include "libpandabase/macros.h" diff --git a/tests/runtime/common/js_function_test.cpp b/tests/runtime/common/js_function_test.cpp index 1e76da4d5..94c2cadca 100644 --- a/tests/runtime/common/js_function_test.cpp +++ b/tests/runtime/common/js_function_test.cpp @@ -23,7 +23,6 @@ #include "plugins/ecmascript/runtime/js_function_extra_info.h" #include "plugins/ecmascript/runtime/tagged_array-inl.h" #include "plugins/ecmascript/runtime/js_handle.h" -#include "plugins/ecmascript/runtime/ecma_vm.h" #include "include/runtime.h" #include "plugins/ecmascript/runtime/object_factory.h" #include "plugins/ecmascript/runtime/global_env.h" diff --git a/tests/runtime/common/js_object_test.cpp b/tests/runtime/common/js_object_test.cpp index 6c4a85adf..ef3393357 100644 --- a/tests/runtime/common/js_object_test.cpp +++ b/tests/runtime/common/js_object_test.cpp @@ -14,11 +14,9 @@ #include "plugins/ecmascript/runtime/ecma_vm.h" #include "plugins/ecmascript/runtime/base/builtins_base.h" #include "plugins/ecmascript/runtime/ecma_runtime_call_info.h" -#include "plugins/ecmascript/runtime/base/builtins_base.h" #include "plugins/ecmascript/runtime/js_thread.h" #include "plugins/ecmascript/runtime/js_function.h" #include "plugins/ecmascript/runtime/global_env.h" -#include "plugins/ecmascript/runtime/js_thread.h" #include "plugins/ecmascript/runtime/tagged_dictionary.h" #include "plugins/ecmascript/runtime/weak_vector-inl.h" #include "plugins/ecmascript/runtime/ic/proto_change_details.h" diff --git a/tests/runtime/common/tagged_value_test.cpp b/tests/runtime/common/tagged_value_test.cpp index e7ec8fc26..cc658406d 100644 --- a/tests/runtime/common/tagged_value_test.cpp +++ b/tests/runtime/common/tagged_value_test.cpp @@ -25,7 +25,6 @@ #include "plugins/ecmascript/runtime/js_symbol.h" #include "plugins/ecmascript/runtime/js_thread.h" #include "include/runtime.h" -#include "plugins/ecmascript/runtime/object_factory.h" #include "plugins/ecmascript/runtime/ecma_vm.h" #include "plugins/ecmascript/runtime/global_env.h" #include "plugins/ecmascript/runtime/snapshot/mem/snapshot.h" -- Gitee