Skip to content

Partial update of the code base to be consistent with rules in .clang-format file #2931

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentCaseLabels: true
IndentWidth: 4
IndentWrappedFunctionNames: false
IndentPPDirectives: AfterHash
IndentPPDirectives: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
Expand Down
20 changes: 10 additions & 10 deletions libs/librtlnumber/src/include/rtl_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,30 @@
#include <stdint.h>

#ifndef FILE_NAME
# define FILE_NAME (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
#define FILE_NAME (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
#endif

/* Enable Debug Messages for libRTLNumber: Un-Comment to Enable Debug Messages:
* Comment-out to Disable Debug Messages: */
// #define ENABLE_DEBUG_MESSAGES

#ifdef ENABLE_DEBUG_MESSAGES
# define DEBUG_MSG(debugMsg) std::cerr << "DEBUG: " << FILE_NAME << ":" << __LINE__ << " " << __func__ << "()" \
<< ": " << debugMsg << std::endl
#define DEBUG_MSG(debugMsg) std::cerr << "DEBUG: " << FILE_NAME << ":" << __LINE__ << " " << __func__ << "()" \
<< ": " << debugMsg << std::endl
#else
# define DEBUG_MSG(debugMsg) /* No-Op */
#define DEBUG_MSG(debugMsg) /* No-Op */
#endif

#ifndef WARN_MSG
# define WARN_MSG(warnMSG) std::cerr << "WARNING: " << FILE_NAME << ":" << __LINE__ << " " << __func__ << "()" \
<< ": " << warnMSG << "!" << std::endl
#define WARN_MSG(warnMSG) std::cerr << "WARNING: " << FILE_NAME << ":" << __LINE__ << " " << __func__ << "()" \
<< ": " << warnMSG << "!" << std::endl
#endif

#ifndef ERR_MSG
# define ERR_MSG(errMsg) std::cerr << std::endl \
<< "ERROR: " << FILE_NAME << ":" << __LINE__ << " " << __func__ << "()" \
<< ": " << errMsg << "!" << std::endl \
<< std::endl
#define ERR_MSG(errMsg) std::cerr << std::endl \
<< "ERROR: " << FILE_NAME << ":" << __LINE__ << " " << __func__ << "()" \
<< ": " << errMsg << "!" << std::endl \
<< std::endl
#endif

std::string string_of_radix_to_bitstring(std::string orig_string, size_t radix);
Expand Down
2 changes: 1 addition & 1 deletion libs/libvtrutil/src/specrand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ unsigned long SpecRandomNumberGenerator::spec_genrand_int32_() {

if (mti >= N) { /* generate N words at one time */

if (mti == N + 1) /* if init_genrand() has not been called, */
if (mti == N + 1) /* if init_genrand() has not been called, */
spec_init_genrand_(5489UL); /* a default initial seed is used */

for (size_t kk = 0; kk < N - M; kk++) {
Expand Down
1 change: 0 additions & 1 deletion libs/libvtrutil/src/specrand.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ class SpecRandomNumberGenerator : public vtr::RandomNumberGeneratorInterface {
size_t mti = N + 1;
/// the array for the state vector
unsigned long mt[N];

};

#endif
110 changes: 55 additions & 55 deletions libs/libvtrutil/src/tl_optional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,78 +32,78 @@
#include <utility>

#if (defined(_MSC_VER) && _MSC_VER == 1900)
# define TL_OPTIONAL_MSVC2015
#define TL_OPTIONAL_MSVC2015
#endif

#if (defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 9 && !defined(__clang__))
# define TL_OPTIONAL_GCC49
#define TL_OPTIONAL_GCC49
#endif

#if (defined(__GNUC__) && __GNUC__ == 5 && __GNUC_MINOR__ <= 4 && !defined(__clang__))
# define TL_OPTIONAL_GCC54
#define TL_OPTIONAL_GCC54
#endif

#if (defined(__GNUC__) && __GNUC__ == 5 && __GNUC_MINOR__ <= 5 && !defined(__clang__))
# define TL_OPTIONAL_GCC55
#define TL_OPTIONAL_GCC55
#endif

#if (defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 9 && !defined(__clang__))
// GCC < 5 doesn't support overloading on const&& for member functions
# define TL_OPTIONAL_NO_CONSTRR
#define TL_OPTIONAL_NO_CONSTRR

// GCC < 5 doesn't support some standard C++11 type traits
# define TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) \
std::has_trivial_copy_constructor<T>::value
# define TL_OPTIONAL_IS_TRIVIALLY_COPY_ASSIGNABLE(T) std::has_trivial_copy_assign<T>::value
#define TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) \
std::has_trivial_copy_constructor<T>::value
#define TL_OPTIONAL_IS_TRIVIALLY_COPY_ASSIGNABLE(T) std::has_trivial_copy_assign<T>::value

// This one will be different for GCC 5.7 if it's ever supported
# define TL_OPTIONAL_IS_TRIVIALLY_DESTRUCTIBLE(T) std::is_trivially_destructible<T>::value
#define TL_OPTIONAL_IS_TRIVIALLY_DESTRUCTIBLE(T) std::is_trivially_destructible<T>::value

// GCC 5 < v < 8 has a bug in is_trivially_copy_constructible which breaks std::vector
// for non-copyable types
#elif (defined(__GNUC__) && __GNUC__ < 8 && !defined(__clang__))
# ifndef TL_GCC_LESS_8_TRIVIALLY_COPY_CONSTRUCTIBLE_MUTEX
# define TL_GCC_LESS_8_TRIVIALLY_COPY_CONSTRUCTIBLE_MUTEX
#ifndef TL_GCC_LESS_8_TRIVIALLY_COPY_CONSTRUCTIBLE_MUTEX
#define TL_GCC_LESS_8_TRIVIALLY_COPY_CONSTRUCTIBLE_MUTEX
namespace tl {
namespace detail {
template<class T>
struct is_trivially_copy_constructible : std::is_trivially_copy_constructible<T> {};
# ifdef _GLIBCXX_VECTOR
#ifdef _GLIBCXX_VECTOR
template<class T, class A>
struct is_trivially_copy_constructible<std::vector<T, A>>
: std::is_trivially_copy_constructible<T> {};
# endif
#endif
} // namespace detail
} // namespace tl
# endif
#endif

# define TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) \
tl::detail::is_trivially_copy_constructible<T>::value
# define TL_OPTIONAL_IS_TRIVIALLY_COPY_ASSIGNABLE(T) \
std::is_trivially_copy_assignable<T>::value
# define TL_OPTIONAL_IS_TRIVIALLY_DESTRUCTIBLE(T) std::is_trivially_destructible<T>::value
#define TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) \
tl::detail::is_trivially_copy_constructible<T>::value
#define TL_OPTIONAL_IS_TRIVIALLY_COPY_ASSIGNABLE(T) \
std::is_trivially_copy_assignable<T>::value
#define TL_OPTIONAL_IS_TRIVIALLY_DESTRUCTIBLE(T) std::is_trivially_destructible<T>::value
#else
# define TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) \
std::is_trivially_copy_constructible<T>::value
# define TL_OPTIONAL_IS_TRIVIALLY_COPY_ASSIGNABLE(T) \
std::is_trivially_copy_assignable<T>::value
# define TL_OPTIONAL_IS_TRIVIALLY_DESTRUCTIBLE(T) std::is_trivially_destructible<T>::value
#define TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) \
std::is_trivially_copy_constructible<T>::value
#define TL_OPTIONAL_IS_TRIVIALLY_COPY_ASSIGNABLE(T) \
std::is_trivially_copy_assignable<T>::value
#define TL_OPTIONAL_IS_TRIVIALLY_DESTRUCTIBLE(T) std::is_trivially_destructible<T>::value
#endif

#if __cplusplus > 201103L
# define TL_OPTIONAL_CXX14
#define TL_OPTIONAL_CXX14
#endif

// constexpr implies const in C++11, not C++14
#if (__cplusplus == 201103L || defined(TL_OPTIONAL_MSVC2015) || defined(TL_OPTIONAL_GCC49))
# define TL_OPTIONAL_11_CONSTEXPR
#define TL_OPTIONAL_11_CONSTEXPR
#else
# define TL_OPTIONAL_11_CONSTEXPR constexpr
#define TL_OPTIONAL_11_CONSTEXPR constexpr
#endif

namespace tl {
#ifndef TL_MONOSTATE_INPLACE_MUTEX
# define TL_MONOSTATE_INPLACE_MUTEX
#define TL_MONOSTATE_INPLACE_MUTEX
/// Used to represent an optional with no data; essentially a bool
class monostate {};

Expand All @@ -120,7 +120,7 @@ class optional;

namespace detail {
#ifndef TL_TRAITS_MUTEX
# define TL_TRAITS_MUTEX
#define TL_TRAITS_MUTEX
// C++14-style aliases for brevity
template<class T>
using remove_const_t = typename std::remove_const<T>::type;
Expand All @@ -142,14 +142,14 @@ template<class B, class... Bs>
struct conjunction<B, Bs...>
: std::conditional<bool(B::value), conjunction<Bs...>, B>::type {};

# if defined(_LIBCPP_VERSION) && __cplusplus == 201103L
# define TL_TRAITS_LIBCXX_MEM_FN_WORKAROUND
# endif
#if defined(_LIBCPP_VERSION) && __cplusplus == 201103L
#define TL_TRAITS_LIBCXX_MEM_FN_WORKAROUND
#endif

// In C++11 mode, there's an issue in libc++'s std::mem_fn
// which results in a hard-error when using it in a noexcept expression
// in some cases. This is a check to workaround the common failing case.
# ifdef TL_TRAITS_LIBCXX_MEM_FN_WORKAROUND
#ifdef TL_TRAITS_LIBCXX_MEM_FN_WORKAROUND
template<class T>
struct is_pointer_to_non_const_member_func : std::false_type {};
template<class T, class Ret, class... Args>
Expand All @@ -171,14 +171,14 @@ template<class T>
struct is_const_or_const_ref<T const&> : std::true_type {};
template<class T>
struct is_const_or_const_ref<T const> : std::true_type {};
# endif
#endif

// std::invoke from C++17
// https://stackoverflow.com/questions/38288042/c11-14-invoke-workaround
template<typename Fn, typename... Args,
# ifdef TL_TRAITS_LIBCXX_MEM_FN_WORKAROUND
#ifdef TL_TRAITS_LIBCXX_MEM_FN_WORKAROUND
typename = enable_if_t<!(is_pointer_to_non_const_member_func<Fn>::value && is_const_or_const_ref<Args...>::value)>,
# endif
#endif
typename = enable_if_t<std::is_member_pointer<decay_t<Fn>>::value>,
int = 0>
constexpr auto invoke(Fn&& f, Args&&... args) noexcept(
Expand Down Expand Up @@ -212,14 +212,14 @@ using invoke_result = invoke_result_impl<F, void, Us...>;
template<class F, class... Us>
using invoke_result_t = typename invoke_result<F, Us...>::type;

# if defined(_MSC_VER) && _MSC_VER <= 1900
#if defined(_MSC_VER) && _MSC_VER <= 1900
// TODO make a version which works with MSVC 2015
template<class T, class U = T>
struct is_swappable : std::true_type {};

template<class T, class U = T>
struct is_nothrow_swappable : std::true_type {};
# else
#else
// https://stackoverflow.com/questions/26744589/what-is-a-proper-way-to-implement-is-swappable-to-test-for-the-swappable-concept
namespace swap_adl_tests {
// if swap ADL finds this then it would call std::swap otherwise (same
Expand Down Expand Up @@ -276,7 +276,7 @@ struct is_nothrow_swappable
bool,
is_swappable<T, U>::value && ((decltype(detail::swap_adl_tests::uses_std<T, U>(0))::value && detail::swap_adl_tests::is_std_swap_noexcept<T>::value) || (!decltype(detail::swap_adl_tests::uses_std<T, U>(0))::value && detail::swap_adl_tests::is_adl_swap_noexcept<T, U>::value))> {
};
# endif
#endif
#endif

// std::void_t from C++17
Expand Down Expand Up @@ -719,7 +719,7 @@ class optional : private detail::optional_move_assign_base<T>,
: result(nullopt);
}

# ifndef TL_OPTIONAL_NO_CONSTRR
#ifndef TL_OPTIONAL_NO_CONSTRR
template<class F>
constexpr auto and_then(F&& f) const&& {
using result = detail::invoke_result_t<F, const T&&>;
Expand All @@ -729,7 +729,7 @@ class optional : private detail::optional_move_assign_base<T>,
return has_value() ? detail::invoke(std::forward<F>(f), std::move(**this))
: result(nullopt);
}
# endif
#endif
#else
/// Carries out some operation which returns an optional on the stored
/// object if there is one.
Expand Down Expand Up @@ -763,7 +763,7 @@ class optional : private detail::optional_move_assign_base<T>,
: result(nullopt);
}

# ifndef TL_OPTIONAL_NO_CONSTRR
#ifndef TL_OPTIONAL_NO_CONSTRR
template<class F>
constexpr detail::invoke_result_t<F, const T&&> and_then(F&& f) const&& {
using result = detail::invoke_result_t<F, const T&&>;
Expand All @@ -773,7 +773,7 @@ class optional : private detail::optional_move_assign_base<T>,
return has_value() ? detail::invoke(std::forward<F>(f), std::move(**this))
: result(nullopt);
}
# endif
#endif
#endif

#if defined(TL_OPTIONAL_CXX14) && !defined(TL_OPTIONAL_GCC49) && !defined(TL_OPTIONAL_GCC54) && !defined(TL_OPTIONAL_GCC55)
Expand Down Expand Up @@ -820,14 +820,14 @@ class optional : private detail::optional_move_assign_base<T>,
return optional_map_impl(*this, std::forward<F>(f));
}

# ifndef TL_OPTIONAL_NO_CONSTRR
#ifndef TL_OPTIONAL_NO_CONSTRR
template<class F>
constexpr decltype(optional_map_impl(std::declval<const optional&&>(),
std::declval<F&&>()))
map(F&& f) const&& {
return optional_map_impl(std::move(*this), std::forward<F>(f));
}
# endif
#endif
#endif

#if defined(TL_OPTIONAL_CXX14) && !defined(TL_OPTIONAL_GCC49) && !defined(TL_OPTIONAL_GCC54) && !defined(TL_OPTIONAL_GCC55)
Expand Down Expand Up @@ -874,14 +874,14 @@ class optional : private detail::optional_move_assign_base<T>,
return optional_map_impl(*this, std::forward<F>(f));
}

# ifndef TL_OPTIONAL_NO_CONSTRR
#ifndef TL_OPTIONAL_NO_CONSTRR
template<class F>
constexpr decltype(optional_map_impl(std::declval<const optional&&>(),
std::declval<F&&>()))
transform(F&& f) const&& {
return optional_map_impl(std::move(*this), std::forward<F>(f));
}
# endif
#endif
#endif

/// Calls `f` if the optional is empty
Expand Down Expand Up @@ -1593,7 +1593,7 @@ class optional<T&> {
: result(nullopt);
}

# ifndef TL_OPTIONAL_NO_CONSTRR
#ifndef TL_OPTIONAL_NO_CONSTRR
template<class F>
constexpr auto and_then(F&& f) const&& {
using result = detail::invoke_result_t<F, const T&>;
Expand All @@ -1603,7 +1603,7 @@ class optional<T&> {
return has_value() ? detail::invoke(std::forward<F>(f), **this)
: result(nullopt);
}
# endif
#endif
#else
/// Carries out some operation which returns an optional on the stored
/// object if there is one.
Expand Down Expand Up @@ -1637,7 +1637,7 @@ class optional<T&> {
: result(nullopt);
}

# ifndef TL_OPTIONAL_NO_CONSTRR
#ifndef TL_OPTIONAL_NO_CONSTRR
template<class F>
constexpr detail::invoke_result_t<F, const T&> and_then(F&& f) const&& {
using result = detail::invoke_result_t<F, const T&>;
Expand All @@ -1647,7 +1647,7 @@ class optional<T&> {
return has_value() ? detail::invoke(std::forward<F>(f), **this)
: result(nullopt);
}
# endif
#endif
#endif

#if defined(TL_OPTIONAL_CXX14) && !defined(TL_OPTIONAL_GCC49) && !defined(TL_OPTIONAL_GCC54) && !defined(TL_OPTIONAL_GCC55)
Expand Down Expand Up @@ -1694,14 +1694,14 @@ class optional<T&> {
return detail::optional_map_impl(*this, std::forward<F>(f));
}

# ifndef TL_OPTIONAL_NO_CONSTRR
#ifndef TL_OPTIONAL_NO_CONSTRR
template<class F>
constexpr decltype(detail::optional_map_impl(std::declval<const optional&&>(),
std::declval<F&&>()))
map(F&& f) const&& {
return detail::optional_map_impl(std::move(*this), std::forward<F>(f));
}
# endif
#endif
#endif

#if defined(TL_OPTIONAL_CXX14) && !defined(TL_OPTIONAL_GCC49) && !defined(TL_OPTIONAL_GCC54) && !defined(TL_OPTIONAL_GCC55)
Expand Down Expand Up @@ -1750,14 +1750,14 @@ class optional<T&> {
return detail::optional_map_impl(*this, std::forward<F>(f));
}

# ifndef TL_OPTIONAL_NO_CONSTRR
#ifndef TL_OPTIONAL_NO_CONSTRR
template<class F>
constexpr decltype(detail::optional_map_impl(std::declval<const optional&&>(),
std::declval<F&&>()))
transform(F&& f) const&& {
return detail::optional_map_impl(std::move(*this), std::forward<F>(f));
}
# endif
#endif
#endif

/// Calls `f` if the optional is empty
Expand Down
Loading