Suppress/fix warnings in libpandabase

Issue: https://gitee.com/openharmony/arkcompiler_runtime_core/issues/IAVTX5

Signed-off-by: Rokashevich Svetlana <rokashevich.svetlana1@huawei-partners.com>
This commit is contained in:
Rokashevich Svetlana 2024-10-08 14:28:31 +03:00
parent 13c815cb9d
commit d581a35caa
28 changed files with 778 additions and 599 deletions

View File

@ -11,49 +11,12 @@
"extras": "*",
"isa/CMakeLists.txt": {"bc-40001": "*"},
"ldscripts": "*",
"libpandabase/arch": "*",
"libpandabase/clang.h": "*",
"libpandabase/cmake": "*",
"libpandabase/concepts.h": "*",
"libpandabase/cpu_features.h": "*",
"libpandabase/events": "*",
"libpandabase/LibpandabasePostPlugins.cmake": "*",
"libpandabase/macros.h": "*",
"libpandabase/mem": "*",
"libpandabase/os/cpu_affinity.h": "*",
"libpandabase/os/debug_info.cpp": "*",
"libpandabase/os/debug_info.h": "*",
"libpandabase/os/dfx_option.cpp": "*",
"libpandabase/os/dfx_option.h": "*",
"libpandabase/os/error.h": "*",
"libpandabase/os/exec.h": "*",
"libpandabase/os/failure_retry.h": "*",
"libpandabase/os/file.h": "*",
"libpandabase/os/filesystem.cpp": "*",
"libpandabase/os/filesystem.h": "*",
"libpandabase/os/kill.h": "*",
"libpandabase/os/library_loader.h": "*",
"libpandabase/os/mutex.cpp": "*",
"libpandabase/os/mutex.h": "*",
"libpandabase/os/native_stack.cpp": "*",
"libpandabase/os/native_stack.h": "*",
"libpandabase/os/pipe.h": "*",
"libpandabase/os/property.cpp": "*",
"libpandabase/os/property.h": "*",
"libpandabase/os/sighook.h": "*",
"libpandabase/os/stacktrace.cpp": "*",
"libpandabase/os/stacktrace.h": "*",
"libpandabase/os/stacktrace_stub.cpp": "*",
"libpandabase/os/system_environment.h": "*",
"libpandabase/os/thread.h": "*",
"libpandabase/os/time.cpp": "*",
"libpandabase/os/time.h": "*",
"libpandabase/os/unique_fd.h": "*",
"libpandabase/serializer": "*",
"libpandabase/templates": "*",
"libpandabase/tests": "*",
"libpandabase/trace": "*",
"libpandabase/utils": "*",
"libpandabase/tests/bit_memory_region_test.cpp": "*",
"libpandabase/tests/mmap_mem_pool_test.cpp": "*",
"libpandabase/tests/genmc": "*",
"libpandabase/tests/taskmanager/task_scheduler_test.cpp": "*",
"libpandabase/tests/taskmanager/task_test.cpp": "*",
"models": "*",
"pandastdlib": "*",
"patches": "*",

View File

@ -16,7 +16,8 @@
#include "cpu_features.h"
namespace ark::compiler {
#if defined PANDA_TARGET_MOBILE || defined PANDA_TARGET_OHOS || defined PANDA_TARGET_LINUX || defined PANDA_TARGET_UNIX
#if defined(PANDA_TARGET_MOBILE) || defined(PANDA_TARGET_OHOS) || defined(PANDA_TARGET_LINUX) || \
defined(PANDA_TARGET_UNIX)
#include <asm/hwcap.h>
#include <sys/auxv.h>

View File

@ -22,7 +22,7 @@
// The attributes can be safely erased when compiling with other compilers.
#if defined(__clang__) && (!defined(SWIG))
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x))
#define THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x)) // CC-OFF(G.NAM.01) public API
#else
#define THREAD_ANNOTATION_ATTRIBUTE__(x) // no-op
#endif

View File

@ -13,6 +13,7 @@
option(ENABLE_LIBPANDABASE_COVERAGE "Enable coverage-calculation for libpandabase" false)
# CC-OFFNXT(bc-40028) false positive
include(${PANDA_ROOT}/cmake/toolchain/coverage/unit_tests_lcov.cmake)
add_custom_target(libpandabase_coverage DEPENDS arkbase_tests arkbase_mem_range_tests)

View File

@ -140,6 +140,7 @@
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define ASSERT_FAIL(expr) ark::debug::AssertionFail(expr, __FILE__, __LINE__, __FUNCTION__)
// CC-OFFNXT(G.PRE.06) solid logic
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define ASSERT_OP(lhs, op, rhs) \
do { \
@ -185,6 +186,7 @@
#define ASSERT_PRINT(cond, message) \
do { \
if (auto cond_val = cond; UNLIKELY(!(cond_val))) { \
/* CC-OFFNXT(G.PRE.02) string arg */ \
std::cerr << message << std::endl; \
ASSERT_FAIL(#cond); \
} \

View File

@ -21,9 +21,11 @@ namespace ark::os::dfx_option {
bool DfxOptionHandler::IsInOptionList(const std::string &s)
{
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define D(e, v, str) \
if (s == (str)) { \
return true; \
#define D(e, v, str) \
/* CC-OFFNXT(G.PRE.10) function scope macro */ \
if (s == (str)) { \
/* CC-OFFNXT(G.PRE.05) function gen */ \
return true; \
}
DFX_OPTION_LIST(D)
#undef D
@ -34,9 +36,11 @@ bool DfxOptionHandler::IsInOptionList(const std::string &s)
DfxOptionHandler::DfxOption DfxOptionHandler::DfxOptionFromString(const std::string &s)
{
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define D(e, v, str) \
if (s == (str)) { \
return DfxOptionHandler::DfxOption::e; \
#define D(e, v, str) \
/* CC-OFFNXT(G.PRE.10) function scope macro */ \
if (s == (str)) { \
/* CC-OFFNXT(G.PRE.05) function gen */ \
return DfxOptionHandler::DfxOption::e; \
}
DFX_OPTION_LIST(D)
#undef D
@ -48,7 +52,9 @@ std::string DfxOptionHandler::StringFromDfxOption(DfxOptionHandler::DfxOption df
{
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define D(e, v, str) \
/* CC-OFFNXT(G.PRE.10) function scope macro */ \
if (dfxOption == DfxOptionHandler::DfxOption::e) { \
/* CC-OFFNXT(G.PRE.05) function gen */ \
return (str); \
}
DFX_OPTION_LIST(D)

View File

@ -27,6 +27,7 @@ namespace ark::os::dfx_option {
#define DFX_OPTION_ELEM(D, NAME, STR) D(NAME, DfxOptionHandler::DfxOptionId::NAME##_ID, STR)
#ifdef PANDA_TARGET_UNIX
// CC-OFFNXT(G.PRE.06) solid logic
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define DFX_OPTION_LIST(D) \
DFX_OPTION_ELEM(D, COMPILER_NULLCHECK, "compiler-nullcheck") \

View File

@ -31,6 +31,7 @@ struct StructToTupleImpl;
auto operator()(Struct &&str) const \
{ \
auto [__VA_ARGS__] = std::forward<Struct>(str); \
/* CC-OFFNXT(G.PRE.05) function gen */ \
return std::make_tuple(__VA_ARGS__); \
} \
}

View File

@ -29,7 +29,7 @@ constexpr const int DEFAULT_LIST_CAPACITY = 1000;
struct TestNode : public ListNode {
TestNode() = default;
// NOLINTNEXTLINE(google-explicit-constructor)
TestNode(int v) : value(v) {}
TestNode(int v) : value(v) {} // CC-OFF(G.CLS.03) class for testing
// NOLINTNEXTLINE(misc-non-private-member-variables-in-classes)
int value {0U};
};

View File

@ -25,7 +25,8 @@ TEST(Mem, GetNativeBytesFromMallinfoTest)
{
#if (!defined(PANDA_ASAN_ON)) && (!defined(PANDA_TSAN_ON)) && (defined(__GLIBC__) || defined(PANDA_TARGET_MOBILE))
size_t oldBytes = ark::os::mem::GetNativeBytesFromMallinfo();
// NOLINTBEGIN(readability-magic-numbers,cppcoreguidelines-no-malloc,clang-analyzer-unix.Malloc,modernize-loop-convert)
// NOLINTBEGIN(readability-magic-numbers,cppcoreguidelines-no-malloc,clang-analyzer-unix.Malloc,
// modernize-loop-convert)
// NOLINTNEXTLINE(modernize-avoid-c-arrays)
void *p1[1000U];
for (size_t i = 0; i < 1000U; i++) {
@ -58,7 +59,8 @@ TEST(Mem, GetNativeBytesFromMallinfoTest)
free(p2[i]);
p2[i] = nullptr;
}
// NOLINTEND(readability-magic-numbers,cppcoreguidelines-no-malloc,clang-analyzer-unix.Malloc,modernize-loop-convert)
// NOLINTEND(readability-magic-numbers,cppcoreguidelines-no-malloc,clang-analyzer-unix.Malloc,
// modernize-loop-convert)
newBytes = ark::os::mem::GetNativeBytesFromMallinfo();
ASSERT_TRUE(newBytes < oldBytes);
#else

File diff suppressed because it is too large Load Diff

View File

@ -32,6 +32,7 @@ namespace ark {
D(X86_64)
enum class Arch {
// CC-OFFNXT(G.PRE.02) part name
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define DEF(v) v,
ARCH_LIST(DEF)
@ -157,21 +158,27 @@ struct ArchTraits<Arch::NONE> {
using WordType = void;
};
// CC-OFFNXT(G.PRE.06) solid logic
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage,-warnings-as-errors)
#define DEF_ARCH_PROPERTY_GETTER(func_name, property) \
/* CC-OFFNXT(G.PRE.02) namespace member */ \
constexpr std::remove_const_t<decltype(ArchTraits<Arch::AARCH64>::property)> func_name(Arch arch) \
{ \
ASSERT(arch != Arch::NONE); \
if (arch == Arch::X86) { \
/* CC-OFFNXT(G.PRE.02, G.PRE.05) namespace member, function gen */ \
return ArchTraits<Arch::X86>::property; \
} \
if (arch == Arch::X86_64) { \
/* CC-OFFNXT(G.PRE.02, G.PRE.05) namespace member, function gen */ \
return ArchTraits<Arch::X86_64>::property; \
} \
if (arch == Arch::AARCH32) { \
/* CC-OFFNXT(G.PRE.02, G.PRE.05) namespace member, function gen */ \
return ArchTraits<Arch::AARCH32>::property; \
} \
if (arch == Arch::AARCH64) { \
/* CC-OFFNXT(G.PRE.02, G.PRE.05) namespace member, function gen */ \
return ArchTraits<Arch::AARCH64>::property; \
} \
UNREACHABLE(); \
@ -195,9 +202,10 @@ constexpr const char *GetArchString(Arch arch)
{
switch (arch) {
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define DEF(v) \
case Arch::v: \
return #v;
#define DEF(v) \
/* CC-OFFNXT(G.PRE.02) namespace name */ \
case Arch::v: \
return #v; // CC-OFF(G.PRE.05, G.PRE.09) code generation
ARCH_LIST(DEF)
#undef DEF
default:

View File

@ -30,9 +30,11 @@
#if defined(PANDA_ASAN_ON)
extern "C" {
// Marks memory region [addr, addr+size) as unaddressable.
// CC-OFFNXT(G.DCL.01) public API
// NOLINTNEXTLINE(readability-identifier-naming, readability-redundant-declaration)
void __asan_poison_memory_region(void const volatile *addr, size_t size) __attribute__((visibility("default")));
// Marks memory region [addr, addr+size) as addressable.
// CC-OFFNXT(G.DCL.01) public API
// NOLINTNEXTLINE(readability-identifier-naming, readability-redundant-declaration)
void __asan_unpoison_memory_region(void const volatile *addr, size_t size) __attribute__((visibility("default")));
}

View File

@ -276,6 +276,7 @@ struct BitTableDefault : public BitTableRow<NUM_COLUMNS, BitTableDefault<NUM_COL
struct ColumnName; \
static constexpr const char *TABLE_NAME = #name
// CC-OFFNXT(G.PRE.06) solid logic
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define BIT_TABLE_COLUMN(index, name, upname) \
static constexpr size_t COLUMN_##upname = (index); \
@ -286,10 +287,12 @@ struct BitTableDefault : public BitTableRow<NUM_COLUMNS, BitTableDefault<NUM_COL
}; \
uint32_t Get##name() const \
{ \
/* CC-OFFNXT(G.PRE.05) function gen */ \
return Get(index); \
} \
bool Has##name() const \
{ \
/* CC-OFFNXT(G.PRE.05) function gen */ \
return Get(index) != NO_VALUE; \
}

View File

@ -29,17 +29,17 @@
#include <securec.h>
#define panda_bit_utils_ctz __builtin_ctz // NOLINT(cppcoreguidelines-macro-usage)
#define panda_bit_utils_ctzll __builtin_ctzll // NOLINT(cppcoreguidelines-macro-usage)
#define PANDA_BIT_UTILS_CTZ __builtin_ctz // NOLINT(cppcoreguidelines-macro-usage)
#define PANDA_BIT_UTILS_CTZLL __builtin_ctzll // NOLINT(cppcoreguidelines-macro-usage)
#define panda_bit_utils_clz __builtin_clz // NOLINT(cppcoreguidelines-macro-usage)
#define panda_bit_utils_clzll __builtin_clzll // NOLINT(cppcoreguidelines-macro-usage)
#define PANDA_BIT_UTILS_CLZ __builtin_clz // NOLINT(cppcoreguidelines-macro-usage)
#define PANDA_BIT_UTILS_CLZLL __builtin_clzll // NOLINT(cppcoreguidelines-macro-usage)
#define panda_bit_utils_ffs __builtin_ffs // NOLINT(cppcoreguidelines-macro-usage)
#define panda_bit_utils_ffsll __builtin_ffsll // NOLINT(cppcoreguidelines-macro-usage)
#define PANDA_BIT_UTILS_FFS __builtin_ffs // NOLINT(cppcoreguidelines-macro-usage)
#define PANDA_BIT_UTILS_FFSLL __builtin_ffsll // NOLINT(cppcoreguidelines-macro-usage)
#define panda_bit_utils_popcount __builtin_popcount // NOLINT(cppcoreguidelines-macro-usage)
#define panda_bit_utils_popcountll __builtin_popcountll // NOLINT(cppcoreguidelines-macro-usage)
#define PANDA_BIT_UTILS_POPCOUNT __builtin_popcount // NOLINT(cppcoreguidelines-macro-usage)
#define PANDA_BIT_UTILS_POPCOUNTLL __builtin_popcountll // NOLINT(cppcoreguidelines-macro-usage)
namespace ark {
@ -54,9 +54,9 @@ constexpr int Clz(T x)
ASSERT(x != 0U);
if (sizeof(T) == sizeof(uint64_t)) {
return panda_bit_utils_clzll(x);
return PANDA_BIT_UTILS_CLZLL(x);
}
return panda_bit_utils_clz(x) - (std::numeric_limits<uint32_t>::digits - std::numeric_limits<T>::digits);
return PANDA_BIT_UTILS_CLZ(x) - (std::numeric_limits<uint32_t>::digits - std::numeric_limits<T>::digits);
}
template <typename T>
@ -70,9 +70,9 @@ constexpr int Ctz(T x)
ASSERT(x != 0U);
if (sizeof(T) == sizeof(uint64_t)) {
return panda_bit_utils_ctzll(x);
return PANDA_BIT_UTILS_CTZLL(x);
}
return panda_bit_utils_ctz(x);
return PANDA_BIT_UTILS_CTZ(x);
}
template <typename T>
@ -85,9 +85,9 @@ constexpr int Popcount(T x)
static_assert(sizeof(T) == sizeof(uint64_t) || sizeof(T) <= sizeof(uint32_t), "Unsupported sizeof(T)");
if (sizeof(T) == sizeof(uint64_t)) {
return panda_bit_utils_popcountll(x);
return PANDA_BIT_UTILS_POPCOUNTLL(x);
}
return panda_bit_utils_popcount(x);
return PANDA_BIT_UTILS_POPCOUNT(x);
}
// How many bits (minimally) does it take to store the constant 'value'? i.e. 1 for 1, 2 for 2 and 3, 3 for 4 and 5 etc.
@ -124,9 +124,9 @@ constexpr int Ffs(T x)
static_assert(sizeof(T) == sizeof(uint64_t) || sizeof(T) <= sizeof(uint32_t), "Unsupported sizeof(T)");
if (sizeof(T) == sizeof(uint64_t)) {
return panda_bit_utils_ffsll(x);
return PANDA_BIT_UTILS_FFSLL(x);
}
return panda_bit_utils_ffs(x);
return PANDA_BIT_UTILS_FFS(x);
}
template <size_t N, typename T>

View File

@ -96,11 +96,12 @@ uint32_t PseudoFnvHashItem(Item item, uint32_t seed = FNV_INITIAL_SEED)
}
/// Works like FNV hash but operates over 4-byte words at a time instead of single bytes
// CC-OFFNXT(G.FUD.06) perf critical
inline uint32_t PseudoFnvHashString(const uint8_t *str, uint32_t hash = FNV_INITIAL_SEED)
{
while (true) {
// NOLINTNEXTLINE(readability-implicit-bool-conversion, cppcoreguidelines-pro-bounds-pointer-arithmetic)
if (!str[0] || !str[1] || !str[2] || !str[3]) {
if (!str[0U] || !str[1U] || !str[2U] || !str[3U]) {
break;
}
constexpr uint32_t BYTE = 8U;

View File

@ -248,6 +248,16 @@ bool JsonObject::Parser::GetBool()
return true;
}
void JsonObject::Parser::SaveSourceString(std::streampos posStart)
{
auto posEnd = istream_.tellg();
auto size = static_cast<size_t>(posEnd - posStart);
stringTemp_.resize(size, '\0');
istream_.seekg(posStart);
istream_.read(&stringTemp_[0], static_cast<std::streamsize>(size));
ASSERT(istream_);
}
bool JsonObject::Parser::GetValue()
{
auto symbol = PeekSymbol();
@ -299,12 +309,7 @@ bool JsonObject::Parser::GetValue()
}
// Save source string of parsed value:
auto posEnd = istream_.tellg();
auto size = static_cast<size_t>(posEnd - posStart);
stringTemp_.resize(size, '\0');
istream_.seekg(posStart);
istream_.read(&stringTemp_[0], static_cast<std::streamsize>(size));
ASSERT(istream_);
SaveSourceString(posStart);
return res;
}

View File

@ -93,6 +93,7 @@ public:
bool Parse();
bool GetJsonObject(JsonObject *emptyObj);
void SaveSourceString(std::streampos posStart);
bool GetValue();
bool GetNull();
bool GetString(char delim);

View File

@ -30,6 +30,7 @@ constexpr size_t EXTENSION_BIT = 0x80;
constexpr size_t SIGN_BIT = 0x40;
template <class T>
// CC-OFFNXT(G.FUD.06) perf critical
inline std::tuple<T, size_t, bool> DecodeUnsigned(const uint8_t *data)
{
static_assert(std::is_unsigned_v<T>, "T must be unsigned");
@ -56,6 +57,7 @@ inline std::tuple<T, size_t, bool> DecodeUnsigned(const uint8_t *data)
}
template <>
// CC-OFFNXT(G.FUD.06) perf critical
inline std::tuple<uint32_t, size_t, bool> DecodeUnsigned<uint32_t>(const uint8_t *data)
{
constexpr size_t LEB128_BYTE2_SHIFT = 7U;
@ -97,6 +99,7 @@ inline std::tuple<uint32_t, size_t, bool> DecodeUnsigned<uint32_t>(const uint8_t
}
template <class T>
// CC-OFFNXT(G.FUD.06) perf critical
inline std::tuple<T, size_t, bool> DecodeSigned(const uint8_t *data)
{
static_assert(std::is_signed_v<T>, "T must be signed");
@ -153,6 +156,7 @@ inline size_t EncodeUnsigned(T data, uint8_t *out)
}
template <class T>
// CC-OFFNXT(G.FUD.06) perf critical
inline size_t EncodeSigned(T data, uint8_t *out)
{
static_assert(std::is_signed_v<T>, "T must be signed");

View File

@ -135,7 +135,7 @@ Logger::Message::~Message()
std::cerr << "FATAL ERROR" << std::endl;
std::cerr << "Backtrace [tid=" << os::thread::GetCurrentThreadId() << "]:\n";
PrintStack(std::cerr);
std::abort();
std::abort(); // CC-OFF(G.STD.16) fatal error
}
}

View File

@ -189,7 +189,7 @@ public:
}
if (level == Level::FATAL) {
std::abort();
std::abort(); // CC-OFF(G.FUU.08) fatal error
}
return false;
@ -452,36 +452,45 @@ private:
#ifndef NDEBUG
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define _LOG_SUPPRESSION_CHECK(level, component) \
#define LOG_SUPPRESSION_CHECK(level, component) \
/* CC-OFFNXT(G.PRE.02) namespace member */ \
!ark::Logger::IsMessageSuppressed(ark::Logger::Level::level, ark::Logger::Component::component)
#else
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define _LOG_SUPPRESSION_CHECK(level, component) true
#define LOG_SUPPRESSION_CHECK(level, component) true
#endif
// Explicit namespace is specified to allow using the logger out of panda namespace.
// For example, in the main function.
// clang-format off
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define _LOG(level, component, p) \
#define IMPL_LOG(level, component, p) \
/* CC-OFFNXT(G.PRE.02) namespace member */ \
ark::Logger::IsLoggingOnOrAbort(ark::Logger::Level::level, ark::Logger::Component::component) && \
_LOG_SUPPRESSION_CHECK(level, component) && \
LOG_SUPPRESSION_CHECK(level, component) && \
/* CC-OFFNXT(G.PRE.02) namespace member */ \
ark::Logger::Message(ark::Logger::Level::level, ark::Logger::Component::component, p).GetStream()
// clang-format on
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define LOG(level, component) _LOG_##level(component, false)
#define LOG(level, component) LOG_##level(component, false)
// clang-format off
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define LOG_DFX(dfx_component) \
ark::Logger::IsLoggingDfxOn() && \
ark::Logger::Message(ark::Logger::Level::ERROR, ark::Logger::DFX, false).GetStream() \
/* CC-OFFNXT(G.PRE.02) namespace member */ \
<< ark::Logger::StringfromDfxComponent(ark::Logger::LogDfxComponent::dfx_component) << " log:"
// clang-format on
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define GET_LOG_STREAM(level, component) \
#define GET_LOG_STREAM(level, component) \
/* CC-OFFNXT(G.PRE.02) namespace member */ \
ark::Logger::Message(ark::Logger::Level::level, ark::Logger::Component::component, false).GetStream()
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define PLOG(level, component) _LOG_##level(component, true)
#define PLOG(level, component) LOG_##level(component, true)
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define LOG_IF(cond, level, component) (cond) && LOG(level, component)
@ -492,26 +501,26 @@ private:
#ifndef NDEBUG
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define _LOG_DEBUG(component, p) _LOG(DEBUG, component, p)
#define LOG_DEBUG(component, p) IMPL_LOG(DEBUG, component, p)
#else
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define _LOG_DEBUG(component, p) false && ark::DummyStream()
#define LOG_DEBUG(component, p) false && ark::DummyStream()
#endif
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define _LOG_INFO(component, p) _LOG(INFO, component, p)
#define LOG_INFO(component, p) IMPL_LOG(INFO, component, p)
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define _LOG_WARNING(component, p) _LOG(WARNING, component, p)
#define LOG_WARNING(component, p) IMPL_LOG(WARNING, component, p)
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define _LOG_ERROR(component, p) _LOG(ERROR, component, p)
#define LOG_ERROR(component, p) IMPL_LOG(ERROR, component, p)
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define _LOG_FATAL(component, p) _LOG(FATAL, component, p)
#define LOG_FATAL(component, p) IMPL_LOG(FATAL, component, p)
} // namespace ark

View File

@ -33,7 +33,7 @@ namespace ark::helpers::math {
constexpr uint32_t GetIntLog2(const uint32_t x)
{
ASSERT((x > 0) && !(x & (x - 1U)));
return static_cast<uint32_t>(panda_bit_utils_ctz(x));
return static_cast<uint32_t>(PANDA_BIT_UTILS_CTZ(x));
}
/**
@ -44,7 +44,7 @@ constexpr uint32_t GetIntLog2(const uint32_t x)
constexpr uint64_t GetIntLog2(const uint64_t x)
{
ASSERT((x > 0) && !(x & (x - 1U)));
return static_cast<uint64_t>(panda_bit_utils_ctzll(x));
return static_cast<uint64_t>(PANDA_BIT_UTILS_CTZLL(x));
}
template <typename T>

View File

@ -87,6 +87,7 @@ private:
template <typename T,
enable_if_t<is_same_v<std::string, T> || is_same_v<double, T> || is_same_v<bool, T> || is_same_v<int, T> ||
// CC-OFFNXT(G.FMT.10) project code style
is_same_v<uint32_t, T> || is_same_v<uint64_t, T> || is_same_v<arg_list_t, T>> * = nullptr>
class PandArg : public PandArgBase {
public:
@ -1017,6 +1018,7 @@ private:
}
template <typename T,
// CC-OFFNXT(G.FMT.10) project code style
enable_if_t<is_same_v<T, int> || is_same_v<T, uint32_t> || is_same_v<T, uint64_t>> * = nullptr>
bool IsIntegerArgInRange(PandArg<T> *arg, T num)
{

View File

@ -30,6 +30,7 @@
namespace ark::helpers::string {
// CC-OFFNXT(G.FUD.06) perf critical
inline std::string Vformat(const char *fmt, va_list args)
{
static constexpr size_t SIZE = 1024;

View File

@ -36,6 +36,7 @@ constexpr auto ToUnsigned(T v)
return static_cast<UnsignedType>(v);
}
// CC-OFFNXT(G.FMT.10) project code style
template <typename T, std::enable_if_t<std::is_enum_v<T>> * = nullptr>
constexpr auto ToUnderlying(T value)
{

View File

@ -327,13 +327,12 @@ bool IsValidModifiedUTF8(const uint8_t *elems)
case 0xf0: // NOLINT(readability-magic-numbers)
// pattern 1111 0xxx starts four byte section
if ((*elems & 0x08) == 0) { // NOLINT(hicpp-signed-bitwise)
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
++elems;
if ((*elems & 0xc0) != 0x80) { // NOLINT(hicpp-signed-bitwise, readability-magic-numbers)
return false;
}
} else {
if ((*elems & 0x08) != 0) { // NOLINT(hicpp-signed-bitwise)
return false;
}
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
++elems;
if ((*elems & 0xc0) != 0x80) { // NOLINT(hicpp-signed-bitwise, readability-magic-numbers)
return false;
}
// no need break
@ -502,6 +501,7 @@ size_t Utf16ToMUtf8Size(const uint16_t *mutf16, uint32_t length)
return Utf16ToUtf8Size(mutf16, length, true);
}
// CC-OFFNXT(G.FUN.01) solid logic
size_t ConvertRegionUtf16ToUtf8(const uint16_t *utf16In, uint8_t *utf8Out, size_t utf16Len, size_t utf8Len,
size_t start, bool modify)
{

View File

@ -192,7 +192,7 @@ struct Mutf8Less {
}
};
static inline std::pair<uint16_t, uint16_t> SplitUtf16Pair(uint32_t pair)
inline std::pair<uint16_t, uint16_t> SplitUtf16Pair(uint32_t pair)
{
constexpr size_t P1_MASK = 0xffff;
constexpr size_t P2_SHIFT = 16;

View File

@ -44,6 +44,7 @@ constexpr double operator""_D(long double v)
// Returns the value (0 .. 15) of a hexadecimal character c.
// If c is not a legal hexadecimal character, returns a value < 0.
// CC-OFFNXT(G.FUD.06) solid logic
inline uint32_t HexValue(uint32_t c)
{
constexpr uint32_t BASE16 = 16;