Skip to content

Commit f069696

Browse files
authored
Merge pull request #2275 from eclipse-iceoryx/iox-2274-fix-clang-tidy-18-warnings
iox-#2274 Fix clang-tidy-18 warnings
2 parents e880982 + b9ab7ee commit f069696

File tree

102 files changed

+377
-370
lines changed

Some content is hidden

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

102 files changed

+377
-370
lines changed

.clang-tidy

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ concurrency-*,
2121
performance-*,
2222
hicpp-*,
2323
24-
-cppcoreguidelines-avoid-do-while
24+
-cppcoreguidelines-avoid-do-while,
2525
-cppcoreguidelines-non-private-member-variables-in-classes,
2626
2727
-hicpp-named-parameter,
@@ -30,13 +30,16 @@ hicpp-*,
3030
-readability-identifier-length,
3131
-readability-redundant-access-specifiers,
3232
-readability-redundant-declaration,
33+
-readability-redundant-inline-specifier,
3334
-readability-static-accessed-through-instance,
3435
3536
-readability-identifier-naming,
3637
-readability-use-anyofallof,
3738
-readability-named-parameter,
3839
39-
-cert-dcl21-cpp
40+
-performance-avoid-endl,
41+
42+
-cert-dcl21-cpp,
4043
4144
'
4245

@@ -98,6 +101,9 @@ hicpp-*,
98101
# // in cpp file
99102
# void bar(Foo& foo) {...}
100103
#
104+
# * rule: readability-redundant-inline-specifier
105+
# justicfication: there are many false positives
106+
#
101107
# * rule: readability-use-anyofallof
102108
# justification: requires C++20 and std::ranges but we only use C++17
103109
#
@@ -132,6 +138,12 @@ hicpp-*,
132138
# Tag1 tag;
133139
# foo(tag); // calls (1)
134140
#
141+
# * rule: performance-avoid-endl
142+
# justification: 'iostream' is only used in a few places where the logger either cannot be used, likt the platform layer, or
143+
# we want to print immediatelly something on the screen like the command line parser or the examples. In this
144+
# cases we would immediatelly after the '\n' calls 'std::flush'. Therefore we keep using 'std::endl' in this
145+
# limited places.
146+
#
135147
## Those warnings should be enabled
136148
## They are disabled since they require a heavy API refactoring and when we enable it we clutter the code with // NOLINT comments
137149
# -bugprone-easily-swappable-parameters

.clang-tidy-diff-scans.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
./iceoryx_hoofs/**/*
22

3-
./iceoryx_posh/include/iox/**/*
4-
./iceoryx_posh/source/posh/**/*
3+
./iceoryx_posh/experimental/include/iox/**/*
4+
./iceoryx_posh/experimental/source/**/*
55

66
# IMPORTANT:
77
# after the first # everything is considered a comment, add new files and

doc/website/release-notes/iceoryx-unreleased.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@
217217
- Split `iceoryx_hoofs` into logical modules [#1391](https://github.com/eclipse-iceoryx/iceoryx/issues/1391)
218218
- Create a flat include structure for `iceoryx_hoofs` [#1593](https://github.com/eclipse-iceoryx/iceoryx/issues/1593)
219219
- Handle 'strerror_r' idiosyncrasies in the platform layer [#1616](https://github.com/eclipse-iceoryx/iceoryx/issues/1616)
220+
- Fix new clang-tidy-18 warnings [#2274](https://github.com/eclipse-iceoryx/iceoryx/issues/2274)
220221

221222
**Workflow:**
222223

iceoryx_hoofs/buffer/include/iox/detail/stack.inl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ inline stack<T, Capacity>& stack<T, Capacity>::copy(const stack& rhs) noexcept
4747
}
4848

4949
template <typename T, uint64_t Capacity>
50+
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved) false positive, the elements are moved
5051
inline stack<T, Capacity>& stack<T, Capacity>::move(stack&& rhs) noexcept
5152
{
5253
uint64_t i{0};

iceoryx_hoofs/cli/include/iox/cli/arguments.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace cli
3737
class Arguments
3838
{
3939
public:
40-
enum class Error
40+
enum class Error : uint8_t
4141
{
4242
UNABLE_TO_CONVERT_VALUE,
4343
NO_SUCH_VALUE

iceoryx_hoofs/concurrent/buffer/include/iox/detail/mpmc_lockfree_queue/mpmc_lockfree_queue.inl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ inline bool MpmcLockFreeQueue<ElementType, Capacity>::tryPush(const ElementType&
5959
}
6060

6161
template <typename ElementType, uint64_t Capacity>
62+
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved) perfect forwarding is used
6263
inline bool MpmcLockFreeQueue<ElementType, Capacity>::tryPush(ElementType&& value) noexcept
6364
{
6465
uint64_t index{0};
@@ -120,6 +121,7 @@ inline iox::optional<ElementType> MpmcLockFreeQueue<ElementType, Capacity>::push
120121
}
121122

122123
template <typename ElementType, uint64_t Capacity>
124+
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved) perfect forwarding is used
123125
inline iox::optional<ElementType> MpmcLockFreeQueue<ElementType, Capacity>::push(ElementType&& value) noexcept
124126
{
125127
return pushImpl(std::forward<ElementType>(value));

iceoryx_hoofs/concurrent/buffer/include/iox/detail/mpmc_lockfree_queue/mpmc_resizeable_lockfree_queue.inl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ inline bool MpmcResizeableLockFreeQueue<ElementType, MaxCapacity>::setCapacity(c
5353

5454
template <typename ElementType, uint64_t MaxCapacity>
5555
template <typename Function, typename>
56-
inline bool MpmcResizeableLockFreeQueue<ElementType, MaxCapacity>::setCapacity(const uint64_t newCapacity,
57-
Function&& removeHandler) noexcept
56+
inline bool MpmcResizeableLockFreeQueue<ElementType, MaxCapacity>::setCapacity(
57+
const uint64_t newCapacity,
58+
// NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward) false positive, this is used as a universal reference
59+
Function&& removeHandler) noexcept
5860
{
5961
if (newCapacity > MAX_CAPACITY)
6062
{
@@ -121,9 +123,10 @@ MpmcResizeableLockFreeQueue<ElementType, MaxCapacity>::increaseCapacity(const ui
121123

122124
template <typename ElementType, uint64_t MaxCapacity>
123125
template <typename Function>
124-
inline uint64_t
125-
MpmcResizeableLockFreeQueue<ElementType, MaxCapacity>::decreaseCapacity(const uint64_t toDecrease,
126-
Function&& removeHandler) noexcept
126+
inline uint64_t MpmcResizeableLockFreeQueue<ElementType, MaxCapacity>::decreaseCapacity(
127+
const uint64_t toDecrease,
128+
// NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward) false positive, this is used as a universal reference
129+
Function&& removeHandler) noexcept
127130
{
128131
uint64_t decreased = 0U;
129132
while (decreased < toDecrease)
@@ -191,6 +194,7 @@ iox::optional<ElementType> inline MpmcResizeableLockFreeQueue<ElementType, MaxCa
191194

192195
template <typename ElementType, uint64_t MaxCapacity>
193196
inline iox::optional<ElementType>
197+
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved) perfect forwarding is used
194198
MpmcResizeableLockFreeQueue<ElementType, MaxCapacity>::push(ElementType&& value) noexcept
195199
{
196200
return pushImpl(std::forward<ElementType>(value));

iceoryx_hoofs/container/include/iox/detail/forward_list.inl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ inline bool forward_list<T, Capacity>::push_front(const T& data) noexcept
354354
}
355355

356356
template <typename T, uint64_t Capacity>
357+
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved) perfect forwarding is used
357358
inline bool forward_list<T, Capacity>::push_front(T&& data) noexcept
358359
{
359360
auto sizeBeforePush = m_size;
@@ -380,8 +381,10 @@ inline typename forward_list<T, Capacity>::iterator forward_list<T, Capacity>::i
380381
}
381382

382383
template <typename T, uint64_t Capacity>
383-
inline typename forward_list<T, Capacity>::iterator forward_list<T, Capacity>::insert_after(const_iterator citer,
384-
T&& data) noexcept
384+
inline typename forward_list<T, Capacity>::iterator forward_list<T, Capacity>::insert_after(
385+
const_iterator citer,
386+
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved) perfect forwarding is used
387+
T&& data) noexcept
385388
{
386389
return emplace_after(citer, std::forward<T>(data));
387390
}

iceoryx_hoofs/container/include/iox/detail/list.inl

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,28 @@
2424

2525
namespace iox
2626
{
27-
/// @NOLINTJUSTIFICATION m_data fields are explicitly initialized whenever a new element is inserted
28-
/// into the list
29-
/// @NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init,hicpp-member-init)
27+
// NOLINTJUSTIFICATION m_data fields are explicitly initialized whenever a new element is inserted
28+
// into the list
29+
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init,hicpp-member-init)
3030
template <typename T, uint64_t Capacity>
3131
inline list<T, Capacity>::list() noexcept
3232
{
3333
init();
3434
}
3535

36-
/// @NOLINTJUSTIFICATION m_data fields are explicitly initialized whenever a new element is inserted
37-
/// into the list
38-
/// @NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init,hicpp-member-init)
36+
// NOLINTJUSTIFICATION m_data fields are explicitly initialized whenever a new element is inserted
37+
// into the list
38+
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init,hicpp-member-init)
3939
template <typename T, uint64_t Capacity>
4040
inline list<T, Capacity>::list(const list& rhs) noexcept
4141
{
4242
init();
4343
*this = rhs;
4444
}
4545

46-
/// @NOLINTJUSTIFICATION m_data fields are explicitly initialized whenever a new element is inserted
47-
/// into the list
48-
/// @NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init,hicpp-member-init)
46+
// NOLINTJUSTIFICATION m_data fields are explicitly initialized whenever a new element is inserted
47+
// into the list
48+
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init,hicpp-member-init)
4949
template <typename T, uint64_t Capacity>
5050
inline list<T, Capacity>::list(list&& rhs) noexcept
5151
{
@@ -371,6 +371,7 @@ inline bool list<T, Capacity>::push_front(const T& data) noexcept
371371
}
372372

373373
template <typename T, uint64_t Capacity>
374+
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved) perfect forwarding is used
374375
inline bool list<T, Capacity>::push_front(T&& data) noexcept
375376
{
376377
auto sizeBeforePush = m_size;
@@ -394,6 +395,7 @@ inline bool list<T, Capacity>::push_back(const T& data) noexcept
394395
}
395396

396397
template <typename T, uint64_t Capacity>
398+
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved) perfect forwarding is used
397399
inline bool list<T, Capacity>::push_back(T&& data) noexcept
398400
{
399401
auto sizeBeforePush = m_size;
@@ -427,6 +429,7 @@ inline typename list<T, Capacity>::iterator list<T, Capacity>::insert(const_iter
427429
}
428430

429431
template <typename T, uint64_t Capacity>
432+
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved) perfect forwarding is used
430433
inline typename list<T, Capacity>::iterator list<T, Capacity>::insert(const_iterator citer, T&& data) noexcept
431434
{
432435
return emplace(citer, std::forward<T>(data));
@@ -466,9 +469,9 @@ template <bool IsConstIterator>
466469
inline typename list<T, Capacity>::template IteratorBase<IsConstIterator>&
467470
list<T, Capacity>::IteratorBase<IsConstIterator>::operator=(const IteratorBase<false>& rhs) noexcept
468471
{
469-
/// @NOLINTJUSTIFICATION ensure that this and rhs are not the same object without taking the type into account
470-
/// required since it is possible to assign a non const iterator to a const iterator
471-
/// @NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
472+
// NOLINTJUSTIFICATION ensure that this and rhs are not the same object without taking the type into account
473+
// required since it is possible to assign a non const iterator to a const iterator
474+
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
472475
if (reinterpret_cast<const void*>(this) != reinterpret_cast<const void*>(&rhs))
473476
{
474477
m_list = rhs.m_list;
@@ -594,9 +597,9 @@ inline const typename list<T, Capacity>::size_type& list<T, Capacity>::getPrevId
594597
template <typename T, uint64_t Capacity>
595598
inline typename list<T, Capacity>::size_type& list<T, Capacity>::getPrevIdx(const size_type idx) noexcept
596599
{
597-
/// @NOLINTJUSTIFICATION const_cast avoids code duplication, is safe since the constness of the return value is
598-
/// restored
599-
/// @NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
600+
// NOLINTJUSTIFICATION const_cast avoids code duplication, is safe since the constness of the return value is
601+
// restored
602+
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
600603
return const_cast<size_type&>(const_cast<const list<T, Capacity>*>(this)->getPrevIdx(idx));
601604
}
602605

@@ -608,9 +611,9 @@ inline const typename list<T, Capacity>::size_type& list<T, Capacity>::getNextId
608611
template <typename T, uint64_t Capacity>
609612
inline typename list<T, Capacity>::size_type& list<T, Capacity>::getNextIdx(const size_type idx) noexcept
610613
{
611-
/// @NOLINTJUSTIFICATION const_cast avoids code duplication, is safe since the constness of the return value is
612-
/// restored
613-
/// @NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
614+
// NOLINTJUSTIFICATION const_cast avoids code duplication, is safe since the constness of the return value is
615+
// restored
616+
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
614617
return const_cast<size_type&>(const_cast<const list<T, Capacity>*>(this)->getNextIdx(idx));
615618
}
616619

@@ -656,17 +659,17 @@ inline const T* list<T, Capacity>::getDataPtrFromIdx(const size_type idx) const
656659
{
657660
IOX_ENFORCE(isValidElementIdx(idx), "invalid list element");
658661

659-
/// @NOLINTJUSTIFICATION provide type safe access to the encapsulated untyped m_data array
660-
/// @NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
662+
// NOLINTJUSTIFICATION provide type safe access to the encapsulated untyped m_data array
663+
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
661664
return &(reinterpret_cast<const T*>(&m_data)[idx]);
662665
}
663666

664667
template <typename T, uint64_t Capacity>
665668
inline T* list<T, Capacity>::getDataPtrFromIdx(const size_type idx) noexcept
666669
{
667-
/// @NOLINTJUSTIFICATION const_cast avoids code duplication, is safe since the constness of the return value is
668-
/// restored
669-
/// @NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
670+
// NOLINTJUSTIFICATION const_cast avoids code duplication, is safe since the constness of the return value is
671+
// restored
672+
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
670673
return const_cast<T*>(const_cast<const list<T, Capacity>*>(this)->getDataPtrFromIdx(idx));
671674
}
672675

iceoryx_hoofs/container/include/iox/detail/vector.inl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ inline bool vector<T, Capacity>::push_back(const T& value) noexcept
247247
}
248248

249249
template <typename T, uint64_t Capacity>
250+
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved) perfect forwarding is used
250251
inline bool vector<T, Capacity>::push_back(T&& value) noexcept
251252
{
252253
// AXIVION Next Construct AutosarC++19_03-A18.9.2: we use idiomatic perfect forwarding

0 commit comments

Comments
 (0)