Skip to content

Commit

Permalink
Update clang-format configuration and formatting to version 16
Browse files Browse the repository at this point in the history
  • Loading branch information
msimberg committed Jan 30, 2024
1 parent bf66ee8 commit 82a1a6f
Show file tree
Hide file tree
Showing 53 changed files with 1,130 additions and 1,110 deletions.
11 changes: 10 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# file while saving edits to disk
# - Please do _not_ reformat a full source file without dire need.

# PLEASE NOTE: This file requires clang-format V14.0
# PLEASE NOTE: This file requires clang-format V16.0

---
AccessModifierOffset: -4
Expand Down Expand Up @@ -55,9 +55,11 @@ BraceWrapping:
BeforeCatch: true
BeforeElse: true
IndentBraces: false
BreakAfterAttributes: Leave
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: true
BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: true
BreakStringLiterals: true
Expand Down Expand Up @@ -92,6 +94,11 @@ IndentCaseLabels: false
IndentWidth: 4
IndentWrappedFunctionNames: false
IndentPPDirectives: AfterHash
InsertBraces: false
IntegerLiteralSeparator:
Binary: 4
Decimal: 0
Hex: 4
KeepEmptyLinesAtTheStartOfBlocks: false
Language: Cpp
# MacroBlockBegin: ''
Expand All @@ -107,6 +114,8 @@ PenaltyReturnTypeOnItsOwnLine: 20
PointerAlignment: Left
PPIndentWidth: 1
ReflowComments: false
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope
SortIncludes: true
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: true
Expand Down
20 changes: 10 additions & 10 deletions cmake/tests/cpuid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ struct matcher
uint32_t registers_t::*reg;
uint32_t bit;
const char* target;
} options[] = {{0x00000001U, &registers_t::edx, 19, "clflush"},
{0x00000001U, &registers_t::edx, 8, "cx8"}, {0x00000001U, &registers_t::ecx, 13, "cx16"},
{0x00000001U, &registers_t::edx, 15, "cmov"}, {0x00000001U, &registers_t::edx, 5, "msr"},
{0x00000001U, &registers_t::edx, 4, "rdtsc"}, {0x80000001U, &registers_t::edx, 27, "rdtscp"},
{0x00000001U, &registers_t::edx, 23, "mmx"}, {0x00000001U, &registers_t::edx, 25, "sse"},
{0x00000001U, &registers_t::edx, 26, "sse2"}, {0x00000001U, &registers_t::ecx, 0, "sse3"},
{0x00000001U, &registers_t::ecx, 9, "ssse3"}, {0x00000001U, &registers_t::ecx, 19, "sse4.1"},
{0x00000001U, &registers_t::ecx, 20, "sse4.2"}, {0x00000001U, &registers_t::ecx, 28, "avx"},
{0x80000001U, &registers_t::edx, 11, "xop"}, {0x80000001U, &registers_t::edx, 16, "fma4"}};
} options[] = {{0x0000'0001U, &registers_t::edx, 19, "clflush"},
{0x0000'0001U, &registers_t::edx, 8, "cx8"}, {0x0000'0001U, &registers_t::ecx, 13, "cx16"},
{0x0000'0001U, &registers_t::edx, 15, "cmov"}, {0x0000'0001U, &registers_t::edx, 5, "msr"},
{0x0000'0001U, &registers_t::edx, 4, "rdtsc"}, {0x8000'0001U, &registers_t::edx, 27, "rdtscp"},
{0x0000'0001U, &registers_t::edx, 23, "mmx"}, {0x0000'0001U, &registers_t::edx, 25, "sse"},
{0x0000'0001U, &registers_t::edx, 26, "sse2"}, {0x0000'0001U, &registers_t::ecx, 0, "sse3"},
{0x0000'0001U, &registers_t::ecx, 9, "ssse3"}, {0x0000'0001U, &registers_t::ecx, 19, "sse4.1"},
{0x0000'0001U, &registers_t::ecx, 20, "sse4.2"}, {0x0000'0001U, &registers_t::ecx, 28, "avx"},
{0x8000'0001U, &registers_t::edx, 11, "xop"}, {0x8000'0001U, &registers_t::edx, 16, "fma4"}};
const size_t noptions = sizeof options / sizeof options[0];

int main(int argc, char** argv)
Expand All @@ -55,7 +55,7 @@ int main(int argc, char** argv)
if (argc < 2) return -1;

string target(argv[1]);
__cpuid(registers, 0x00000000);
__cpuid(registers, 0x0000'0000);

matcher m;
size_t i = 0;
Expand Down
20 changes: 10 additions & 10 deletions libs/pika/assertion/include/pika/assert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ namespace pika::detail {
#else
/// \cond NOINTERNAL
# define PIKA_ASSERT_(expr, msg) \
(!!(expr) ? void() : \
::pika::detail::handle_assert( \
::pika::detail::source_location{ \
__FILE__, static_cast<unsigned>(__LINE__), PIKA_ASSERT_CURRENT_FUNCTION}, \
PIKA_PP_STRINGIZE(expr), msg)) /**/
(!!(expr) ? void() : \
::pika::detail::handle_assert( \
::pika::detail::source_location{ \
__FILE__, static_cast<unsigned>(__LINE__), PIKA_ASSERT_CURRENT_FUNCTION}, \
PIKA_PP_STRINGIZE(expr), msg)) /**/

# if defined(PIKA_DEBUG)
# if defined(PIKA_COMPUTE_DEVICE_CODE)
Expand All @@ -74,9 +74,9 @@ namespace pika::detail {
# endif

# define PIKA_UNREACHABLE \
PIKA_ASSERT_(false, \
"This code is meant to be unreachable. If you are seeing this error " \
"message it means that you have found a bug in pika. Please report " \
"it on https://github.com/pika-org/pika/issues."); \
std::terminate()
PIKA_ASSERT_(false, \
"This code is meant to be unreachable. If you are seeing this error " \
"message it means that you have found a bug in pika. Please report " \
"it on https://github.com/pika-org/pika/issues."); \
std::terminate()
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ namespace pika::cuda::experimental {

#if defined(PIKA_HAVE_STDEXEC)
template <typename... Ts>
requires std::is_invocable_v<F, Ts...>
requires std::is_invocable_v<F, Ts...>
using invoke_result_helper =
pika::execution::experimental::completion_signatures<pika::execution::experimental::
detail::result_type_signature_helper_t<std::invoke_result_t<F, Ts...>>>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ namespace pika::cuda::experimental::then_with_stream_detail {

#if defined(PIKA_HAVE_STDEXEC)
template <typename... Ts>
requires std::is_invocable_v<F, cuda_stream const&,
std::add_lvalue_reference_t<std::decay_t<Ts>>...>
requires std::is_invocable_v<F, cuda_stream const&,
std::add_lvalue_reference_t<std::decay_t<Ts>>...>
using invoke_result_helper =
pika::execution::experimental::completion_signatures<pika::execution::experimental::
detail::result_type_signature_helper_t<std::invoke_result_t<F,
Expand Down
8 changes: 4 additions & 4 deletions libs/pika/async_cuda/tests/unit/cuda_scheduler.cu
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ inline constexpr bool is_cuda_scheduler_v =
std::is_same_v<std::decay_t<Scheduler>, cu::cuda_scheduler>;

#define CHECK_CUDA_COMPLETION_SCHEDULER(...) \
static_assert(is_cuda_scheduler_v<decltype(ex::get_completion_scheduler<ex::set_value_t>( \
ex::get_env(__VA_ARGS__)))>)
static_assert(is_cuda_scheduler_v<decltype(ex::get_completion_scheduler<ex::set_value_t>( \
ex::get_env(__VA_ARGS__)))>)

#define CHECK_NOT_CUDA_COMPLETION_SCHEDULER(...) \
static_assert(!is_cuda_scheduler_v<decltype(ex::get_completion_scheduler<ex::set_value_t>( \
ex::get_env(__VA_ARGS__)))>)
static_assert(!is_cuda_scheduler_v<decltype(ex::get_completion_scheduler<ex::set_value_t>( \
ex::get_env(__VA_ARGS__)))>)

int pika_main()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ inline std::uint32_t prev_rank(std::uint32_t rank, std::uint32_t size)
// at the same time
inline std::uint32_t make_tag(std::uint32_t rank, std::uint32_t iteration, std::uint32_t ranks)
{
std::int64_t tag = (rank + (iteration * ranks)) & 0xffffffff;
std::int64_t tag = (rank + (iteration * ranks)) & 0xffff'ffff;
msr_deb<7>.debug(
str<>("generating tag"), std::uint32_t(tag), "rank/s", rank, ranks, "iteration", iteration);
return std::uint32_t(tag);
Expand Down
16 changes: 9 additions & 7 deletions libs/pika/concepts/include/pika/concepts/concepts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@
#include <type_traits>

#define PIKA_CONCEPT_REQUIRES_(...) \
int PIKA_PP_CAT(_concept_requires_, \
__LINE__) = 42, \
typename std::enable_if < (PIKA_PP_CAT(_concept_requires_, __LINE__) == 43) || (__VA_ARGS__), \
int > ::type PIKA_PP_CAT(_concept_check_, __LINE__) = 0 /**/
int PIKA_PP_CAT(_concept_requires_, \
__LINE__) = 42, \
typename std::enable_if < (PIKA_PP_CAT(_concept_requires_, __LINE__) == 43) || \
(__VA_ARGS__), \
int > ::type PIKA_PP_CAT(_concept_check_, __LINE__) = 0 /**/

#define PIKA_CONCEPT_REQUIRES(...) \
template <int PIKA_PP_CAT(_concept_requires_, __LINE__) = 42, \
typename std::enable_if<(PIKA_PP_CAT(_concept_requires_, __LINE__) == 43) || (__VA_ARGS__), \
int>::type PIKA_PP_CAT(_concept_check_, __LINE__) = 0> /**/
template <int PIKA_PP_CAT(_concept_requires_, __LINE__) = 42, \
typename std::enable_if<(PIKA_PP_CAT(_concept_requires_, __LINE__) == 43) || \
(__VA_ARGS__), \
int>::type PIKA_PP_CAT(_concept_check_, __LINE__) = 0> /**/

#define PIKA_CONCEPT_ASSERT(...) static_assert((__VA_ARGS__), "Concept check failed") /**/
82 changes: 41 additions & 41 deletions libs/pika/concepts/include/pika/concepts/has_member_xxx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,52 +18,52 @@
/// MEMBER name (no matter static it is or not). The generated trait
/// ends up in a namespace where the macro itself has been placed.
#define PIKA_HAS_MEMBER_XXX_TRAIT_DEF(MEMBER) \
namespace PIKA_PP_CAT(PIKA_PP_CAT(has_, MEMBER), _detail) \
{ \
struct helper \
{ \
void MEMBER(...); \
}; \
namespace PIKA_PP_CAT(PIKA_PP_CAT(has_, MEMBER), _detail) { \
struct helper \
{ \
void MEMBER(...); \
}; \
\
template <typename T> \
struct helper_composed \
: T \
, helper \
{ \
}; \
template <typename T> \
struct helper_composed \
: T \
, helper \
{ \
}; \
\
template <void (helper::*)(...)> \
struct member_function_holder \
{ \
}; \
template <void (helper::*)(...)> \
struct member_function_holder \
{ \
}; \
\
template <typename T, typename Ambiguous = member_function_holder<&helper::MEMBER>> \
struct impl : std::true_type \
{ \
}; \
template <typename T, typename Ambiguous = member_function_holder<&helper::MEMBER>> \
struct impl : std::true_type \
{ \
}; \
\
template <typename T> \
struct impl<T, member_function_holder<&helper_composed<T>::MEMBER>> : std::false_type \
{ \
}; \
} \
template <typename T> \
struct impl<T, member_function_holder<&helper_composed<T>::MEMBER>> : std::false_type \
{ \
}; \
} \
\
template <typename T, typename Enable = void> \
struct PIKA_PP_CAT(has_, MEMBER) \
: std::false_type \
{ \
}; \
template <typename T, typename Enable = void> \
struct PIKA_PP_CAT(has_, MEMBER) \
: std::false_type \
{ \
}; \
\
template <typename T> \
struct PIKA_PP_CAT(has_, MEMBER)<T, std::enable_if_t<std::is_class_v<T>>> \
: PIKA_PP_CAT(PIKA_PP_CAT(has_, MEMBER), _detail)::impl<T> \
{ \
}; \
template <typename T> \
struct PIKA_PP_CAT(has_, MEMBER)<T, std::enable_if_t<std::is_class_v<T>>> \
: PIKA_PP_CAT(PIKA_PP_CAT(has_, MEMBER), _detail)::impl<T> \
{ \
}; \
\
template <typename T> \
using PIKA_PP_CAT(PIKA_PP_CAT(has_, MEMBER), _t) = typename PIKA_PP_CAT(has_, MEMBER)<T>::type; \
template <typename T> \
using PIKA_PP_CAT(PIKA_PP_CAT(has_, MEMBER), _t) = \
typename PIKA_PP_CAT(has_, MEMBER)<T>::type; \
\
template <typename T> \
inline constexpr bool PIKA_PP_CAT(PIKA_PP_CAT(has_, MEMBER), _v) = \
PIKA_PP_CAT(has_, MEMBER)<T>::value; \
/**/
template <typename T> \
inline constexpr bool PIKA_PP_CAT(PIKA_PP_CAT(has_, MEMBER), _v) = \
PIKA_PP_CAT(has_, MEMBER)<T>::value; \
/**/
Loading

0 comments on commit 82a1a6f

Please sign in to comment.