add support of clang 14.0.3

This commit is contained in:
InoriRus
2022-05-25 20:07:51 +10:00
parent 6129b6ecac
commit adda20a6fe
53 changed files with 681 additions and 210 deletions
+2 -2
View File
@@ -1235,7 +1235,7 @@ ByteBuffer ZipReader::ExtractFile(int file_index)
if (file_index < 0 || IsFileDirectory(file_index))
{
return ByteBuffer();
return {};
}
ZipFileStat s {};
@@ -1243,7 +1243,7 @@ ByteBuffer ZipReader::ExtractFile(int file_index)
if (s.m_uncomp_size == 0)
{
return ByteBuffer();
return {};
}
void* ptr = mz_zip_reader_extract_to_heap(&m_p->zip, file_index, &size, 0);
+4 -4
View File
@@ -28,7 +28,7 @@ using Math::Rand;
struct StatementPrivate
{
explicit StatementPrivate(ConnectionPrivate* p): p_stmt(nullptr), m_p(p), text(nullptr) {}
explicit StatementPrivate(ConnectionPrivate* p): m_p(p) {}
void Prepare(const char* sql_text);
[[nodiscard]] Statement::State Step() const;
@@ -46,9 +46,9 @@ struct StatementPrivate
void DbgTest() const;
sqlite3_stmt* p_stmt;
ConnectionPrivate* m_p;
const char* text;
sqlite3_stmt* p_stmt = nullptr;
ConnectionPrivate* m_p = nullptr;
const char* text = nullptr;
};
struct ConnectionPrivate
+15 -12
View File
@@ -389,7 +389,7 @@ Date Date::FromMacros(const String& date)
if (lst.Size() != 3)
{
return Date();
return {};
}
static const char* month_str[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
@@ -406,7 +406,7 @@ Date Date::FromMacros(const String& date)
if (month < 0)
{
return Date();
return {};
}
return Date(lst.At(2).ToInt32(), month, lst.At(1).ToInt32());
@@ -673,7 +673,7 @@ Time Time::operator+(int secs) const
if (IsInvalid())
{
return Time();
return {};
}
int r = m_ms + ms_secs;
@@ -698,7 +698,7 @@ Time Time::operator-(int secs) const
if (IsInvalid())
{
return Time();
return {};
}
int r = m_ms - ms_secs;
@@ -768,7 +768,7 @@ DateTime DateTime::FromSystem()
if (t.is_invalid)
{
return DateTime();
return {};
}
return DateTime(Date(t.Year, t.Month, t.Day), Time(t.Hour, t.Minute, t.Second, t.Milliseconds));
@@ -781,7 +781,7 @@ DateTime DateTime::FromSystemUTC()
if (t.is_invalid)
{
return DateTime();
return {};
}
return DateTime(Date(t.Year, t.Month, t.Day), Time(t.Hour, t.Minute, t.Second, t.Milliseconds));
@@ -848,26 +848,29 @@ uint64_t DateTime::DistanceMs(const DateTime& other) const
jd_t j1 = other.m_date.JulianDay();
jd_t j2 = m_date.JulianDay();
return int64_t(j2 - j1 - 1) * int64_t(TIME_MS_IN_DAY) + (int64_t(TIME_MS_IN_DAY) - int64_t(other.m_time.MsecTotal())) +
int64_t(m_time.MsecTotal());
return static_cast<int64_t>(j2 - j1 - 1) * static_cast<int64_t>(TIME_MS_IN_DAY) +
(static_cast<int64_t>(TIME_MS_IN_DAY) - static_cast<int64_t>(other.m_time.MsecTotal())) +
static_cast<int64_t>(m_time.MsecTotal());
}
DateTime DateTime::FromSQLiteJulian(double jd)
{
double i = NAN;
double f = modf(jd + 0.5, &i);
return DateTime(Date(jd_t(i)), Time(int(f * double(TIME_MS_IN_DAY))));
return DateTime(Date(static_cast<jd_t>(i)), Time(static_cast<int>(f * static_cast<double>(TIME_MS_IN_DAY))));
}
double DateTime::ToSQLiteJulian() const
{
return -0.5 + double(GetDate().JulianDay()) + double(GetTime().MsecTotal()) / double(TIME_MS_IN_DAY);
return -0.5 + static_cast<double>(GetDate().JulianDay()) +
static_cast<double>(GetTime().MsecTotal()) / static_cast<double>(TIME_MS_IN_DAY);
}
int64_t DateTime::ToSQLiteJulianInt64() const
{
return -(static_cast<int64_t>(TIME_MS_IN_DAY)) / 2 + int64_t(GetDate().JulianDay()) * (static_cast<int64_t>(TIME_MS_IN_DAY)) +
int64_t(GetTime().MsecTotal());
return -(static_cast<int64_t>(TIME_MS_IN_DAY)) / 2 +
static_cast<int64_t>(GetDate().JulianDay()) * (static_cast<int64_t>(TIME_MS_IN_DAY)) +
static_cast<int64_t>(GetTime().MsecTotal());
}
DateTime DateTime::FromUnix(double seconds)
+6 -6
View File
@@ -16,9 +16,9 @@
#endif
#ifdef KYTY_UNDECORATE
//String unDName(const String &mangled,
// String unDName(const String &mangled,
// void* (*memget)(size_t), void (*memfree)(void*),
// unsigned short int flags);
// unsigned short int flags);
#endif
namespace Kyty::Core {
@@ -199,7 +199,7 @@ void DebugMap::LoadCsv()
#endif
//EXIT("1");
// EXIT("1");
#endif
}
@@ -269,7 +269,7 @@ void DebugMap::LoadMsvcLink(const String& name, int mode)
if (DBG_PRINTF)
{
printf("%016" PRIx64 "; %s; %s\n", static_cast<uint64_t>(addr), func.utf8_str().GetData(), obj.utf8_str().GetData());
fflush(stdout);
// int ok = fflush(stdout);
}
DebugFunctionInfo inf = {addr, 0, func.utf8_str(), obj.utf8_str()};
@@ -365,7 +365,7 @@ void DebugMap::LoadMsvcLldLink(const String& name, int mode)
if (DBG_PRINTF)
{
printf("%016" PRIx64 "; %s; %s\n", static_cast<uint64_t>(addr), func.utf8_str().GetData(), obj.utf8_str().GetData());
fflush(stdout);
// fflush(stdout);
}
DebugFunctionInfo inf = {addr, 0, func.utf8_str(), obj.utf8_str()};
@@ -417,7 +417,7 @@ void DebugMap::LoadMsvcLldLink(const String& name, int mode)
{
m_p->data[i - 1].length = m_p->data[i].addr - m_p->data[i - 1].addr;
}
#ifdef KYTY_UNDECORATE
#endif
}
+3 -2
View File
@@ -13,6 +13,7 @@
// IWYU pragma: no_include <fileapi.h>
// IWYU pragma: no_include <windows.h>
// IWYU pragma: no_include <winbase.h>
#if KYTY_PLATFORM == KYTY_PLATFORM_WINDOWS
#ifdef CreateDirectory
@@ -931,7 +932,7 @@ DateTime File::GetLastAccessTimeUTC(const String& name)
if (t.is_invalid)
{
return DateTime();
return {};
}
return DateTime(Date(t.Year, t.Month, t.Day), Time(t.Hour, t.Minute, t.Second, t.Milliseconds));
@@ -944,7 +945,7 @@ DateTime File::GetLastWriteTimeUTC(const String& name)
if (t.is_invalid)
{
return DateTime();
return {};
}
return DateTime(Date(t.Year, t.Month, t.Day), Time(t.Hour, t.Minute, t.Second, t.Milliseconds));
+7 -2
View File
@@ -426,6 +426,13 @@ static bool MSpaceInternalInit(MSpaceContext& ctx, const char* name, void* base,
ctx = MSpaceContext();
int s = snprintf(ctx.name, sizeof(ctx.name), "%s", name);
if (static_cast<size_t>(s) >= sizeof(ctx.name))
{
return false;
}
ctx.base = static_cast<MSpaceBlock*>(base);
ctx.capacity = (capacity / sizeof(MSpaceBlock)) - 2;
@@ -438,8 +445,6 @@ static bool MSpaceInternalInit(MSpaceContext& ctx, const char* name, void* base,
ctx.mutex = (thread_safe ? new Core::Mutex : nullptr);
ctx.dbg_callback = dbg_callback;
snprintf(ctx.name, sizeof(ctx.name), "%s", name);
return true;
}
+6 -2
View File
@@ -99,7 +99,11 @@ public:
KYTY_CLASS_NO_COPY(MemLock);
#ifdef MEM_TRACKER
[[nodiscard]] bool IsRecursive() const { return g_mem_depth > 1; } // NOLINT(readability-convert-member-functions-to-static)
// NOLINTNEXTLINE(readability-convert-member-functions-to-static)
[[nodiscard]] bool IsRecursive() const
{
return g_mem_depth > 1;
}
#endif
};
@@ -193,7 +197,7 @@ void core_memory_init()
void* mem_alloc_check_alignment(void* ptr)
{
#ifdef MEM_ALLOC_ALIGNED
if ((uintptr_t(ptr) & uintptr_t(MEM_ALLOC_ALIGN - 1)) != 0u)
if ((reinterpret_cast<uintptr_t>(ptr) & static_cast<uintptr_t>(MEM_ALLOC_ALIGN - 1)) != 0u)
{
EXIT("mem alloc not aligned!\n");
}
+8 -8
View File
@@ -1155,7 +1155,7 @@ String String::Mid(uint32_t first, uint32_t count) const
if (first >= size)
{
return String();
return {};
}
if (first + count > size)
@@ -1225,7 +1225,7 @@ String String::TrimRight() const
return Mid(0, size - i);
}
}
return String();
return {};
}
String String::TrimLeft() const
@@ -1240,7 +1240,7 @@ String String::TrimLeft() const
return Mid(i, size - i);
}
}
return String();
return {};
}
String String::Trim() const
@@ -1902,7 +1902,7 @@ String String::DirectoryWithoutFilename() const
if (index == STRING_INVALID_INDEX)
{
return String();
return {};
}
return Left(index + 1);
@@ -1938,7 +1938,7 @@ String String::ExtensionWithoutFilename() const
if (index == STRING_INVALID_INDEX)
{
return String();
return {};
}
return Mid(index);
@@ -1966,7 +1966,7 @@ String String::RemoveLast(uint32_t num) const
if (num >= size)
{
return String();
return {};
}
return Left(size - num);
@@ -1978,7 +1978,7 @@ String String::RemoveFirst(uint32_t num) const
if (num >= size)
{
return String();
return {};
}
return Right(size - num);
@@ -2097,7 +2097,7 @@ String String::SortChars() const
if (IsEmpty())
{
return String();
return {};
}
auto size = m_data->Size() - 1;
Vector<char32_t> d(size);
+10 -3
View File
@@ -23,7 +23,8 @@
//#define KYTY_DEBUG_LOCKS_TIMED
#if !(defined(KYTY_DEBUG_LOCKS) || defined(KYTY_DEBUG_LOCKS_TIMED)) && defined(KYTY_WIN_CS)
#include <windows.h>
#include <windows.h> // IWYU pragma: keep
// IWYU pragma: no_include <winbase.h>
constexpr DWORD KYTY_CS_SPIN_COUNT = 4000;
// IWYU pragma: no_include <minwindef.h>
@@ -84,8 +85,14 @@ struct MutexPrivate
std::recursive_timed_mutex m_mutex;
#else
#ifdef KYTY_WIN_CS
MutexPrivate() { InitializeCriticalSectionAndSpinCount(&m_cs, KYTY_CS_SPIN_COUNT); }
~MutexPrivate() { DeleteCriticalSection(&m_cs); }
MutexPrivate()
{
InitializeCriticalSectionAndSpinCount(&m_cs, KYTY_CS_SPIN_COUNT);
}
~MutexPrivate()
{
DeleteCriticalSection(&m_cs);
}
KYTY_CLASS_NO_COPY(MutexPrivate);
CRITICAL_SECTION m_cs {};
#else
+5 -5
View File
@@ -555,7 +555,7 @@ bool ScriptVar::IsInteger() const
#else
bool ScriptVar::IsInteger() const
{
return m_p->is_double && double(int32_t(m_p->val_double)) == m_p->val_double;
return m_p->is_double && static_cast<double>(static_cast<int32_t>(m_p->val_double)) == m_p->val_double;
}
#endif
bool ScriptVar::IsString() const
@@ -575,7 +575,7 @@ int64_t ScriptVar::ToInteger() const
#else
int32_t ScriptVar::ToInteger() const
{
return IsInteger() ? int32_t(m_p->val_double) : 0;
return IsInteger() ? static_cast<int32_t>(m_p->val_double) : 0;
}
#endif
double ScriptVar::ToDouble() const
@@ -747,7 +747,7 @@ void PushInteger(int32_t i)
{
lua_init();
PushDouble(double(i));
PushDouble(static_cast<double>(i));
}
#endif
@@ -781,7 +781,7 @@ ScriptVar ScriptTable::At(const String& key) const
return p.GetValue();
}
}
return ScriptVar();
return {};
}
ScriptVar ScriptTable::At(double key) const
@@ -797,7 +797,7 @@ ScriptVar ScriptTable::At(double key) const
return p.GetValue();
}
}
return ScriptVar();
return {};
}
void ScriptTable::DbgPrint(int depth) const
+3
View File
@@ -8,6 +8,9 @@
// IWYU pragma: no_include <memoryapi.h>
// IWYU pragma: no_include <minwindef.h>
// IWYU pragma: no_include <processthreadsapi.h>
// IWYU pragma: no_include <errhandlingapi.h>
// IWYU pragma: no_include <excpt.h>
// IWYU pragma: no_include <winbase.h>
#if KYTY_PLATFORM != KYTY_PLATFORM_WINDOWS
//#error "KYTY_PLATFORM != KYTY_PLATFORM_WINDOWS"
+7 -6
View File
@@ -12,12 +12,13 @@
#include "Kyty/Sys/SysFileIO.h"
#include "Kyty/Sys/SysTimer.h"
#include <windows.h>
#include <windows.h> // IWYU pragma: keep
// IWYU pragma: no_include <fileapi.h>
// IWYU pragma: no_include <handleapi.h>
// IWYU pragma: no_include <minwinbase.h>
// IWYU pragma: no_include <minwindef.h>
// IWYU pragma: no_include <winbase.h>
namespace Kyty {
@@ -188,8 +189,8 @@ sys_file_t* sys_file_create(const String& file_name)
HANDLE h_file = nullptr;
h_file = CreateFileW(reinterpret_cast<LPCWSTR>(file_name.utf16_str().GetData()),
static_cast<DWORD>(GENERIC_READ) | static_cast<DWORD>(GENERIC_WRITE), 0, nullptr, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, nullptr);
static_cast<DWORD>(GENERIC_READ) | static_cast<DWORD>(GENERIC_WRITE), 0, nullptr, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, nullptr);
ret->handle = h_file;
ret->type = SYS_FILE_FILE;
@@ -250,7 +251,7 @@ sys_file_t* sys_file_open_w(const String& file_name, sys_file_cache_type_t cache
HANDLE h_file = nullptr;
h_file = CreateFileW(reinterpret_cast<LPCWSTR>(file_name.utf16_str().GetData()), GENERIC_WRITE, 0, nullptr, OPEN_EXISTING,
get_cache_access_type(cache_type), nullptr);
get_cache_access_type(cache_type), nullptr);
if (h_file == KYTY_INVALID_HANDLE_VALUE())
{
@@ -271,8 +272,8 @@ sys_file_t* sys_file_open_rw(const String& file_name, sys_file_cache_type_t cach
HANDLE h_file = nullptr;
h_file = CreateFileW(reinterpret_cast<LPCWSTR>(file_name.utf16_str().GetData()),
static_cast<DWORD>(GENERIC_READ) | static_cast<DWORD>(GENERIC_WRITE), 0, nullptr, OPEN_EXISTING,
get_cache_access_type(cache_type), nullptr);
static_cast<DWORD>(GENERIC_READ) | static_cast<DWORD>(GENERIC_WRITE), 0, nullptr, OPEN_EXISTING,
get_cache_access_type(cache_type), nullptr);
if (h_file == KYTY_INVALID_HANDLE_VALUE())
{