a/util: Resolve a bothersome clang-tidy complaint in iterators.

This commit is contained in:
Ryan Pavlik 2022-04-13 14:01:26 -05:00 committed by Jakob Bornecrantz
parent 290fafa4f7
commit 1fb6270194
3 changed files with 33 additions and 41 deletions

View file

@ -15,6 +15,7 @@ Checks: |
-misc-static-assert,-cert-dcl03-c,
-bugprone-macro-parentheses,
-bugprone-reserved-identifier,-cert-dcl37-c,-cert-dcl51-cpp,
-cert-dcl21-cpp,
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
-clang-analyzer-security.insecureAPI.strcpy,
-clang-diagnostic-missing-braces,
@ -26,6 +27,9 @@ Checks: |
-readability-redundant-access-specifiers,
-readability-uppercase-literal-suffix,
-readability-identifier-length,
# Notes:
# misc-static-assert turns our assert(false) in failure/bad cases into static_asserts. We should revise them, but not like that.
# cert-dcl21-cpp is an overkill "recommendation" to return a special type from iterator post-increment
WarningsAsErrors: ''
HeaderFilterRegex: 'src/xrt/.*'
AnalyzeTemporaryDtors: false

View file

@ -84,16 +84,28 @@ namespace detail {
operator++();
//! Post-increment: return a copy of initial state after incrementing self
// NOLINTNEXTLINE(cert-dcl21-cpp)
Self
operator++(int);
operator++(int) &
{
Self tmp = *this;
this->increment_n(1);
return tmp;
}
//! Pre-decrement: Subtract, then return self.
Self &
operator--();
//! Post-decrement: return a copy of initial state after decrementing self
// NOLINTNEXTLINE(cert-dcl21-cpp)
Self
operator--(int);
operator--(int) &
{
Self tmp = *this;
this->decrement_n(1);
return tmp;
}
// Use the base class implementation of subtracting one iterator from another
using base::operator-;
@ -140,7 +152,7 @@ namespace detail {
inline typename HistoryBufConstIterator<T, MaxSize>::reference
HistoryBufConstIterator<T, MaxSize>::operator*() const
{
auto ptr = container_->get_at_index(base::index());
auto *ptr = container_->get_at_index(base::index());
if (ptr == nullptr) {
throw std::out_of_range("Iterator index out of range");
}
@ -162,15 +174,6 @@ namespace detail {
return *this;
}
template <typename T, size_t MaxSize>
inline HistoryBufConstIterator<T, MaxSize>
HistoryBufConstIterator<T, MaxSize>::operator++(int)
{
HistoryBufConstIterator tmp = *this;
this->increment_n(1);
return tmp;
}
template <typename T, size_t MaxSize>
inline HistoryBufConstIterator<T, MaxSize> &
HistoryBufConstIterator<T, MaxSize>::operator--()
@ -179,15 +182,6 @@ namespace detail {
return *this;
}
template <typename T, size_t MaxSize>
inline HistoryBufConstIterator<T, MaxSize>
HistoryBufConstIterator<T, MaxSize>::operator--(int)
{
Self tmp = *this;
this->decrement_n(1);
return tmp;
}
template <typename T, size_t MaxSize>
inline HistoryBufConstIterator<T, MaxSize> &
HistoryBufConstIterator<T, MaxSize>::operator+=(std::ptrdiff_t n) noexcept

View file

@ -80,16 +80,28 @@ namespace detail {
operator++();
//! Post-increment: return a copy of initial state after incrementing self
// NOLINTNEXTLINE(cert-dcl21-cpp)
Self
operator++(int);
operator++(int)
{
Self tmp = *this;
this->increment_n(1);
return tmp;
}
//! Pre-decrement: Subtract, then return self.
Self &
operator--();
//! Post-decrement: return a copy of initial state after decrementing self
// NOLINTNEXTLINE(cert-dcl21-cpp)
Self
operator--(int);
operator--(int)
{
Self tmp = *this;
this->decrement_n(1);
return tmp;
}
// Use the base class implementation of subtracting one iterator from another
using base::operator-;
@ -157,15 +169,6 @@ namespace detail {
return *this;
}
template <typename T, size_t MaxSize>
inline HistoryBufIterator<T, MaxSize>
HistoryBufIterator<T, MaxSize>::operator++(int)
{
HistoryBufIterator tmp = *this;
this->increment_n(1);
return tmp;
}
template <typename T, size_t MaxSize>
inline HistoryBufIterator<T, MaxSize> &
HistoryBufIterator<T, MaxSize>::operator--()
@ -174,15 +177,6 @@ namespace detail {
return *this;
}
template <typename T, size_t MaxSize>
inline HistoryBufIterator<T, MaxSize>
HistoryBufIterator<T, MaxSize>::operator--(int)
{
Self tmp = *this;
this->decrement_n(1);
return tmp;
}
template <typename T, size_t MaxSize>
inline HistoryBufIterator<T, MaxSize> &
HistoryBufIterator<T, MaxSize>::operator+=(std::ptrdiff_t n) noexcept