Enable clang-tidy bugprone-misplaced-widening-cast check

This commit is contained in:
Chris Thrasher 2024-06-17 13:01:00 -06:00
parent 5580720ae0
commit 9f88867d90
4 changed files with 4 additions and 5 deletions

View File

@ -15,7 +15,6 @@ Checks: >
-bugprone-exception-escape, -bugprone-exception-escape,
-bugprone-implicit-widening-of-multiplication-result, -bugprone-implicit-widening-of-multiplication-result,
-bugprone-integer-division, -bugprone-integer-division,
-bugprone-misplaced-widening-cast,
-bugprone-narrowing-conversions, -bugprone-narrowing-conversions,
-bugprone-signed-char-misuse, -bugprone-signed-char-misuse,
-bugprone-string-integer-assignment, -bugprone-string-integer-assignment,

View File

@ -541,7 +541,7 @@ void Image::flipVertically()
{ {
if (!m_pixels.empty()) if (!m_pixels.empty())
{ {
const auto rowSize = static_cast<std::vector<std::uint8_t>::iterator::difference_type>(m_size.x * 4); const auto rowSize = static_cast<std::vector<std::uint8_t>::iterator::difference_type>(m_size.x) * 4;
auto top = m_pixels.begin(); auto top = m_pixels.begin();
auto bottom = m_pixels.end() - rowSize; auto bottom = m_pixels.end() - rowSize;

View File

@ -412,10 +412,10 @@ Image Texture::copyToImage() const
if (m_pixelsFlipped) if (m_pixelsFlipped)
{ {
// Flip the texture vertically // Flip the texture vertically
const auto stride = static_cast<std::ptrdiff_t>(m_size.x * 4); const auto stride = static_cast<std::ptrdiff_t>(m_size.x) * 4;
auto currentRowIterator = pixels.begin(); auto currentRowIterator = pixels.begin();
auto nextRowIterator = pixels.begin() + stride; auto nextRowIterator = pixels.begin() + stride;
auto reverseRowIterator = pixels.begin() + (stride * static_cast<std::ptrdiff_t>(m_size.y - 1)); auto reverseRowIterator = pixels.begin() + (stride * (static_cast<std::ptrdiff_t>(m_size.y) - 1));
for (unsigned int i = 0; i < m_size.y / 2; ++i) for (unsigned int i = 0; i < m_size.y / 2; ++i)
{ {
std::swap_ranges(currentRowIterator, nextRowIterator, reverseRowIterator); std::swap_ranges(currentRowIterator, nextRowIterator, reverseRowIterator);

View File

@ -317,7 +317,7 @@ void pushEvent(const sf::Event& event)
TouchSlot& atSlot(int idx) TouchSlot& atSlot(int idx)
{ {
if (idx >= static_cast<int>(touchSlots.size())) if (idx >= static_cast<int>(touchSlots.size()))
touchSlots.resize(static_cast<std::size_t>(idx + 1)); touchSlots.resize(static_cast<std::size_t>(idx) + 1);
return touchSlots.at(static_cast<std::size_t>(idx)); return touchSlots.at(static_cast<std::size_t>(idx));
} }