mirror of
https://github.com/monero-project/monero.git
synced 2026-04-28 11:53:17 -07:00
Misc clang 21 fixes
* Use -O3 and other flags instead of -Ofast - https://discourse.llvm.org/t/rfc-deprecate-ofast/78687 - https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html * Find libunwind library based on C++ compiler type, not C compiler type * In stack_trace.cpp, pass stream modifiers to `std::stringstream` first, then send string to log * In stack_trace.cpp, remove dead code related to `stack_trace_log` path * Remove `virtual` method attributues from `final` class `cryptonote::core` * Remove unused `this` capture in cryptonote protocol handler * Remove unused variable `bad` in net node * Use `std::make_unsigned` instead of `boost::make_unsigned` - https://github.com/boostorg/type_traits/issues/171 - https://github.com/boostorg/type_traits/issues/202 - https://github.com/boostorg/type_traits/pull/199 * Cleanup `include`s in pair serialization * Test convergence b/t `std::make_unsigned` and `boost::make_unsigned` Fixes compilation and silences warnings on: clang version 21.1.6 Linux 6.18.8-3-cachyos
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
#include <vector>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/archive/portable_binary_iarchive.hpp>
|
||||
#include <boost/type_traits/make_unsigned.hpp>
|
||||
#include "cryptonote_basic/cryptonote_basic.h"
|
||||
#include "cryptonote_basic/cryptonote_basic_impl.h"
|
||||
#include "ringct/rctSigs.h"
|
||||
@@ -56,6 +57,63 @@ static_assert(!std::is_trivially_copyable<std::vector<unsigned char>>(),
|
||||
static_assert(!std::is_trivially_copyable<std::string>(),
|
||||
"should fail to compile when applying blob serializer");
|
||||
|
||||
/**
|
||||
* Test convergence of std::make_unsigned against boost::make_unsigned for
|
||||
* scoped enums with explicit underlying types
|
||||
*/
|
||||
#define DEFINE_SCOPED_UNDERLYING_ENUM(u) \
|
||||
enum class E_ ## u : u { A_##u = static_cast<u>(-1), B_##u = 0, C_##u }; \
|
||||
static_assert(std::is_same_v<std::underlying_type_t<E_##u>, u>); \
|
||||
static_assert(sizeof(std::make_unsigned_t<E_##u>) == sizeof(std::make_unsigned_t<u>)); \
|
||||
static_assert(std::is_same_v<std::make_unsigned_t<E_##u>, boost::make_unsigned_t<E_##u>>);
|
||||
|
||||
DEFINE_SCOPED_UNDERLYING_ENUM(uint8_t)
|
||||
DEFINE_SCOPED_UNDERLYING_ENUM(uint16_t)
|
||||
DEFINE_SCOPED_UNDERLYING_ENUM(uint32_t)
|
||||
DEFINE_SCOPED_UNDERLYING_ENUM(uint64_t)
|
||||
//DEFINE_SCOPED_UNDERLYING_ENUM(__uint128_t)
|
||||
DEFINE_SCOPED_UNDERLYING_ENUM(int8_t)
|
||||
DEFINE_SCOPED_UNDERLYING_ENUM(int16_t)
|
||||
DEFINE_SCOPED_UNDERLYING_ENUM(int32_t)
|
||||
DEFINE_SCOPED_UNDERLYING_ENUM(int64_t)
|
||||
//DEFINE_SCOPED_UNDERLYING_ENUM(__int128_t)
|
||||
DEFINE_SCOPED_UNDERLYING_ENUM(size_t)
|
||||
|
||||
/**
|
||||
* Test convergence of std::make_unsigned against boost::make_unsigned for
|
||||
* unscoped enums with explicit underlying types
|
||||
*/
|
||||
#define DEFINE_UNSCOPED_UNDERLYING_ENUM(u) \
|
||||
enum class UE_ ## u : u { A_##u = static_cast<u>(-1), B_##u = 0, C_##u }; \
|
||||
static_assert(std::is_same_v<std::underlying_type_t<UE_##u>, u>); \
|
||||
static_assert(sizeof(std::make_unsigned_t<UE_##u>) == sizeof(std::make_unsigned_t<u>)); \
|
||||
static_assert(std::is_same_v<std::make_unsigned_t<UE_##u>, boost::make_unsigned_t<UE_##u>>);
|
||||
|
||||
DEFINE_UNSCOPED_UNDERLYING_ENUM(uint8_t)
|
||||
DEFINE_UNSCOPED_UNDERLYING_ENUM(uint16_t)
|
||||
DEFINE_UNSCOPED_UNDERLYING_ENUM(uint32_t)
|
||||
DEFINE_UNSCOPED_UNDERLYING_ENUM(uint64_t)
|
||||
//DEFINE_UNSCOPED_UNDERLYING_ENUM(__uint128_t)
|
||||
DEFINE_UNSCOPED_UNDERLYING_ENUM(int8_t)
|
||||
DEFINE_UNSCOPED_UNDERLYING_ENUM(int16_t)
|
||||
DEFINE_UNSCOPED_UNDERLYING_ENUM(int32_t)
|
||||
DEFINE_UNSCOPED_UNDERLYING_ENUM(int64_t)
|
||||
//DEFINE_UNSCOPED_UNDERLYING_ENUM(__int128_t)
|
||||
DEFINE_UNSCOPED_UNDERLYING_ENUM(size_t)
|
||||
|
||||
/**
|
||||
* Test convergence of std::make_unsigned against boost::make_unsigned for
|
||||
* unscoped enums with implicit underlying types
|
||||
*/
|
||||
#define TEST_MAKE_UNSIGNED_ENUM(e) \
|
||||
static_assert(std::is_same_v<std::make_unsigned_t<e>, boost::make_unsigned_t<e>>);
|
||||
enum IUE1 { A1, B1, C1 };
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
TEST_MAKE_UNSIGNED_ENUM(IUE1) // may break for GCC later too, or Boost might fix it first
|
||||
#endif
|
||||
enum IUE2 { A2 = -1, B2, C2 };
|
||||
TEST_MAKE_UNSIGNED_ENUM(IUE2)
|
||||
|
||||
struct Struct
|
||||
{
|
||||
int32_t a;
|
||||
|
||||
Reference in New Issue
Block a user