Skip to content

Commit 6dff29a

Browse files
authored
Merge pull request #541 from hvdijk/upgrade-clang-tools
Upgrade clang-format & clang-tidy.
2 parents 6a99ac4 + ea1a63d commit 6dff29a

File tree

312 files changed

+3094
-2767
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

312 files changed

+3094
-2767
lines changed

.clang-tidy

+6-1
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ Checks: "bugprone-*,\
194194
-cert-err34-c,\
195195
-cert-err58-cpp,\
196196
-cert-flp30-c,\
197+
-cert-int09-c,\
197198
-cert-msc30-c,\
198199
-cert-msc32-c,\
199200
-cert-msc50-cpp,\
@@ -207,6 +208,7 @@ Checks: "bugprone-*,\
207208
clang-analyzer-*,\
208209
-clang-analyzer-cplusplus.NewDelete,\
209210
-clang-analyzer-cplusplus.NewDeleteLeaks,\
211+
-clang-analyzer-optin.core.EnumCastOutOfRange,\
210212
-clang-analyzer-optin.performance.Padding,\
211213
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,\
212214
*googletest*,\
@@ -280,6 +282,7 @@ Checks: "bugprone-*,\
280282
-modernize-use-trailing-return-type,\
281283
-modernize-use-using,\
282284
performance-*,\
285+
-performance-enum-size,\
283286
-performance-move-const-arg,\
284287
-performance-move-constructor-init,\
285288
-performance-noexcept-move-constructor,\
@@ -293,6 +296,7 @@ Checks: "bugprone-*,\
293296
-readability-convert-member-functions-to-static,
294297
-readability-delete-null-pointer,\
295298
-readability-else-after-return,\
299+
-readability-enum-initial-value,\
296300
-readability-function-cognitive-complexity,\
297301
-readability-function-size,\
298302
-readability-implicit-bool-conversion,\
@@ -327,9 +331,10 @@ ExtraArgs: [
327331
]
328332
WarningsAsErrors: '*'
329333
HeaderFilterRegex: '.*'
330-
AnalyzeTemporaryDtors: false
331334
FormatStyle: 'file'
332335
CheckOptions:
336+
- key: bugprone-unused-return-value.AllowCastToVoid
337+
value: true
333338
- key: readability-braces-around-statements.ShortStatementLines
334339
value: '1'
335340
- key: hicpp-braces-around-statements.ShortStatementLines

.github/workflows/run_pr_tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ jobs:
106106

107107
- name: setup-ubuntu-clang-format
108108
run:
109-
pip install clang-format==17.0.6
109+
pip install clang-format==19.1.0
110110

111111
- name: run clang-format
112112
run: |

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ find_package(PythonInterp 3.6 REQUIRED)
201201
# which perform static analysis and style checking on source files.
202202
# When updating the version here, also update that used in the merge request
203203
# config
204-
find_package(ClangTools 17 COMPONENTS clang-format clang-tidy)
204+
find_package(ClangTools 19 COMPONENTS clang-format clang-tidy)
205205
if(TARGET ClangTools::clang-tidy)
206206
ca_option(CA_CLANG_TIDY_FLAGS STRING
207207
"Semi-color separated list of clang-tidy flags" "")

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ To install the dependencies on Ubuntu, open the terminal and run:
4141
To install the recommended packages, run:
4242
```sh
4343
$ sudo apt install -y ninja-build doxygen python3-pip
44-
$ sudo pip3 install lit virtualenv cmakelint clang-format==17.0.6
44+
$ sudo pip3 install lit virtualenv cmakelint clang-format==19.1.0
4545
```
4646

4747
### Compiling oneAPI Construction Kit

clik/external/hal_cpu/source/hal_main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class cpu_hal_platform : public hal::hal_t {
5858
cpu_hal_platform() {
5959
hal_device_info = &cpu_hal::setup_cpu_hal_device_info();
6060

61-
constexpr static uint32_t implemented_api_version = 6;
61+
static constexpr uint32_t implemented_api_version = 6;
6262
static_assert(implemented_api_version == hal_t::api_version,
6363
"Implemented API version for CPU HAL does not match hal.h");
6464
hal_info.platform_name = hal_device_info->target_name;

clik/include/clik_common.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
struct clik_buffer;
4141

4242
struct CLIK_API clik_ndrange {
43-
constexpr static uint32_t max_dimensions = 3;
43+
static constexpr uint32_t max_dimensions = 3;
4444
// Origin of the work 'grid'. Used when the first item is not at (0, 0, 0).
4545
uint64_t offset[max_dimensions];
4646
// Global size, i.e. total number of work-items in each dimension.

clik/include/clik_hal_version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919

2020
#include <stdint.h>
2121

22-
constexpr static uint32_t supported_hal_api_version = 6;
22+
static constexpr uint32_t supported_hal_api_version = 6;
2323

2424
#endif // _CLIK_CLIK_HAL_VERSION_H

cmake/FindClangTools.cmake

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ foreach(component ${ClangTools_FIND_COMPONENTS})
108108

109109
if(result EQUAL 0)
110110
# Strip all non-version text from the output, we only care about the
111-
# <major>.<minor> version components.
112-
string(REGEX MATCH "[0-9]+\\.[0-9]+" version_string ${version_string})
111+
# <major> version component.
112+
string(REGEX MATCH "[0-9]+" version_string ${version_string})
113113
if(version_string VERSION_EQUAL ClangTools_FIND_VERSION)
114114
# Success, found the correct version of the component.
115115
set(ClangTools_${component}_FOUND TRUE)

doc/getting-started.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Recommended for Ubuntu 20.04
4848
4949
$ sudo apt update
5050
$ sudo apt install -y ninja-build doxygen python3-pip
51-
$ sudo pip3 install lit virtualenv cmakelint clang-format==17.0.6
51+
$ sudo pip3 install lit virtualenv cmakelint clang-format==19.1.0
5252
5353
.. tip::
5454
For ease of use ``python3`` and ``pip3`` can be symlinked to ``python`` and

examples/hals/hal_cpu_client/source/hal_main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace hal {
2121
class hal_cpu_socket_client : public hal::hal_socket_client {
2222
public:
2323
hal_cpu_socket_client() : hal_socket_client(0) {
24-
constexpr static uint32_t implemented_api_version = 6;
24+
static constexpr uint32_t implemented_api_version = 6;
2525
static_assert(
2626
implemented_api_version == hal_t::api_version,
2727
"Implemented API version for hal_socket_client does not match hal.h");

examples/hals/hal_refsi_tutorial/source/hal_main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class refsi_tutorial_hal : public hal::hal_t {
5050

5151
refsi_tutorial_hal() {
5252
const char *target_name = "RefSi M1 Tutorial";
53-
constexpr static uint32_t implemented_api_version = 6;
53+
static constexpr uint32_t implemented_api_version = 6;
5454
static_assert(implemented_api_version == hal_t::api_version,
5555
"Implemented API version for RefSi HAL does not match hal.h");
5656
hal_info.platform_name = target_name;

examples/refsi/hal_refsi/external/refsidrv/include/common/elf_loader.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class ELFProgram {
5858

5959
reg_t find_symbol(const char *name) const;
6060

61-
constexpr static uint64_t invalid_address = ~0ull;
61+
static constexpr uint64_t invalid_address = ~0ull;
6262

6363
private:
6464
bool read_header(MemoryDevice &src, unit_id_t unit);

examples/refsi/hal_refsi/external/refsidrv/include/refsidrv/refsi_device_g.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ struct RefSiGDevice : public RefSiDevice {
4545
refsi_result setupHartLocalWindow(unsigned index);
4646
void pre_run_kernel(slim_sim_t &sim, reg_t entry_point_addr);
4747

48-
constexpr const static unsigned window_index_elf = 0;
49-
constexpr const static unsigned window_index_harts = 1;
48+
static constexpr const unsigned window_index_elf = 0;
49+
static constexpr const unsigned window_index_harts = 1;
5050
unsigned max_harts = REFSI_SIM_MAX_HARTS;
5151
refsi_addr_t elf_mem_mapped_addr = 0;
5252
refsi_addr_t harts_mem_mapped_addr = 0;

examples/refsi/hal_refsi/source/hal_main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class refsi_hal : public hal::hal_t {
121121
}
122122

123123
refsi_hal() {
124-
constexpr static uint32_t implemented_api_version = 6;
124+
static constexpr uint32_t implemented_api_version = 6;
125125
static_assert(implemented_api_version == hal_t::api_version,
126126
"Implemented API version for RefSi HAL does not match hal.h");
127127
hal_info.num_devices = 1;

hal/hal_remote/include/hal_remote/hal_transmitter.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class hal_transmitter {
3232
/// Receive `size` bytes of data into `data`
3333
/// @return true if the receive succeeds
3434
virtual bool receive(void *data, uint32_t size) = 0;
35-
virtual ~hal_transmitter(){};
35+
virtual ~hal_transmitter() {};
3636

3737
void enable_debug(bool debug_enabled) { debug = debug_enabled; }
3838
bool debug_enabled() { return debug; }

hal/include/hal.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ namespace hal {
3535
/// a hal. it provides access to device memory, program loading, execution
3636
/// and information queries.
3737
struct hal_device_t {
38-
hal_device_t(hal_device_info_t *device_info) : device_info(device_info){};
39-
virtual ~hal_device_t(){};
38+
hal_device_t(hal_device_info_t *device_info) : device_info(device_info) {};
39+
virtual ~hal_device_t() {};
4040

4141
/// @brief Find a specific kernel function in a compiled program.
4242
///

modules/cargo/include/cargo/allocator.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class mallocator {
7878
/// @brief Free allocated memory.
7979
///
8080
/// @param pointer Pointer to allocated memory.
81-
void free(value_type *pointer) { cargo::free(pointer); }
81+
void free(value_type *pointer) { cargo::free(static_cast<void *>(pointer)); }
8282

8383
/// @brief Allocate and construct an object.
8484
///

modules/cargo/include/cargo/detail/expected.h

+42-39
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,9 @@ namespace detail {
4343

4444
// Trait for checking if a type is a cargo::expected
4545
template <class T>
46-
struct is_expected_impl : std::false_type {};
46+
static constexpr bool is_expected_v = false;
4747
template <class T, class E>
48-
struct is_expected_impl<expected<T, E>> : std::true_type {};
49-
template <class T>
50-
using is_expected = is_expected_impl<std::decay_t<T>>;
48+
static constexpr bool is_expected_v<expected<T, E>> = true;
5149

5250
template <class T, class E, class U>
5351
using expected_enable_forward_value =
@@ -69,16 +67,13 @@ using expected_enable_from_other =
6967
!std::is_convertible_v<const expected<U, G> &, T> &&
7068
!std::is_convertible_v<const expected<U, G> &&, T>>;
7169

72-
template <class T, class U>
73-
using is_void_or = std::conditional_t<std::is_void_v<T>, std::true_type, U>;
74-
7570
template <class T>
76-
using is_copy_constructible_or_void =
77-
is_void_or<T, std::is_copy_constructible<T>>;
71+
static constexpr bool is_copy_constructible_or_void_v =
72+
std::is_void_v<T> || std::is_copy_constructible_v<T>;
7873

7974
template <class T>
80-
using is_move_constructible_or_void =
81-
is_void_or<T, std::is_move_constructible<T>>;
75+
static constexpr bool is_move_constructible_or_void_v =
76+
std::is_void_v<T> || std::is_move_constructible_v<T>;
8277

8378
struct no_init_t {};
8479
static constexpr no_init_t no_init{};
@@ -95,9 +90,11 @@ struct expected_storage_base {
9590
constexpr expected_storage_base() : m_val(T{}), m_has_val(true) {}
9691
constexpr expected_storage_base(no_init_t) : m_no_init(), m_has_val(false) {}
9792

93+
// NOLINTBEGIN(modernize-type-traits)
9894
template <
9995
class... Args,
10096
std::enable_if_t<std::is_constructible_v<T, Args &&...>> * = nullptr>
97+
// NOLINTEND(modernize-type-traits)
10198
constexpr expected_storage_base(in_place_t, Args &&...args)
10299
: m_val(std::forward<Args>(args)...), m_has_val(true) {}
103100

@@ -143,9 +140,11 @@ struct expected_storage_base<T, E, true, true> {
143140
constexpr expected_storage_base() : m_val(T{}), m_has_val(true) {}
144141
constexpr expected_storage_base(no_init_t) : m_no_init(), m_has_val(false) {}
145142

143+
// NOLINTBEGIN(modernize-type-traits)
146144
template <
147145
class... Args,
148146
std::enable_if_t<std::is_constructible_v<T, Args &&...>> * = nullptr>
147+
// NOLINTEND(modernize-type-traits)
149148
constexpr expected_storage_base(in_place_t, Args &&...args)
150149
: m_val(std::forward<Args>(args)...), m_has_val(true) {}
151150

@@ -184,9 +183,11 @@ struct expected_storage_base<T, E, true, false> {
184183
constexpr expected_storage_base() : m_val(T{}), m_has_val(true) {}
185184
constexpr expected_storage_base(no_init_t) : m_no_init(), m_has_val(false) {}
186185

186+
// NOLINTBEGIN(modernize-type-traits)
187187
template <
188188
class... Args,
189189
std::enable_if_t<std::is_constructible_v<T, Args &&...>> * = nullptr>
190+
// NOLINTEND(modernize-type-traits)
190191
constexpr expected_storage_base(in_place_t, Args &&...args)
191192
: m_val(std::forward<Args>(args)...), m_has_val(true) {}
192193

@@ -230,9 +231,11 @@ struct expected_storage_base<T, E, false, true> {
230231
constexpr expected_storage_base() : m_val(T{}), m_has_val(true) {}
231232
constexpr expected_storage_base(no_init_t) : m_no_init(), m_has_val(false) {}
232233

234+
// NOLINTBEGIN(modernize-type-traits)
233235
template <
234236
class... Args,
235237
std::enable_if_t<std::is_constructible_v<T, Args &&...>> * = nullptr>
238+
// NOLINTEND(modernize-type-traits)
236239
constexpr expected_storage_base(in_place_t, Args &&...args)
237240
: m_val(std::forward<Args>(args)...), m_has_val(true) {}
238241

@@ -342,19 +345,21 @@ struct expected_operations_base : expected_storage_base<T, E> {
342345

343346
template <class... Args>
344347
void construct(Args &&...args) noexcept {
345-
new (std::addressof(this->m_val)) T(std::forward<Args>(args)...);
348+
new (static_cast<void *>(std::addressof(this->m_val)))
349+
T(std::forward<Args>(args)...);
346350
this->m_has_val = true;
347351
}
348352

349353
template <class Rhs>
350354
void construct_with(Rhs &&rhs) noexcept {
351-
new (std::addressof(this->m_val)) T(std::forward<Rhs>(rhs).get());
355+
new (static_cast<void *>(std::addressof(this->m_val)))
356+
T(std::forward<Rhs>(rhs).get());
352357
this->m_has_val = true;
353358
}
354359

355360
template <class... Args>
356361
void construct_error(Args &&...args) noexcept {
357-
new (std::addressof(this->m_unexpect))
362+
new (static_cast<void *>(std::addressof(this->m_unexpect)))
358363
unexpected<E>(std::forward<Args>(args)...);
359364
this->m_has_val = false;
360365
}
@@ -429,7 +434,7 @@ struct expected_operations_base<void, E> : expected_storage_base<void, E> {
429434

430435
template <class... Args>
431436
void construct_error(Args &&...args) noexcept {
432-
new (std::addressof(this->m_unexpect))
437+
new (static_cast<void *>(std::addressof(this->m_unexpect)))
433438
unexpected<E>(std::forward<Args>(args)...);
434439
this->m_has_val = false;
435440
}
@@ -463,9 +468,9 @@ struct expected_operations_base<void, E> : expected_storage_base<void, E> {
463468
// This class manages conditionally having a trivial copy constructor
464469
// This specialization is for when T and E are trivially copy constructible
465470
template <class T, class E,
466-
bool =
467-
is_void_or<T, std::is_trivially_copy_constructible<T>>::value &&
468-
std::is_trivially_copy_constructible_v<E>>
471+
bool = (std::is_void_v<T> ||
472+
std::is_trivially_copy_constructible_v<T>) &&
473+
std::is_trivially_copy_constructible_v<E>>
469474
struct expected_copy_base : expected_operations_base<T, E> {
470475
using expected_operations_base<T, E>::expected_operations_base;
471476
};
@@ -492,9 +497,9 @@ struct expected_copy_base<T, E, false> : expected_operations_base<T, E> {
492497

493498
// This class manages conditionally having a trivial move constructor
494499
template <class T, class E,
495-
bool =
496-
is_void_or<T, std::is_trivially_move_constructible<T>>::value &&
497-
std::is_trivially_move_constructible_v<E>>
500+
bool = (std::is_void_v<T> ||
501+
std::is_trivially_move_constructible_v<T>) &&
502+
std::is_trivially_move_constructible_v<E>>
498503
struct expected_move_base : expected_copy_base<T, E> {
499504
using expected_copy_base<T, E>::expected_copy_base;
500505
};
@@ -519,15 +524,14 @@ struct expected_move_base<T, E, false> : expected_copy_base<T, E> {
519524
};
520525

521526
// This class manages conditionally having a trivial copy assignment operator
522-
template <
523-
class T, class E,
524-
bool =
525-
is_void_or<T, conjunction<std::is_trivially_copy_assignable<T>,
526-
std::is_trivially_copy_constructible<T>,
527-
std::is_trivially_destructible<T>>>::value &&
528-
std::is_trivially_copy_assignable_v<E> &&
529-
std::is_trivially_copy_constructible_v<E> &&
530-
std::is_trivially_destructible_v<E>>
527+
template <class T, class E,
528+
bool = (std::is_void_v<T> ||
529+
(std::is_trivially_copy_assignable_v<T> &&
530+
std::is_trivially_copy_constructible_v<T> &&
531+
std::is_trivially_destructible_v<T>)) &&
532+
std::is_trivially_copy_assignable_v<E> &&
533+
std::is_trivially_copy_constructible_v<E> &&
534+
std::is_trivially_destructible_v<E>>
531535
struct expected_copy_assign_base : expected_move_base<T, E> {
532536
using expected_move_base<T, E>::expected_move_base;
533537
};
@@ -549,15 +553,14 @@ struct expected_copy_assign_base<T, E, false> : expected_move_base<T, E> {
549553
};
550554

551555
// This class manages conditionally having a trivial move assignment operator
552-
template <
553-
class T, class E,
554-
bool = is_void_or<
555-
T, conjunction<std::is_trivially_destructible<T>,
556-
std::is_trivially_move_constructible<T>,
557-
std::is_trivially_move_assignable<T>>>::value &&
558-
std::is_trivially_destructible_v<E> &&
559-
std::is_trivially_move_constructible_v<E> &&
560-
std::is_trivially_move_assignable_v<E>>
556+
template <class T, class E,
557+
bool = (std::is_void_v<T> ||
558+
(std::is_trivially_destructible_v<T> &&
559+
std::is_trivially_move_constructible_v<T> &&
560+
std::is_trivially_move_assignable_v<T>)) &&
561+
std::is_trivially_destructible_v<E> &&
562+
std::is_trivially_move_constructible_v<E> &&
563+
std::is_trivially_move_assignable_v<E>>
561564
struct expected_move_assign_base : expected_copy_assign_base<T, E> {
562565
using expected_copy_assign_base<T, E>::expected_copy_assign_base;
563566
};

0 commit comments

Comments
 (0)