Skip to content

Commit 412d0b2

Browse files
authored
Merge pull request #23 from braxtons12/clang-21-compat
clang 21 build compatibility
2 parents 924d16b + bf41ed3 commit 412d0b2

File tree

9 files changed

+1121
-690
lines changed

9 files changed

+1121
-690
lines changed

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
Language: Cpp
33
AccessModifierOffset: -2
4-
AlignAfterOpenBracket: Align
4+
AlignAfterOpenBracket: BlockIndent
55
AlignArrayOfStructures: Right
66
AlignConsecutiveAssignments: None
77
AlignConsecutiveBitFields: Consecutive

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.20)
2-
project(hyperion_platform LANGUAGES CXX VERSION 0.5.4)
2+
project(hyperion_platform LANGUAGES CXX VERSION 0.5.5)
33

44
include(CTest)
55

include/hyperion/platform.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
/// @author Braxton Salyer <braxtonsalyer@gmail.com>
33
/// @brief This module includes macro definitions for identifying the platform being compiled for
44
/// (operating system, compiler, etc)
5-
/// @version 0.4.0
6-
/// @date 2024-04-20
5+
/// @version 0.4.1
6+
/// @date 2025-11-25
77
///
88
/// MIT License
9-
/// @copyright Copyright (c) 2024 Braxton Salyer <braxtonsalyer@gmail.com>
9+
/// @copyright Copyright (c) 2025 Braxton Salyer <braxtonsalyer@gmail.com>
1010
///
1111
/// Permission is hereby granted, free of charge, to any person obtaining a copy
1212
/// of this software and associated documentation files (the "Software"), to deal
@@ -47,8 +47,7 @@
4747
#if !((defined(__MSC_VER) || defined(_MSC_VER)) && !defined(__clang__))
4848
// NOLINTNEXTLINE
4949
#define HYPERION_IGNORE_UNUSED_MACROS_WARNING_START \
50-
_Pragma("GCC diagnostic push") \
51-
_Pragma("GCC diagnostic ignored \"-Wunused-macros\"")
50+
_Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wunused-macros\"")
5251
#else
5352
// NOLINTNEXTLINE
5453
#define HYPERION_IGNORE_UNUSED_MACROS_WARNING_START
@@ -174,7 +173,7 @@ HYPERION_IGNORE_UNUSED_MACROS_WARNING_START;
174173
/// @brief Whether the current compiler is GCC
175174
/// @ingroup platform
176175
/// @headerfile hyperion/platform.h
177-
#if(defined(__MSC_VER) || defined(_MSC_VER)) && !HYPERION_PLATFORM_COMPILER_IS_CLANG
176+
#if (defined(__MSC_VER) || defined(_MSC_VER)) && !HYPERION_PLATFORM_COMPILER_IS_CLANG
178177
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
179178
#define HYPERION_PLATFORM_COMPILER_IS_MSVC true
180179
#else

include/hyperion/platform/compare.h

Lines changed: 147 additions & 102 deletions
Large diffs are not rendered by default.

include/hyperion/platform/def.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
/// @author Braxton Salyer <braxtonsalyer@gmail.com>
33
/// @brief Provides various macro definitions for things like compiler-specific attributes,
44
/// feature enablement, and warning suppression
5-
/// @version 0.4.0
6-
/// @date 2024-04-20
5+
/// @version 0.4.1
6+
/// @date 2025-11-25
77
///
88
/// MIT License
9-
/// @copyright Copyright (c) 2024 Braxton Salyer <braxtonsalyer@gmail.com>
9+
/// @copyright Copyright (c) 2025 Braxton Salyer <braxtonsalyer@gmail.com>
1010
///
1111
/// Permission is hereby granted, free of charge, to any person obtaining a copy
1212
/// of this software and associated documentation files (the "Software"), to deal
@@ -38,6 +38,7 @@
3838
#define HYPERION_PLATFORM_DEF_H
3939

4040
#include <hyperion/platform.h>
41+
4142
#include <version>
4243

4344
HYPERION_IGNORE_UNUSED_MACROS_WARNING_START;
@@ -93,7 +94,7 @@ HYPERION_IGNORE_UNUSED_MACROS_WARNING_START;
9394
/// @brief if `std::jthread` is available, this will be defined as true, otherwise it will be false.
9495
/// @ingroup defines
9596
/// @headerfile hyperion/platform/def.h
96-
#if(defined(__cpp_lib_jthread) && __cpp_lib_jthread >= 201911L)
97+
#if (defined(__cpp_lib_jthread) && __cpp_lib_jthread >= 201911L)
9798
#define HYPERION_STD_LIB_HAS_JTHREAD true
9899
#else
99100
#define HYPERION_STD_LIB_HAS_JTHREAD false
@@ -180,7 +181,7 @@ HYPERION_IGNORE_UNUSED_MACROS_WARNING_START;
180181
/// @ingroup defines
181182
/// @headerfile hyperion/platform/def.h
182183
#if defined(__cpp_lib_constexpr_string)
183-
#if(__cpp_lib_constexpr_string >= 201907L)
184+
#if (__cpp_lib_constexpr_string >= 201907L)
184185
#define HYPERION_CONSTEXPR_STRINGS constexpr
185186
#else
186187
#define HYPERION_CONSTEXPR_STRINGS

include/hyperion/platform/types.h

Lines changed: 105 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/// @file types.h
22
/// @author Braxton Salyer <braxtonsalyer@gmail.com>
33
/// @brief various type aliases for builtin types and user defined literals for them
4-
/// @version 0.5.3
5-
/// @date 2024-09-25
4+
/// @version 0.5.4
5+
/// @date 2025-11-25
66
///
77
/// MIT License
8-
/// @copyright Copyright (c) 2024 Braxton Salyer <braxtonsalyer@gmail.com>
8+
/// @copyright Copyright (c) 2025 Braxton Salyer <braxtonsalyer@gmail.com>
99
///
1010
/// Permission is hereby granted, free of charge, to any person obtaining a copy
1111
/// of this software and associated documentation files (the "Software"), to deal
@@ -129,21 +129,27 @@ namespace hyperion {
129129
};
130130

131131
template<char... Chars>
132-
constexpr auto trim_separators([[maybe_unused]] string_literal<Chars...> literal) noexcept {
133-
constexpr auto new_size = []() {
134-
constexpr auto array = std::array{Chars...};
135-
auto size = array.size();
136-
for(const auto& c : array) {
137-
if(c == '\'') {
138-
size--;
139-
}
132+
constexpr auto
133+
get_size([[maybe_unused]] string_literal<Chars...> literal) noexcept -> usize {
134+
auto size = literal.array.size();
135+
// NOLINTNEXTLINE(readability-identifier-length)
136+
for(const auto& c : literal.array) {
137+
if(c == '\'') {
138+
size--;
140139
}
141-
return size;
142-
}();
140+
}
141+
return size;
142+
}
143143

144+
template<char... Chars>
145+
constexpr auto trim_separators([[maybe_unused]] string_literal<Chars...> literal) noexcept
146+
-> std::array<char, get_size(string_literal<Chars...>{})> {
147+
constexpr auto new_size = get_size(string_literal<Chars...>{});
144148
constexpr auto array = std::array{Chars...};
145149
std::array<char, new_size> new_array = {};
150+
// NOLINTNEXTLINE(readability-identifier-length)
146151
auto i = 0UL;
152+
// NOLINTNEXTLINE(readability-identifier-length)
147153
for(const auto& c : array) {
148154
if(c != '\'') {
149155
new_array[i] = c;
@@ -163,12 +169,18 @@ namespace hyperion {
163169

164170
template<literal_status status>
165171
static constexpr auto check_literal_status() noexcept -> void {
166-
static_assert(status != detail::literal_status::OutOfRange,
167-
"Invalid Literal: Literal out of numeric range for type");
168-
static_assert(status != detail::literal_status::InvalidCharacterSequence,
169-
"Invalid Literal: Literal contains invalid character sequence for type");
170-
static_assert(status != detail::literal_status::InvalidLiteralType,
171-
"Invalid Literal: Requested type is not a valid numeric literal type");
172+
static_assert(
173+
status != detail::literal_status::OutOfRange,
174+
"Invalid Literal: Literal out of numeric range for type"
175+
);
176+
static_assert(
177+
status != detail::literal_status::InvalidCharacterSequence,
178+
"Invalid Literal: Literal contains invalid character sequence for type"
179+
);
180+
static_assert(
181+
status != detail::literal_status::InvalidLiteralType,
182+
"Invalid Literal: Requested type is not a valid numeric literal type"
183+
);
172184
}
173185

174186
HYPERION_IGNORE_PADDING_WARNING_START
@@ -191,9 +203,11 @@ namespace hyperion {
191203
Type sum = 0;
192204
const auto& str = literal.array;
193205
const auto is_hex
206+
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-constant-array-index)
194207
= str.size() > 2 && str[0] == '0' && (str[1] == 'x' || str[1] == 'X');
195208

196209
const auto is_binary
210+
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-constant-array-index)
197211
= str.size() > 2 && str[0] == '0' && (str[1] == 'b' || str[1] == 'B');
198212

199213
if constexpr(std::is_floating_point_v<Type>
@@ -226,30 +240,36 @@ namespace hyperion {
226240

227241
const auto is_octal = str.size() > 1 && str[0] == '0' && !is_hex && !is_binary
228242
&& !std::is_floating_point_v<Type>;
243+
// NOLINTNEXTLINE(readability-avoid-nested-conditional-operator)
229244
const auto offset = is_hex || is_binary ? 2U : (is_octal ? 1U : 0U);
230245

231-
constexpr auto to_number = [](char digit) {
246+
constexpr auto to_number = [](char digit) -> Type {
232247
if(digit >= '0' && digit <= '9') {
233248
return static_cast<Type>(digit - '0');
234249
}
235250

236251
if(digit >= 'a' && digit <= 'f') {
237-
// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)
238-
return static_cast<Type>(static_cast<Type>(digit - 'a')
239-
+ static_cast<Type>(10));
252+
return static_cast<Type>(
253+
static_cast<Type>(digit - 'a')
254+
// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)
255+
+ static_cast<Type>(10)
256+
);
240257
}
241258

242259
if(digit >= 'A' && digit <= 'F') {
243-
// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)
244-
return static_cast<Type>(static_cast<Type>(digit - 'A')
245-
+ static_cast<Type>(10));
260+
return static_cast<Type>(
261+
static_cast<Type>(digit - 'A')
262+
// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)
263+
+ static_cast<Type>(10)
264+
);
246265
}
247266

248267
return static_cast<Type>(0);
249268
};
250269

251-
// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)
270+
// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers,readability-avoid-nested-conditional-operator)
252271
[[maybe_unused]] const usize base
272+
// NOLINTNEXTLINE(readability-avoid-nested-conditional-operator)
253273
= is_hex ? 16U : (is_binary ? 2U : (is_octal ? 8U : 10U));
254274
[[maybe_unused]] bool found_decimal = false;
255275
[[maybe_unused]] usize current_multiplier = 1U;
@@ -312,16 +332,19 @@ namespace hyperion {
312332
}
313333
else {
314334
if(digit != '\'') {
335+
// NOLINTNEXTLINE(cppcoreguidelines-narrowing-conversions)
315336
Type value = to_number(digit) * static_cast<Type>(current_multiplier);
316337
current_multiplier *= base;
317338
if(sum > std::numeric_limits<Type>::max() - value) {
318339
return {.status = literal_status::OutOfRange};
319340
}
341+
// NOLINTNEXTLINE(cppcoreguidelines-narrowing-conversions)
320342
sum += value;
321343
}
322344
}
323345
}
324346

347+
// NOLINTNEXTLINE(readability-redundant-casting)
325348
auto result = static_cast<Type>(sum);
326349
if constexpr(std::is_floating_point_v<Type>) {
327350
if(found_decimal && num_before_decimal != 0U) {
@@ -611,48 +634,68 @@ namespace hyperion {
611634
static_assert(static_cast<i8>(8) == 8_i8, "i8 literal operator broken");
612635
// NOLINTNEXTLINE
613636
static_assert(static_cast<i16>(8) == 8_i16, "i16 literal operator broken");
614-
// NOLINTNEXTLINE
615-
static_assert(static_cast<i64>(-64'123'456) == -64'123'456_i64,
616-
"i64 literal operator broken!");
617-
// NOLINTNEXTLINE
618-
static_assert(-static_cast<i64>(0xDEAD'BEEF) == -0xDEAD'BEEF_i64,
619-
"i64 literal operator broken!");
637+
static_assert(
638+
// NOLINTNEXTLINE
639+
static_cast<i64>(-64'123'456) == -64'123'456_i64,
640+
"i64 literal operator broken!"
641+
);
642+
static_assert(
643+
// NOLINTNEXTLINE
644+
-static_cast<i64>(0xDEAD'BEEF) == -0xDEAD'BEEF_i64,
645+
"i64 literal operator broken!"
646+
);
620647
// NOLINTNEXTLINE
621648
static_assert(-static_cast<i64>(012345) == -012345_i64, "i64 literal operator broken!");
622-
// NOLINTNEXTLINE
623-
static_assert(static_cast<i64>(0b0011001100) == 0b0011001100_i64,
624-
"i64 literal operator broken!");
649+
static_assert(
650+
// NOLINTNEXTLINE
651+
static_cast<i64>(0b0011001100) == 0b0011001100_i64,
652+
"i64 literal operator broken!"
653+
);
625654

626655
static inline constexpr auto acceptable_deviation
627656
= static_cast<fmax>(0.000000000001261213356);
628-
// NOLINTNEXTLINE
629-
static_assert(static_cast<fmax>(64.123456789) - 64.123456789_fmax < acceptable_deviation,
630-
"fmax literal operator broken!");
631-
// NOLINTNEXTLINE
632-
static_assert(static_cast<fmax>(64'000) - 64'000_fmax < acceptable_deviation,
633-
"fmax literal operator broken!");
634-
// NOLINTNEXTLINE
635-
static_assert(static_cast<fmax>(1) - 1_fmax < acceptable_deviation,
636-
"fmax literal operator broken!");
637-
// NOLINTNEXTLINE
638-
static_assert(static_cast<fmax>(64'000.123456789) - 64'000.123456789_fmax
639-
< acceptable_deviation,
640-
"fmax literal operator broken!");
641-
// NOLINTNEXTLINE
642-
static_assert(static_cast<fmax>(-64'000.123456789) - -64'000.123456789_fmax
643-
< acceptable_deviation,
644-
"fmax literal operator broken!");
645-
// NOLINTNEXTLINE
646-
static_assert(static_cast<fmax>(0.5) - 0.5_fmax < acceptable_deviation,
647-
"fmax literal operator broken!");
657+
static_assert(
658+
// NOLINTNEXTLINE
659+
static_cast<fmax>(64.123456789) - 64.123456789_fmax < acceptable_deviation,
660+
"fmax literal operator broken!"
661+
);
662+
static_assert(
663+
// NOLINTNEXTLINE
664+
static_cast<fmax>(64'000) - 64'000_fmax < acceptable_deviation,
665+
"fmax literal operator broken!"
666+
);
667+
static_assert(
668+
// NOLINTNEXTLINE
669+
static_cast<fmax>(1) - 1_fmax < acceptable_deviation,
670+
"fmax literal operator broken!"
671+
);
672+
static_assert(
673+
// NOLINTNEXTLINE
674+
static_cast<fmax>(64'000.123456789) - 64'000.123456789_fmax < acceptable_deviation,
675+
"fmax literal operator broken!"
676+
);
677+
static_assert(
678+
// NOLINTNEXTLINE
679+
static_cast<fmax>(-64'000.123456789) - -64'000.123456789_fmax < acceptable_deviation,
680+
"fmax literal operator broken!"
681+
);
682+
static_assert(
683+
// NOLINTNEXTLINE
684+
static_cast<fmax>(0.5) - 0.5_fmax < acceptable_deviation,
685+
"fmax literal operator broken!"
686+
);
648687
// NOLINTNEXTLINE
649688
static_assert(static_cast<fmax>(0.5) == 0.5_fmax, "fmax literal operator broken!");
650-
// NOLINTNEXTLINE
651-
static_assert(static_cast<fmax>(1.0e10) == 10'000'000'000.0_fmax,
652-
"fmax literal operator broken!");
653-
// NOLINTNEXTLINE
654-
static_assert(static_cast<fmax>(1.0e18) == 1'000'000'000'000'000'000.0_fmax,
655-
"fmax literal operator broken!");
689+
static_assert(
690+
// NOLINTNEXTLINE
691+
static_cast<fmax>(1.0e10) == 10'000'000'000.0_fmax,
692+
"fmax literal operator broken!"
693+
);
694+
static_assert(
695+
// NOLINTNEXTLINE
696+
static_cast<fmax>(1.0e18) == 1'000'000'000'000'000'000.0_fmax,
697+
"fmax literal operator broken!"
698+
);
656699

657700
#if HYPERION_PLATFORM_COMPILER_IS_CLANG || HYPERION_PLATFORM_COMPILER_IS_GCC
658701
_Pragma("GCC diagnostic pop")

0 commit comments

Comments
 (0)