fix reinterpret_cast + #ifdef + field initialize
Bigfoot / Sonarqube (pull_request) Failing after 5m20s
Bigfoot / Sonarqube (push) Skipped
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Successful in 43s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Successful in 28s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Successful in 47s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Successful in 29s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Successful in 1m20s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Successful in 1m2s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Successful in 1m27s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Successful in 1m6s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Successful in 48s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Successful in 32s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Successful in 53s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Successful in 37s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Successful in 1m20s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Successful in 44s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Successful in 1m5s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Successful in 1m29s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Successful in 1m12s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Successful in 34s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Successful in 28s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Successful in 53s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Successful in 1m0s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Successful in 48s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Successful in 1m3s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Successful in 56s
Bigfoot / Clang Format Checks (push) Successful in 12s

This commit is contained in:
2026-09-02 00:32:11 +02:00
parent b7f4677c68
commit 253c786b42
21 changed files with 56 additions and 48 deletions
+2 -1
View File
@@ -56,7 +56,8 @@ void AssetBase::HardReferenceVisitor::Visit(const flatbuffers::ElementaryType p_
return;
}
const ::Flat::Bigfoot::HardReference* hardReference = std::bit_cast<const ::Flat::Bigfoot::HardReference*>(p_val);
const ::Flat::Bigfoot::HardReference* hardReference = reinterpret_cast<const ::Flat::Bigfoot::HardReference*>(
p_val);
m_uuids.emplace(flatbuffers::UnPack(hardReference->uuid()));
}
} // namespace Bigfoot
@@ -91,7 +91,8 @@ class Asset: public AssetBase
void Unpack(const eastl::span<const std::byte> p_flatbuffer) override
{
#ifdef BIGFOOT_NOT_OPTIMIZED
flatbuffers::Verifier verifier {std::bit_cast<std::uint8_t*>(p_flatbuffer.data()), p_flatbuffer.size()};
flatbuffers::Verifier verifier {reinterpret_cast<const std::uint8_t*>(p_flatbuffer.data()),
p_flatbuffer.size()};
const bool assetVerified = ::Flat::Bigfoot::VerifyAssetBuffer(verifier);
CRITICAL_ASSERT(EngineAssertHandler, assetVerified, "Given asset could not be verified!");
#endif
@@ -124,8 +125,9 @@ class Asset: public AssetBase
const auto innerAsset = assetFbb.CreateVector(innerAssetFbb.GetBufferPointer(), innerAssetFbb.GetSize());
assetFbb.Finish(::Flat::Bigfoot::CreateAsset(assetFbb, header, innerAsset));
return eastl::vector<std::byte> {std::bit_cast<std::byte*>(assetFbb.GetBufferPointer()),
std::bit_cast<std::byte*>(assetFbb.GetBufferPointer() + assetFbb.GetSize())};
return eastl::vector<std::byte> {
reinterpret_cast<std::byte*>(assetFbb.GetBufferPointer()),
reinterpret_cast<std::byte*>(assetFbb.GetBufferPointer() + assetFbb.GetSize())};
}
/**
@@ -138,7 +140,8 @@ class Asset: public AssetBase
eastl::vector<UUID> GetHardReferences(const eastl::span<const std::byte> p_flatbuffer) const override
{
#ifdef BIGFOOT_NOT_OPTIMIZED
flatbuffers::Verifier verifier {std::bit_cast<std::uint8_t*>(p_flatbuffer.data()), p_flatbuffer.size()};
flatbuffers::Verifier verifier {reinterpret_cast<const std::uint8_t*>(p_flatbuffer.data()),
p_flatbuffer.size()};
const bool assetVerified = ::Flat::Bigfoot::VerifyAssetBuffer(verifier);
CRITICAL_ASSERT(EngineAssertHandler, assetVerified, "Given asset could not be verified!");
#endif
@@ -15,7 +15,7 @@ namespace Bigfoot
/*
* Logger
*/
inline Log::LoggerInfo ENGINE_LOGGER {"ENGINE_LOGGER", Flat::LogLevel::Trace};
inline Log::LoggerInfo ENGINE_LOGGER { .m_name = "ENGINE_LOGGER", .m_level = Flat::LogLevel::Trace};
} // namespace Bigfoot
#endif
#endif
@@ -95,7 +95,8 @@ void LoadAssets(const eastl::span<const UUID> p_uuids)
}
#ifdef BIGFOOT_NOT_OPTIMIZED
flatbuffers::Verifier verifier {std::bit_cast<std::uint8_t*>(flatbuffer.data()), flatbuffer.size()};
flatbuffers::Verifier verifier {reinterpret_cast<const std::uint8_t*>(flatbuffer.data()),
flatbuffer.size()};
const bool assetVerified = ::Flat::Bigfoot::VerifyAssetBuffer(verifier);
CRITICAL_ASSERT(EngineAssertHandler, assetVerified, "Given asset could not be verified!");
#endif
+2 -3
View File
@@ -8,7 +8,6 @@
#include <System/SystemAssertHandler.hpp>
#include <bit>
#include <fstream>
#include <string>
@@ -83,7 +82,7 @@ eastl::vector<std::byte> File::Read(const std::size_t p_offset, const std::size_
eastl::vector<std::byte> data;
data.resize(p_size);
file.read(std::bit_cast<char*>(data.data()), static_cast<std::streamsize>(data.size()));
file.read(reinterpret_cast<char*>(data.data()), static_cast<std::streamsize>(data.size()));
return data;
}
@@ -100,7 +99,7 @@ void File::Write(const eastl::span<const std::byte> p_data, const std::size_t p_
CRITICAL_ASSERT(SystemAssertHandler, file.is_open(), "Failed to open file {} for writing", path);
file.seekp(static_cast<std::streamoff>(p_offset), std::ios::beg);
file.write(std::bit_cast<const char*>(p_data.data()), static_cast<std::streamsize>(p_data.size()));
file.write(reinterpret_cast<const char*>(p_data.data()), static_cast<std::streamsize>(p_data.size()));
}
/****************************************************************************************/
@@ -15,7 +15,7 @@ namespace Bigfoot
/*
* Logger
*/
inline Log::LoggerInfo SYSTEM_LOGGER {"SYSTEM_LOGGER", Flat::LogLevel::Trace};
inline Log::LoggerInfo SYSTEM_LOGGER { .m_name = "SYSTEM_LOGGER", .m_level = Flat::LogLevel::Trace};
} // namespace Bigfoot
#endif
#endif
@@ -134,18 +134,18 @@ struct fmt::formatter<Bigfoot::UUID>
/****************************************************************************************/
#if defined BIGFOOT_NOT_OPTIMIZED
#ifdef BIGFOOT_NOT_OPTIMIZED
#include <quill/DeferredFormatCodec.h>
template<>
struct fmtquill::formatter<Bigfoot::UUID>
{
constexpr auto parse(format_parse_context& ctx)
static constexpr auto parse(format_parse_context& ctx)
{
return ctx.begin();
}
auto format(const Bigfoot::UUID& p_uuid, format_context& ctx) const
static auto format(const Bigfoot::UUID& p_uuid, format_context& ctx)
{
return fmtquill::format_to(ctx.out(), "{}", p_uuid.ToString().c_str());
}
+2 -1
View File
@@ -57,7 +57,8 @@ Time::Time(const std::uint64_t p_epoch):
std::uint32_t Time::GetYear() const
{
return m_timeInfo.tm_year + 1900;
constexpr std::uint32_t TM_YEAR_EPOCH = 1900;
return m_timeInfo.tm_year + TM_YEAR_EPOCH;
}
/****************************************************************************************/
+1 -1
View File
@@ -35,7 +35,7 @@ UUID::UUID(const std::string_view p_string):
UUID::UUID(const std::span<const std::byte, UUID_BYTE_SIZE> p_raw)
{
const std::span<std::uint8_t, UUID_BYTE_SIZE> raw {
const_cast<std::uint8_t*>(std::bit_cast<const std::uint8_t*>(p_raw.data())),
const_cast<std::uint8_t*>(reinterpret_cast<const std::uint8_t*>(p_raw.data())),
UUID_BYTE_SIZE};
m_uuid = uuids::uuid {raw};
@@ -15,7 +15,7 @@ namespace Bigfoot
/*
* Logger
*/
inline Log::LoggerInfo SASQUATCHBAKER_LOGGER {"SASQUATCHBAKER_LOGGER", Flat::LogLevel::Trace};
inline Log::LoggerInfo SASQUATCHBAKER_LOGGER { .m_name = "SASQUATCHBAKER_LOGGER", .m_level = Flat::LogLevel::Trace};
} // namespace Bigfoot
#endif
#endif
+9 -13
View File
@@ -6,37 +6,33 @@
*********************************************************************/
#ifndef BIGFOOT_UTILS_CASTER_HPP
#define BIGFOOT_UTILS_CASTER_HPP
#include <EASTL/type_traits.h>
#include <type_traits>
namespace Bigfoot
{
template<class TO,
class FROM,
eastl::enable_if_t<eastl::is_base_of_v<FROM, TO> || eastl::is_base_of_v<TO, FROM>, bool> = true>
template<class TO, class FROM>
requires(std::is_base_of_v<FROM, TO> || std::is_base_of_v<TO, FROM>)
constexpr TO* Cast(FROM* p_object)
{
return static_cast<TO*>(p_object);
}
template<class TO,
class FROM,
eastl::enable_if_t<eastl::is_base_of_v<FROM, TO> || eastl::is_base_of_v<TO, FROM>, bool> = true>
template<class TO, class FROM>
requires(std::is_base_of_v<FROM, TO> || std::is_base_of_v<TO, FROM>)
constexpr const TO* Cast(const FROM* p_object)
{
return static_cast<const TO*>(p_object);
}
template<class TO,
class FROM,
eastl::enable_if_t<eastl::is_base_of_v<FROM, TO> || eastl::is_base_of_v<TO, FROM>, bool> = true>
template<class TO, class FROM>
requires(std::is_base_of_v<FROM, TO> || std::is_base_of_v<TO, FROM>)
constexpr TO& Cast(FROM& p_object)
{
return static_cast<TO&>(p_object);
}
template<class TO,
class FROM,
eastl::enable_if_t<eastl::is_base_of_v<FROM, TO> || eastl::is_base_of_v<TO, FROM>, bool> = true>
template<class TO, class FROM>
requires(std::is_base_of_v<FROM, TO> || std::is_base_of_v<TO, FROM>)
constexpr const TO& Cast(const FROM& p_object)
{
return static_cast<const TO&>(p_object);
@@ -467,7 +467,8 @@ class StableSlotMap
T* Get(const std::size_t p_offset)
{
ASSERT(UtilsAssertHandler, m_occupied[p_offset], "Requesting a dead data!");
return std::launder(reinterpret_cast<T*>(m_data[p_offset].m_bytes.data()));
void* const bytes = m_data[p_offset].m_bytes.data();
return std::launder(static_cast<T*>(bytes));
}
/**
@@ -479,7 +480,8 @@ class StableSlotMap
const T* Get(const std::size_t p_offset) const
{
ASSERT(UtilsAssertHandler, m_occupied[p_offset], "Requesting a dead data!");
return std::launder(reinterpret_cast<const T*>(m_data[p_offset].m_bytes.data()));
const void* const bytes = m_data[p_offset].m_bytes.data();
return std::launder(static_cast<const T*>(bytes));
}
/**
@@ -61,7 +61,7 @@ class Log
*
* \param p_loggerInfo The logger to unregister
*/
static void UnregisterLogger(const LoggerInfo& p_loggerInfo);
void UnregisterLogger(const LoggerInfo& p_loggerInfo);
/**
* Register a logger.
@@ -84,7 +84,7 @@ class Log
* Flush all the loggers
*
*/
static void Flush();
void Flush();
~Log();
@@ -15,7 +15,7 @@ namespace Bigfoot
/*
* Logger
*/
inline Log::LoggerInfo @LOGGER_NAME@ {"@LOGGER_NAME@", Flat::LogLevel::Trace};
inline Log::LoggerInfo @LOGGER_NAME@ { .m_name = "@LOGGER_NAME@", .m_level = Flat::LogLevel::Trace};
} // namespace Bigfoot
#endif
#endif
@@ -33,6 +33,7 @@ class TaggedType
return m_value;
}
[[nodiscard]]
constexpr TYPE Get() const
{
return m_value;
@@ -21,13 +21,13 @@
#define BIGFOOT_ALWAYS_INLINE [[gnu::always_inline]] inline
#endif
#if defined BIGFOOT_OPTIMIZED
#ifdef BIGFOOT_OPTIMIZED
#define BIGFOOT_OPTIMIZED_ONLY(...) __VA_ARGS__
#define BIGFOOT_NOT_OPTIMIZED_ONLY(...)
#define BIGFOOT_OPTIMIZED_OR_NOT(p_optimized, p_notOptimized) p_optimized
#endif
#if defined BIGFOOT_NOT_OPTIMIZED
#ifdef BIGFOOT_NOT_OPTIMIZED
#define BIGFOOT_OPTIMIZED_ONLY(...)
#define BIGFOOT_NOT_OPTIMIZED_ONLY(...) __VA_ARGS__
#define BIGFOOT_OPTIMIZED_OR_NOT(p_optimized, p_notOptimized) p_notOptimized
@@ -15,7 +15,7 @@ namespace Bigfoot
/*
* Logger
*/
inline Log::LoggerInfo UTILS_LOGGER {"UTILS_LOGGER", Flat::LogLevel::Trace};
inline Log::LoggerInfo UTILS_LOGGER { .m_name = "UTILS_LOGGER", .m_level = Flat::LogLevel::Trace};
} // namespace Bigfoot
#endif
#endif
@@ -19,6 +19,10 @@ namespace Bigfoot
{
class Version
{
private:
static constexpr std::uint32_t MAJOR_SHIFT = 16;
static constexpr std::uint32_t MINOR_SHIFT = 8;
public:
Version() = default;
@@ -40,7 +44,7 @@ class Version
* \param p_patch Patch
*/
constexpr Version(const std::uint8_t p_major, const std::uint8_t p_minor, const std::uint8_t p_patch):
m_combined((p_major << 16) | (p_minor << 8) | p_patch)
m_combined((p_major << MAJOR_SHIFT) | (p_minor << MINOR_SHIFT) | p_patch)
{
}
+1 -1
View File
@@ -6,7 +6,7 @@
*********************************************************************/
#include <Utils/Log/Log.hpp>
#if defined BIGFOOT_NOT_OPTIMIZED
#ifdef BIGFOOT_NOT_OPTIMIZED
namespace Bigfoot
{
+7 -7
View File
@@ -103,7 +103,7 @@ TEST_F(FileFixture, GetSize_ShouldReturnZeroForAnEmptyFile)
TEST_F(FileFixture, GetSize_ShouldReturnTheFileSize)
{
constexpr eastl::string_view content = "Hello, Sasquatch!";
m_writeScratchFile.Write({std::bit_cast<const std::byte*>(content.data()), content.size()}, 0);
m_writeScratchFile.Write({reinterpret_cast<const std::byte*>(content.data()), content.size()}, 0);
EXPECT_EQ(m_writeScratchFile.GetSize(), content.size());
}
@@ -113,7 +113,7 @@ TEST_F(FileFixture, GetSize_ShouldReturnTheFileSize)
TEST_F(FileFixture, Read_ShouldReturnTheRequestedBytesAtTheGivenOffset)
{
constexpr eastl::string_view content = "Hello, Sasquatch!";
m_writeScratchFile.Write({std::bit_cast<const std::byte*>(content.data()), content.size()}, 0);
m_writeScratchFile.Write({reinterpret_cast<const std::byte*>(content.data()), content.size()}, 0);
const eastl::vector<std::byte> data = m_writeScratchFile.Read(7, 10);
ASSERT_EQ(data.size(), 10);
@@ -125,7 +125,7 @@ TEST_F(FileFixture, Read_ShouldReturnTheRequestedBytesAtTheGivenOffset)
TEST_F(FileFixture, Write_ShouldCreateTheFileWithTheGivenContent)
{
constexpr eastl::string_view content = "Hello, Sasquatch!";
m_writeScratchFile.Write({std::bit_cast<const std::byte*>(content.data()), content.size()}, 0);
m_writeScratchFile.Write({reinterpret_cast<const std::byte*>(content.data()), content.size()}, 0);
const eastl::vector<std::byte> data = m_writeScratchFile.Read(0, m_writeScratchFile.GetSize());
ASSERT_EQ(data.size(), content.size());
@@ -137,10 +137,10 @@ TEST_F(FileFixture, Write_ShouldCreateTheFileWithTheGivenContent)
TEST_F(FileFixture, Write_ShouldNotTouchContentOutsideTheWrittenRange)
{
constexpr eastl::string_view initial = "Hello, Sasquatch!";
m_writeScratchFile.Write({std::bit_cast<const std::byte*>(initial.data()), initial.size()}, 0);
m_writeScratchFile.Write({reinterpret_cast<const std::byte*>(initial.data()), initial.size()}, 0);
constexpr eastl::string_view patch = "BIGFOOT";
m_writeScratchFile.Write({std::bit_cast<const std::byte*>(patch.data()), patch.size()}, 7);
m_writeScratchFile.Write({reinterpret_cast<const std::byte*>(patch.data()), patch.size()}, 7);
const eastl::vector<std::byte> data = m_writeScratchFile.Read(0, m_writeScratchFile.GetSize());
ASSERT_EQ(data.size(), initial.size());
@@ -165,11 +165,11 @@ TEST_F(FileFixture, Write_ShouldRoundTripArbitraryData)
static_assert(std::is_trivially_copyable_v<Payload>);
constexpr Payload payload {.m_intValue = 42, .m_doubleValue = 3.14, .m_tag = {'B', 'I', 'G', 'F'}};
m_writeScratchFile.Write({std::bit_cast<const std::byte*>(&payload), sizeof(payload)}, 0);
m_writeScratchFile.Write({reinterpret_cast<const std::byte*>(&payload), sizeof(payload)}, 0);
const eastl::vector<std::byte> data = m_writeScratchFile.Read(0, m_writeScratchFile.GetSize());
ASSERT_EQ(data.size(), sizeof(Payload));
EXPECT_EQ(*std::bit_cast<const Payload*>(data.data()), payload);
EXPECT_EQ(*reinterpret_cast<const Payload*>(data.data()), payload);
}
/****************************************************************************************/
@@ -15,7 +15,7 @@ namespace Bigfoot
/*
* Logger
*/
inline Log::LoggerInfo UTILSTESTS_LOGGER {"UTILSTESTS_LOGGER", Flat::LogLevel::Trace};
inline Log::LoggerInfo UTILSTESTS_LOGGER { .m_name = "UTILSTESTS_LOGGER", .m_level = Flat::LogLevel::Trace};
} // namespace Bigfoot
#endif
#endif