Doxygen fixes, style fixes
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2022-05-14 16:24:22 +02:00
parent 7373f7a26b
commit 8e35267bb0
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
8 changed files with 33 additions and 20 deletions

View File

@ -19,11 +19,12 @@ namespace ArbUt {
/// @brief Initialise a OptionalUniquePtr with a specific raw pointer.
inline OptionalUniquePtr<T>(T* nullable ptr) : _raw(ptr){};
/// @brief We do not allow copying or moving of unique pointers, as that would cause memory leaks and use after
/// frees.
NO_COPY_OR_MOVE(OptionalUniquePtr);
~OptionalUniquePtr() noexcept { delete _raw; }
/// @brief Return whether the pointer is null or not.
[[nodiscard]] inline bool HasValue() const noexcept { return _raw != nullptr; }

View File

@ -48,11 +48,12 @@ namespace ArbUt {
/// @brief Operator for access into underlying pointer.
inline T* non_null operator->() const noexcept { return _raw; }
/// @brief Get the raw underlying pointer, and take ownership of it. This removes the existing pointer in here.
#if defined(__clang__)
/// @brief Get the raw underlying pointer, and take ownership of it. This removes the existing pointer in here.
#if defined(__clang__)
[[clang::no_sanitize("nullability-assign")]]
#endif
inline T* non_null TakeOwnership() noexcept {
#endif
inline T* non_null
TakeOwnership() noexcept {
auto raw = _raw;
_raw = nullptr;
return raw;

View File

@ -17,8 +17,10 @@ namespace ArbUt {
public:
inline UniquePtr<T>() {}
/// @brief Initialise a UniquePtr with a specific raw pointer.
inline UniquePtr<T>(T* non_null ptr) : _raw(ptr) { EnsureNotNull(ptr) };
inline UniquePtr<T>(T* non_null ptr) : _raw(ptr){EnsureNotNull(ptr)};
/// @brief We do not allow copying or moving of unique pointers, as that would cause memory leaks and use after
/// frees.
NO_COPY_OR_MOVE(UniquePtr);
#if !WINDOWS // This doesn't work on mingw-w64 for some reason

View File

@ -9,6 +9,6 @@
/* @brief: Copy assignment is not allowed */ \
type& operator=(const type&) = delete; \
/* @brief: Copy assignment is not allowed */ \
type& operator=(type&&) = delete;
type& operator=(type&&) = delete
#endif // ARBUTILS_MISC_HPP

View File

@ -3,8 +3,8 @@
// PCG uses unsigned shifts, and overflows a lot. Disable the sanitizer for that.
#if defined(__clang__)
// If we don't ignore this diagnostic, and the sanitizer is not known yet in the clang version, this spams tens of thousands
// of warnings. Hence we disable it for a bit.
// If we don't ignore this diagnostic, and the sanitizer is not known yet in the clang version, this spams tens of
// thousands of warnings. Hence we disable it for a bit.
#pragma GCC diagnostic push
#pragma clang diagnostic ignored "-Wunknown-sanitizers"
#pragma clang attribute push(__attribute__((no_sanitize("unsigned-shift-base", "unsigned-integer-overflow"))), \

View File

@ -24,12 +24,12 @@ namespace ArbUt {
EnsureNotNull(value);
// For GCC we need to disable a diagnostic that does not like this.
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
#endif
strncpy(_value, value, length);
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#pragma GCC diagnostic pop
#endif
_value[length] = 0;
@ -94,7 +94,8 @@ namespace ArbUt {
/// @brief Instantiate a StringView using a C string.
/// @param str A null-terminated C string.
StringView(const char* non_null str)
: BasicStringView(CalcLength(str), Hash(str, CalcLength(str))), _str(new __ConstStringCharHolder(str, CalcLength(str))) {}
: BasicStringView(CalcLength(str), Hash(str, CalcLength(str))),
_str(new __ConstStringCharHolder(str, CalcLength(str))) {}
/// @brief Instantiate a StringView using a C string, as well as it's length.
/// @param str A null-terminated C string.
/// @param length The length of the C string
@ -143,9 +144,13 @@ namespace ArbUt {
return _hash != Hash(rhs.data(), rhs.size());
}
/// @brief Check equality with standard C style string.
inline constexpr bool operator==(const char* non_null rhs) const noexcept final { return _hash == Hash(rhs, CalcLength(rhs)); }
inline constexpr bool operator==(const char* non_null rhs) const noexcept final {
return _hash == Hash(rhs, CalcLength(rhs));
}
/// @brief Check inequality with standard C style string.
inline constexpr bool operator!=(const char* non_null rhs) const noexcept final { return _hash != Hash(rhs, CalcLength(rhs)); }
inline constexpr bool operator!=(const char* non_null rhs) const noexcept final {
return _hash != Hash(rhs, CalcLength(rhs));
}
/// @brief Calculates the hash for a given C string.
/// @param val A null-terminated C string.

View File

@ -41,9 +41,13 @@ namespace ArbUt {
return _hash != Hash(rhs.data(), rhs.size());
}
/// @brief Check equality with standard C style string.
inline constexpr bool operator==(const char* non_null rhs) const noexcept final { return _hash == Hash(rhs, CalcLength(rhs)); }
inline constexpr bool operator==(const char* non_null rhs) const noexcept final {
return _hash == Hash(rhs, CalcLength(rhs));
}
/// @brief Check inequality with standard C style string.
inline constexpr bool operator!=(const char* non_null rhs) const noexcept final { return _hash != Hash(rhs, CalcLength(rhs)); }
inline constexpr bool operator!=(const char* non_null rhs) const noexcept final {
return _hash != Hash(rhs, CalcLength(rhs));
}
};
}