diff --git a/CMakeLists.txt b/CMakeLists.txt index 415d51bbf09d3d20e4d4c4f73ff516954332a7cd..e2ea6de6628ff16c1951505bb17bd434f8e50282 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 efc7767a6f911f39099c7b57447f89d4ba830bf9..0f9de45e05b515b027b5898006ef26019be37f4b 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 d25346190b7f1008aaa86b72214909fdd71d643e..0b9b7d21fbfa2b3733b89b0d914b4d54337a59e9 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 8b32a7701fc89aeb9faf85684e9b1a95c8ab39a3..ef014d704b95344657ecf1b382398158e3394a02 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 e033f8876f31e06c552357cb36a29655b5adbbd0..bf5a8f68299791d3c87aa320664ebbabfc987f77 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 b4928850dacc432ee6405e73363b0d2c8cfe5c9b..f96c1a62530e897a733a1aac9bc8e434f029f8fc 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 ca1b58efbfe6c56613a974fd6c4e0ba74889a307..17996eae41a2870cf4a8dd8775323dc263c9595e 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 d6b0677a86c0a9f72029ef70304febd7c3de1d80..4c13fee7f19bfb5f750ffd5e3808e9a9f38f8362 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 5252357fed32805573adcdcef143b9d71584b4b0..a74ea46e1fc87c6c7b55690e972704048d8b476a 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 8ef74a5138a35e51095646730bf7f4ea90a1d79c..b49a488bb86d9be63c40feed23114ae35a6734b0 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 d26c0a9b0c5a2a2fb10201203bcc4b638d1f3966..fe51b35443311ea983f49609b28289ea92e1ee9e 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 5d9d2a166641f077e3fee26b735b3268ce71cc83..ce7f9b88afe7d4ec91c642e7a0792ac02d1644b7 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 7c9373a14df34847bae5f2ce91405d172f5898f1..bcdb4a4dc27c4507f5fec89b0f2fa7f2e03fa5ca 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 49813b641cdcb361dab6a9730fa17895dd2b06e0..d7b719f7c2f76456305d271be40129690f4ef931 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 063d7e891df522b960bec043f091d11e7219ad82..2bc856c8397b0d910bb3131134922525c9799f1c 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 d2b329d8d621d9201a43801dc0df8d9d57e7043c..091820746a14fe5b72c76e2e2fc87600566c8ca8 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 2624283616028b9407c5586f998a8308e7a755fb..a438eb5855ff38abc307161d72bd1105d08bf1ce 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 a88561f0288ecc4e5a48551379da6e1e758c0348..957c31d27535dd71c83fb8518e1212b2648cd129 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 97cf93aa1f5ced86c4bf55984f32c62e2be24cdb..a0064164308d90c0c6e5d04cb195459ea47b9286 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 47a0be2264f3e7057e393c195569a6370394e076..33d4a5a9cf1136a712801dfa9f9a9811bd48471b 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 56ac39b4448803ea6c42eadf16d5f2403ab48ae5..d23dd1722ab6a853d3da6dd4369f1db81a626890 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 cc0a514256056d3df5608079a35c8b96f9ea47db..7d60ce1f971643c023e36e0718403e1a19b86b65 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 b499dc5900571e5264c2a4a8523bc93fdb657e73..99a12bf186a4ef037a76cfaf753e6e9800e665c2 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 12a7fa6d3a0d3463f174280abe29fd3a6fa5e2cb..1873c740bb22edbc7a81788cfde3b4ec315e447b 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 50abe274bc4a07dd9da6bd75160f9132294a2dd5..de1fc4c780cf42ee2ce2d156678f6940f03abadd 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 79d87e0739cae56f1f77de3013d0e637cf14aa49..9638311c83ec61489d2d885d22c365b60e4cd789 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 1f291ff7e749f569d9e54674a3c46d9f0c69864f..fb5ef74df3d62a7533261f2357c51fd910392212 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 62ffccbbe772ce18e2219cab41feb86472972d28..45eb23930cca4b685e5460fdb12da1bf78b37535 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 bf7071d7bdc69c9ad4e37f6c84cd490484eeb6aa..dfecd6292aa37c2afa0d1b1ec0e3e3dc77253a80 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 db033fd4fa07a015496588c1cafd64743c4c69b1..434451ca865a575e4df08959c8b34f1759f4aa23 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 69da46a4fb9157162fd2acfd9ffe9fe9830d1437..9ff36a147f1bdf6e047a477230cde1e0845e9452 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 1cd68e77bb0149ac267b7736993bb105dc5127ac..fa44094c2653b796f37a1589afcc3763adabb0c0 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 e1250ab2684d4ce5679d8791bd6ae2afd6f7e342..44a2a3fd978719df359da669641f504d0302e40c 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 ec0b6c1870cb91045277ecffc3023deaa769a5b9..2bbdd43fef93c6df9dc98853758f0766cf3d2f3f 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 eb830dc225419a533dd8e5a847af5d3295c65dc6..bcbcb6e453754a14f47f6cd339350165df566009 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 54054aff968fdab3d615f41bbcaebeccc1a2a769..90912ec9838a80bc30f072c3c1a2fe9e444b2b04 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 6160e68dca218cf74a8aa17187a065d73c08f331..59031fec9cc6fe8b9d09ce562f38fbb4f57fee67 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 b62eeb01692da46781b4c65ea12f3743f26282b9..f68542137549b125c2362851b4ca2e807fcfa07e 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 c1a0a91806cc3a5a3a13135096d4c841bb415353..fe956eeddc7e0ac2d346d7b8fef1e6447afee995 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 dcd232a0d1f371717aad8c87980963ad64ed85bf..2718197c4b26cbc754fbbcf0c7d7de62bc4cd106 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 03cdb1910ab8707c7da41ba1bcc78259d200faf2..1c127ff74bf6eec97ae7e77c3caca517b394335d 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 a912ece7d9542691df846a4c26fb7b6391178bd9..5dd04f6cea579cc334c2cc2ddf263aacd9ef6d78 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 7a28d3c34e85578e69e3e9f95bd917124ef1a886..69b78779b648e70e7cd56e6a7d9405093f3eda75 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 0646d45d66c46885dbff4b21a4690bec56d4e4b1..1da1a79152c88cba13e58ad0be9c768e7ecc9034 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 df698c84bc8166acfb1159c3804e30611f33de27..454a4edf222d343848ca039b1a0f0c00729309fb 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 1001c72b680d0f5a6b678e9a272076b7b3f405d5..292c0194895c51af2efb5f04c7979e70c665c24e 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 b21a20e9405d3664f9f3a54239e08078e4b1600e..bc5923343cf092de719542de6f8cdebb090cee7b 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 f1c56839fc8c5e741af6ecea084befd35d77f965..a25a6dbf538006bfdb568b77f6367303f040af96 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 198ed1ffee493a3eb6c856028d6a9d816f03048c..6cf830d096d6b676249cf30c8680daa8b149b934 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 f09378b9fb47f953302e9e05c6b109b76447377b..e972e9b2ae8b149cb80fc0c180403003c126af95 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 e83172f6c426c4569450dc02273ff96aef56425d..6dc705be1cbdfdd33f16d6a1bb14cf493bed0d70 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 0771a690febda0dcf2e8b0fab87883ce55f509be..a8cd57359750a1d82f6287cb8b983887124a9439 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 1e76da4d5ed9d9eaa50e2e758bd0552fbe584ba1..94c2cadca4a7c0c6f8abaa26df6739d442216b17 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 6c4a85adfed75498552336ba01340aff3113d690..ef339335762474c160e5b9b544934b97ca8d3cc5 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 e7ec8fc266776137e2b25d099b76d238d3e8686e..cc658406dda73b12ba616014e35cd247e6cd6118 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"