From 04ec11656fd22ef95bf71214b87487ad2f6e1e9e Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Sat, 16 Mar 2024 02:35:30 +0300 Subject: [PATCH 1/8] CI: LLVM18 jobs --- .github/workflows/CI-linux.yml | 10 +++++++--- .github/workflows/CI.yml | 13 +++++++------ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/CI-linux.yml b/.github/workflows/CI-linux.yml index 628a88230..25922e918 100644 --- a/.github/workflows/CI-linux.yml +++ b/.github/workflows/CI-linux.yml @@ -80,7 +80,11 @@ jobs: APT::Get::Fix-Missing "true"; EOT rm -rf /etc/apt/sources.list* - if [ "${{ inputs.distro }}" = "debian:trixie-slim" ]; then + if [ "${{ inputs.distro }}" = "debian:unstable-slim" ]; then + tee /etc/apt/sources.list > /dev/null < /dev/null < /dev/null + echo 'deb http://download.opensuse.org/repositories/graphics:/darktable:/master/Debian_Unstable/ /' | tee /etc/apt/sources.list + curl -fsSL https://download.opensuse.org/repositories/graphics:darktable:master/Debian_Unstable/Release.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/graphics_darktable_master.gpg > /dev/null apt-get update eatmydata apt-get install rawspeed-clang-tidy-module fi diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 357656642..61702545f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -32,7 +32,7 @@ jobs: os: [ linux ] compiler: - { distro: "debian:trixie-slim", family: GNU, version: 13, CC: gcc-13, CXX: g++-13 } - - { distro: "debian:trixie-slim", family: LLVM, version: 17, CC: clang-17, CXX: clang++-17 } + - { distro: "debian:unstable-slim", family: LLVM, version: 18, CC: clang-18, CXX: clang++-18 } flavor: [ ReleaseWithAsserts, Release ] uses: ./.github/workflows/CI-linux.yml with: @@ -54,6 +54,7 @@ jobs: os: [ linux ] compiler: - { distro: "debian:bookworm-slim", family: GNU, version: 12, CC: gcc-12, CXX: g++-12 } + - { distro: "debian:trixie-slim", family: LLVM, version: 17, CC: clang-17, CXX: clang++-17 } - { distro: "debian:bookworm-slim", family: LLVM, version: 16, CC: clang-16, CXX: clang++-16 } - { distro: "debian:bookworm-slim", family: LLVM, version: 15, CC: clang-15, CXX: clang++-15 } flavor: [ ReleaseWithAsserts, Release ] @@ -74,16 +75,16 @@ jobs: matrix: include: - os: linux - compiler: { distro: "debian:trixie-slim", family: LLVM, version: 17, CC: clang-17, CXX: clang++-17, CLANG_TIDY: clang-tidy-17 } + compiler: { distro: "debian:unstable-slim", family: LLVM, version: 18, CC: clang-18, CXX: clang++-18, CLANG_TIDY: clang-tidy-18 } flavor: ClangTidy - os: linux - compiler: { distro: "debian:trixie-slim", family: LLVM, version: 17, CC: clang-17, CXX: clang++-17 } + compiler: { distro: "debian:unstable-slim", family: LLVM, version: 18, CC: clang-18, CXX: clang++-18 } flavor: ClangStaticAnalysis - os: linux - compiler: { distro: "debian:trixie-slim", family: LLVM, version: 17, CC: clang-17, CXX: clang++-17 } + compiler: { distro: "debian:unstable-slim", family: LLVM, version: 18, CC: clang-18, CXX: clang++-18 } flavor: ClangCTUStaticAnalysis - os: linux - compiler: { distro: "debian:trixie-slim", family: LLVM, version: 17, CC: clang-17, CXX: clang++-17 } + compiler: { distro: "debian:unstable-slim", family: LLVM, version: 18, CC: clang-18, CXX: clang++-18 } flavor: CodeQLAnalysis uses: ./.github/workflows/CI-linux.yml with: @@ -125,7 +126,7 @@ jobs: matrix: include: - os: linux - compiler: { distro: "debian:trixie-slim", family: LLVM, version: 17, CC: clang-17, CXX: clang++-17 } + compiler: { distro: "debian:unstable-slim", family: LLVM, version: 18, CC: clang-18, CXX: clang++-18 } flavor: SonarCloudStaticAnalysis uses: ./.github/workflows/CI-linux.yml with: From 6cad7d88f5d349a3fe4e3dcec1df5e0b9e8a70a8 Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Sat, 16 Mar 2024 02:39:48 +0300 Subject: [PATCH 2/8] Apply clang-format-18 --- src/librawspeed/adt/Array2DRef.h | 4 +-- src/librawspeed/adt/CroppedArray1DRef.h | 4 +-- test/librawspeed/adt/BitTest.cpp | 5 ++-- test/librawspeed/codes/HuffmanCodeTest.cpp | 33 ++++++++++++---------- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/librawspeed/adt/Array2DRef.h b/src/librawspeed/adt/Array2DRef.h index af5110b49..d46fc2232 100644 --- a/src/librawspeed/adt/Array2DRef.h +++ b/src/librawspeed/adt/Array2DRef.h @@ -110,8 +110,8 @@ template class Array2DRef final { // CTAD deduction guide template -explicit Array2DRef(Array1DRef data, int width, int height, int pitch) - -> Array2DRef; +explicit Array2DRef(Array1DRef data, int width, int height, + int pitch) -> Array2DRef; // CTAD deduction guide template diff --git a/src/librawspeed/adt/CroppedArray1DRef.h b/src/librawspeed/adt/CroppedArray1DRef.h index 817251059..7e7e7b244 100644 --- a/src/librawspeed/adt/CroppedArray1DRef.h +++ b/src/librawspeed/adt/CroppedArray1DRef.h @@ -86,8 +86,8 @@ template class CroppedArray1DRef final { // CTAD deduction guide template -CroppedArray1DRef(Array1DRef base, int offset, int numElts) - -> CroppedArray1DRef; +CroppedArray1DRef(Array1DRef base, int offset, + int numElts) -> CroppedArray1DRef; template __attribute__((always_inline)) inline void diff --git a/test/librawspeed/adt/BitTest.cpp b/test/librawspeed/adt/BitTest.cpp index 79e105421..1d3283b0c 100644 --- a/test/librawspeed/adt/BitTest.cpp +++ b/test/librawspeed/adt/BitTest.cpp @@ -117,8 +117,9 @@ TEST(ClampBitsDeathTest, Only16Bit) { TEST(ClampBitsUnsignedDeathTest, NoNopClamps) { #ifndef NDEBUG - ASSERT_DEATH({ ASSERT_EQ(clampBits(0, 16), 0); }, - "bitwidth\\(\\) > nBits"); + ASSERT_DEATH( + { ASSERT_EQ(clampBits(0, 16), 0); }, + "bitwidth\\(\\) > nBits"); #endif } diff --git a/test/librawspeed/codes/HuffmanCodeTest.cpp b/test/librawspeed/codes/HuffmanCodeTest.cpp index 932ba6991..4500b79f8 100644 --- a/test/librawspeed/codes/HuffmanCodeTest.cpp +++ b/test/librawspeed/codes/HuffmanCodeTest.cpp @@ -87,14 +87,16 @@ TEST(HuffmanCodeCodeSymbolTest, Equality) { #ifndef NDEBUG TEST(CodeSymbolDeathTest, CodeSymbolLength) { - ASSERT_DEATH({ HuffmanCode::CodeSymbol(0, 0); }, - "code_len > 0"); - ASSERT_DEATH({ HuffmanCode::CodeSymbol(1, 0); }, - "code_len > 0"); - ASSERT_DEATH({ HuffmanCode::CodeSymbol(0, 17); }, - "code_len <= Traits::MaxCodeLenghtBits"); - ASSERT_DEATH({ HuffmanCode::CodeSymbol(1, 17); }, - "code_len <= Traits::MaxCodeLenghtBits"); + ASSERT_DEATH( + { HuffmanCode::CodeSymbol(0, 0); }, "code_len > 0"); + ASSERT_DEATH( + { HuffmanCode::CodeSymbol(1, 0); }, "code_len > 0"); + ASSERT_DEATH( + { HuffmanCode::CodeSymbol(0, 17); }, + "code_len <= Traits::MaxCodeLenghtBits"); + ASSERT_DEATH( + { HuffmanCode::CodeSymbol(1, 17); }, + "code_len <= Traits::MaxCodeLenghtBits"); } using CodeSymbolType = std::tuple; @@ -323,8 +325,9 @@ TEST(HuffmanCodeDeathTest, setNCodesPerLengthRequires16Lengths) { HuffmanCode hc; if (b.getSize() != 16) { - ASSERT_DEATH({ hc.setNCodesPerLength(b); }, - "data.getSize\\(\\) == Traits::MaxCodeLenghtBits"); + ASSERT_DEATH( + { hc.setNCodesPerLength(b); }, + "data.getSize\\(\\) == Traits::MaxCodeLenghtBits"); } else { ASSERT_EXIT( { @@ -425,9 +428,9 @@ TEST(HuffmanCodeDeathTest, setCodeValuesRequiresCount) { v.data(), rawspeed::implicit_cast(v.size())); if (cnt != count) { - ASSERT_DEATH({ ht.setCodeValues(bv); }, - "static_cast\\(data.size\\(\\)" - "\\) == maxCodesCount\\(\\)"); + ASSERT_DEATH( + { ht.setCodeValues(bv); }, "static_cast\\(data.size\\(\\)" + "\\) == maxCodesCount\\(\\)"); } else { ASSERT_EXIT( { @@ -445,8 +448,8 @@ TEST(HuffmanCodeDeathTest, setCodeValuesRequiresLessThan162) { std::vector v(163, 0); rawspeed::Array1DRef bv( v.data(), rawspeed::implicit_cast(v.size())); - ASSERT_DEATH({ ht.setCodeValues(bv); }, - "data.size\\(\\) <= Traits::MaxNumCodeValues"); + ASSERT_DEATH( + { ht.setCodeValues(bv); }, "data.size\\(\\) <= Traits::MaxNumCodeValues"); } #endif From d13ff5ac9394aed371240ea20851438ce4d88f0d Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Sat, 16 Mar 2024 03:20:42 +0300 Subject: [PATCH 3/8] clang-tidy: update config --- .clang-tidy | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.clang-tidy b/.clang-tidy index ca7693863..fcdc1b1dc 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -37,6 +37,7 @@ Checks: > -cppcoreguidelines-avoid-magic-numbers, -cppcoreguidelines-c-copy-assignment-signature, -cppcoreguidelines-explicit-virtual-functions, + -cppcoreguidelines-macro-to-enum, -cppcoreguidelines-noexcept-destructor, -cppcoreguidelines-noexcept-move-operations, -cppcoreguidelines-noexcept-swap, @@ -118,11 +119,12 @@ Checks: > -readability-implicit-bool-conversion, -readability-inconsistent-declaration-parameter-name, -readability-magic-numbers, + -modernize-use-std-numbers, + -readability-avoid-nested-conditional-operator, -rawspeed-std-array-no-operator-at WarningsAsErrors: '*' HeaderFilterRegex: '.*' -AnalyzeTemporaryDtors: false InheritParentConfig: false User: lebedevri CheckOptions: From 5f1ebab186ae3513f97a09ad5d54771596c4782b Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Sat, 16 Mar 2024 03:41:32 +0300 Subject: [PATCH 4/8] Apply clang-tidy's `readability-redundant-inline-specifier` check --- .../bitstreams/BitVacuumerRoundtrip.cpp | 6 +- src/librawspeed/adt/Array1DRef.h | 4 +- src/librawspeed/adt/Array2DRef.h | 6 +- src/librawspeed/adt/BitIterator.h | 3 +- .../adt/CoalescingOutputIterator.h | 17 +++--- src/librawspeed/adt/CroppedArray1DRef.h | 4 +- src/librawspeed/adt/CroppedArray2DRef.h | 4 +- .../adt/PartitioningOutputIterator.h | 11 ++-- src/librawspeed/bitstreams/BitStream.h | 12 ++-- src/librawspeed/bitstreams/BitStreamer.h | 39 ++++++------ src/librawspeed/bitstreams/BitVacuumer.h | 12 ++-- src/librawspeed/bitstreams/BitVacuumerJPEG.h | 2 +- src/librawspeed/codes/AbstractPrefixCode.h | 2 +- .../codes/AbstractPrefixCodeDecoder.h | 6 +- .../codes/AbstractPrefixCodeEncoder.h | 2 +- .../codes/AbstractPrefixCodeTranscoder.h | 4 +- .../codes/DummyPrefixCodeDecoder.h | 7 +-- src/librawspeed/codes/HuffmanCode.h | 4 +- src/librawspeed/codes/PrefixCodeLUTDecoder.h | 8 +-- .../codes/PrefixCodeLookupDecoder.h | 11 ++-- src/librawspeed/codes/PrefixCodeTreeDecoder.h | 11 ++-- .../codes/PrefixCodeVectorDecoder.h | 11 ++-- .../codes/PrefixCodeVectorEncoder.h | 10 +-- src/librawspeed/common/DngOpcodes.cpp | 4 +- src/librawspeed/common/SimpleLUT.h | 2 +- .../decoders/AbstractTiffDecoder.h | 14 ++--- .../interpolators/Cr2sRawInterpolator.cpp | 20 +++--- src/librawspeed/io/Buffer.h | 17 +++--- src/librawspeed/io/ByteStream.h | 61 +++++++++---------- src/librawspeed/tiff/TiffEntry.h | 12 ++-- src/utilities/rstest/md5.h | 18 +++--- 31 files changed, 162 insertions(+), 182 deletions(-) diff --git a/fuzz/librawspeed/bitstreams/BitVacuumerRoundtrip.cpp b/fuzz/librawspeed/bitstreams/BitVacuumerRoundtrip.cpp index a78791a3e..59bce076e 100644 --- a/fuzz/librawspeed/bitstreams/BitVacuumerRoundtrip.cpp +++ b/fuzz/librawspeed/bitstreams/BitVacuumerRoundtrip.cpp @@ -106,17 +106,17 @@ class InputWrapper final { InputWrapper& operator=(const InputWrapper&) = delete; InputWrapper& operator=(InputWrapper&&) = delete; - inline InputWrapper(ByteStream bitLengths_, ByteStream bitVals_) + InputWrapper(ByteStream bitLengths_, ByteStream bitVals_) : bitLengths(bitLengths_), bitVals(bitVals_) { invariant(size() >= 0); } - [[nodiscard]] inline int size() const RAWSPEED_READNONE { + [[nodiscard]] int size() const RAWSPEED_READNONE { invariant(bitVals.getSize() == 4 * bitLengths.getSize()); return bitLengths.getSize(); } - [[nodiscard]] inline std::pair + [[nodiscard]] std::pair operator[](int i) const RAWSPEED_READNONE { invariant(i >= 0); invariant(i < size()); diff --git a/src/librawspeed/adt/Array1DRef.h b/src/librawspeed/adt/Array1DRef.h index 0d021cfbb..bee6dee8d 100644 --- a/src/librawspeed/adt/Array1DRef.h +++ b/src/librawspeed/adt/Array1DRef.h @@ -65,7 +65,7 @@ template class Array1DRef final { template requires(!std::is_const_v && std::is_const_v && std::is_same_v, std::remove_const_t>) - inline Array1DRef(Array1DRef RHS) // NOLINT(google-explicit-constructor) + Array1DRef(Array1DRef RHS) // NOLINT(google-explicit-constructor) : Array1DRef(RHS.data, RHS.numElts) {} // Const-preserving conversion from Array1DRef to Array1DRef. @@ -74,7 +74,7 @@ template class Array1DRef final { !(std::is_const_v && !std::is_const_v) && !(std::is_same_v, std::remove_const_t>) && std::is_same_v, std::byte>) - inline Array1DRef(Array1DRef RHS) // NOLINT(google-explicit-constructor) + Array1DRef(Array1DRef RHS) // NOLINT(google-explicit-constructor) : Array1DRef(reinterpret_cast(RHS.data), sizeof(T2) * RHS.numElts) {} [[nodiscard]] CroppedArray1DRef getCrop(int offset, int numElts) const; diff --git a/src/librawspeed/adt/Array2DRef.h b/src/librawspeed/adt/Array2DRef.h index d46fc2232..0344e8df5 100644 --- a/src/librawspeed/adt/Array2DRef.h +++ b/src/librawspeed/adt/Array2DRef.h @@ -78,7 +78,7 @@ template class Array2DRef final { template requires(!std::is_const_v && std::is_const_v && std::is_same_v, std::remove_const_t>) - inline Array2DRef(Array2DRef RHS) // NOLINT(google-explicit-constructor) + Array2DRef(Array2DRef RHS) // NOLINT(google-explicit-constructor) : Array2DRef(RHS.data, RHS._width, RHS._height, RHS._pitch) {} // Const-preserving conversion from Array2DRef to Array2DRef. @@ -87,13 +87,13 @@ template class Array2DRef final { !(std::is_const_v && !std::is_const_v) && !(std::is_same_v, std::remove_const_t>) && std::is_same_v, std::byte>) - inline Array2DRef(Array2DRef RHS) // NOLINT(google-explicit-constructor) + Array2DRef(Array2DRef RHS) // NOLINT(google-explicit-constructor) : Array2DRef(RHS.data, sizeof(T2) * RHS._width, RHS._height, sizeof(T2) * RHS._pitch) {} template ::allocator_type> - inline static Array2DRef + static Array2DRef create(std::vector& storage, int width, int height) { using VectorTy = std::remove_reference_t; diff --git a/src/librawspeed/adt/BitIterator.h b/src/librawspeed/adt/BitIterator.h index 5c8ec7570..59562882c 100644 --- a/src/librawspeed/adt/BitIterator.h +++ b/src/librawspeed/adt/BitIterator.h @@ -54,8 +54,7 @@ struct BitMSBIterator final { invariant(bitIdx >= -1); return *this; } - friend inline bool operator==(const BitMSBIterator& a, - const BitMSBIterator& b) { + friend bool operator==(const BitMSBIterator& a, const BitMSBIterator& b) { invariant(a.bitsPat == b.bitsPat && "Comparing unrelated iterators."); return a.bitIdx == b.bitIdx; } diff --git a/src/librawspeed/adt/CoalescingOutputIterator.h b/src/librawspeed/adt/CoalescingOutputIterator.h index 6f81c1771..2ec0cfaf9 100644 --- a/src/librawspeed/adt/CoalescingOutputIterator.h +++ b/src/librawspeed/adt/CoalescingOutputIterator.h @@ -45,13 +45,13 @@ class CoalescingOutputIterator { static constexpr int MaxOccupancy = bitwidth(); - inline void establishClassInvariants() const { + void establishClassInvariants() const { invariant(occupancy >= 0); invariant(occupancy <= MaxOccupancy); invariant(occupancy % bitwidth() == 0); } - inline void maybeOutputCoalescedParts() { + void maybeOutputCoalescedParts() { establishClassInvariants(); invariant(occupancy > 0); if (occupancy != MaxOccupancy) @@ -79,8 +79,7 @@ class CoalescingOutputIterator { template requires std::same_as> - inline explicit CoalescingOutputIterator(U&& it_) - : it(std::forward(it_)) {} + explicit CoalescingOutputIterator(U&& it_) : it(std::forward(it_)) {} CoalescingOutputIterator(const CoalescingOutputIterator& other) : it(other.it) { @@ -107,7 +106,7 @@ class CoalescingOutputIterator { return *this; } - inline ~CoalescingOutputIterator() { + ~CoalescingOutputIterator() { establishClassInvariants(); if (occupancy == 0) return; @@ -120,25 +119,25 @@ class CoalescingOutputIterator { invariant(occupancy == 0); } - [[nodiscard]] inline CoalescingOutputIterator& operator*() { + [[nodiscard]] CoalescingOutputIterator& operator*() { establishClassInvariants(); return *this; } - inline CoalescingOutputIterator& operator++() { + CoalescingOutputIterator& operator++() { establishClassInvariants(); return *this; } // NOLINTNEXTLINE(cert-dcl21-cpp) - inline CoalescingOutputIterator operator++(int) { + CoalescingOutputIterator operator++(int) { establishClassInvariants(); return *this; } template requires std::same_as - inline CoalescingOutputIterator& operator=(U part) { + CoalescingOutputIterator& operator=(U part) { establishClassInvariants(); invariant(occupancy < MaxOccupancy); invariant(occupancy + bitwidth() <= MaxOccupancy); diff --git a/src/librawspeed/adt/CroppedArray1DRef.h b/src/librawspeed/adt/CroppedArray1DRef.h index 7e7e7b244..f0f9c8dd8 100644 --- a/src/librawspeed/adt/CroppedArray1DRef.h +++ b/src/librawspeed/adt/CroppedArray1DRef.h @@ -64,11 +64,11 @@ template class CroppedArray1DRef final { template requires(!std::is_const_v && std::is_const_v && std::is_same_v, std::remove_const_t>) - inline CroppedArray1DRef( // NOLINT(google-explicit-constructor) + CroppedArray1DRef( // NOLINT(google-explicit-constructor) CroppedArray1DRef RHS) : CroppedArray1DRef(RHS.base, RHS.offset, RHS.numElts) {} - [[nodiscard]] inline Array1DRef getAsArray1DRef() const { + [[nodiscard]] Array1DRef getAsArray1DRef() const { return {begin(), size()}; } diff --git a/src/librawspeed/adt/CroppedArray2DRef.h b/src/librawspeed/adt/CroppedArray2DRef.h index 3785251ee..ebde43311 100644 --- a/src/librawspeed/adt/CroppedArray2DRef.h +++ b/src/librawspeed/adt/CroppedArray2DRef.h @@ -60,7 +60,7 @@ template class CroppedArray2DRef final { // Conversion from Array2DRef to CroppedArray2DRef. // NOLINTNEXTLINE(google-explicit-constructor) - inline CroppedArray2DRef(Array2DRef RHS) + CroppedArray2DRef(Array2DRef RHS) : CroppedArray2DRef(RHS, /*offsetCols=*/0, /*offsetRows=*/0, RHS.width(), RHS.height()) {} @@ -71,7 +71,7 @@ template class CroppedArray2DRef final { template requires(!std::is_const_v && std::is_const_v && std::is_same_v, std::remove_const_t>) - inline CroppedArray2DRef( // NOLINT(google-explicit-constructor) + CroppedArray2DRef( // NOLINT(google-explicit-constructor) CroppedArray2DRef RHS) : CroppedArray2DRef(RHS.base, RHS.offsetCols, RHS.offsetRows, RHS.croppedWidth, RHS.croppedHeight) {} diff --git a/src/librawspeed/adt/PartitioningOutputIterator.h b/src/librawspeed/adt/PartitioningOutputIterator.h index 66fb6d321..3227b5f1a 100644 --- a/src/librawspeed/adt/PartitioningOutputIterator.h +++ b/src/librawspeed/adt/PartitioningOutputIterator.h @@ -45,20 +45,19 @@ class PartitioningOutputIterator { template requires std::same_as> - inline explicit PartitioningOutputIterator(U&& it_) - : it(std::forward(it_)) {} + explicit PartitioningOutputIterator(U&& it_) : it(std::forward(it_)) {} - [[nodiscard]] inline PartitioningOutputIterator& operator*() { return *this; } + [[nodiscard]] PartitioningOutputIterator& operator*() { return *this; } - inline PartitioningOutputIterator& operator++() { return *this; } + PartitioningOutputIterator& operator++() { return *this; } // NOLINTNEXTLINE(cert-dcl21-cpp) - inline PartitioningOutputIterator operator++(int) { return *this; } + PartitioningOutputIterator operator++(int) { return *this; } template requires(std::unsigned_integral && sizeof(U) >= sizeof(PartType) && sizeof(U) % sizeof(PartType) == 0) - inline PartitioningOutputIterator& operator=(U coalesced) { + PartitioningOutputIterator& operator=(U coalesced) { // NOLINTNEXTLINE(bugprone-sizeof-expression) constexpr int NumParts = sizeof(U) / sizeof(PartType); for (int i = 0; i != NumParts; ++i) { diff --git a/src/librawspeed/bitstreams/BitStream.h b/src/librawspeed/bitstreams/BitStream.h index 925b7bb3d..c6303b865 100644 --- a/src/librawspeed/bitstreams/BitStream.h +++ b/src/librawspeed/bitstreams/BitStream.h @@ -56,7 +56,7 @@ BitStreamCacheBase::establishClassInvariants() const noexcept { } struct BitStreamCacheLeftInRightOut final : BitStreamCacheBase { - inline void push(uint64_t bits, int count) noexcept { + void push(uint64_t bits, int count) noexcept { establishClassInvariants(); invariant(count >= 0); // NOTE: count may be zero! @@ -66,7 +66,7 @@ struct BitStreamCacheLeftInRightOut final : BitStreamCacheBase { fillLevel += count; } - [[nodiscard]] inline uint32_t peek(int count) const noexcept { + [[nodiscard]] uint32_t peek(int count) const noexcept { establishClassInvariants(); invariant(count >= 0); invariant(count <= MaxGetBits); @@ -76,7 +76,7 @@ struct BitStreamCacheLeftInRightOut final : BitStreamCacheBase { return extractLowBits(static_cast(cache), count); } - inline void skip(int count) noexcept { + void skip(int count) noexcept { establishClassInvariants(); invariant(count >= 0); // `count` *could* be larger than `MaxGetBits`. @@ -89,7 +89,7 @@ struct BitStreamCacheLeftInRightOut final : BitStreamCacheBase { }; struct BitStreamCacheRightInLeftOut final : BitStreamCacheBase { - inline void push(uint64_t bits, int count) noexcept { + void push(uint64_t bits, int count) noexcept { establishClassInvariants(); invariant(count >= 0); // NOTE: count may be zero! @@ -115,7 +115,7 @@ struct BitStreamCacheRightInLeftOut final : BitStreamCacheBase { fillLevel += count; } - [[nodiscard]] inline auto peek(int count) const noexcept { + [[nodiscard]] auto peek(int count) const noexcept { establishClassInvariants(); invariant(count >= 0); invariant(count <= Size); @@ -127,7 +127,7 @@ struct BitStreamCacheRightInLeftOut final : BitStreamCacheBase { /*effectiveBitwidth=*/BitStreamCacheBase::Size)); } - inline void skip(int count) noexcept { + void skip(int count) noexcept { establishClassInvariants(); invariant(count >= 0); // `count` *could* be larger than `MaxGetBits`. diff --git a/src/librawspeed/bitstreams/BitStreamer.h b/src/librawspeed/bitstreams/BitStreamer.h index cdc0664c8..20c0ae008 100644 --- a/src/librawspeed/bitstreams/BitStreamer.h +++ b/src/librawspeed/bitstreams/BitStreamer.h @@ -49,7 +49,7 @@ template struct BitStreamerReplenisherBase { BitStreamerReplenisherBase() = delete; - inline explicit BitStreamerReplenisherBase(Array1DRef input_) + explicit BitStreamerReplenisherBase(Array1DRef input_) : input(input_) { if (input.size() < BitStreamerTraits::MaxProcessBytes) ThrowIOE("Bit stream size is smaller than MaxProcessBytes"); @@ -62,7 +62,7 @@ template struct BitStreamerReplenisherBase { // as we can and fill rest with zeros. std::array::MaxProcessBytes> tmpStorage = {}; - inline Array1DRef tmp() noexcept RAWSPEED_READONLY { + Array1DRef tmp() noexcept RAWSPEED_READONLY { return {tmpStorage.data(), implicit_cast(tmpStorage.size())}; } }; @@ -85,22 +85,22 @@ struct BitStreamerForwardSequentialReplenisher final BitStreamerForwardSequentialReplenisher() = delete; - [[nodiscard]] inline typename Base::size_type getPos() const { + [[nodiscard]] typename Base::size_type getPos() const { Base::establishClassInvariants(); return Base::pos; } - [[nodiscard]] inline typename Base::size_type getRemainingSize() const { + [[nodiscard]] typename Base::size_type getRemainingSize() const { Base::establishClassInvariants(); return Base::input.size() - getPos(); } - inline void markNumBytesAsConsumed(typename Base::size_type numBytes) { + void markNumBytesAsConsumed(typename Base::size_type numBytes) { Base::establishClassInvariants(); invariant(numBytes >= 0); invariant(numBytes != 0); Base::pos += numBytes; } - inline Array1DRef getInput() { + Array1DRef getInput() { Base::establishClassInvariants(); #if !defined(DEBUG) @@ -182,12 +182,11 @@ class BitStreamer { BitStreamer() = delete; - inline explicit BitStreamer(Array1DRef input) - : replenisher(input) { + explicit BitStreamer(Array1DRef input) : replenisher(input) { establishClassInvariants(); } - inline void fill(int nbits = Cache::MaxGetBits) { + void fill(int nbits = Cache::MaxGetBits) { establishClassInvariants(); invariant(nbits >= 0); invariant(nbits != 0); @@ -202,28 +201,28 @@ class BitStreamer { } // these methods might be specialized by implementations that support it - [[nodiscard]] inline size_type RAWSPEED_READONLY getInputPosition() const { + [[nodiscard]] size_type RAWSPEED_READONLY getInputPosition() const { establishClassInvariants(); return replenisher.getPos(); } // these methods might be specialized by implementations that support it - [[nodiscard]] inline size_type getStreamPosition() const { + [[nodiscard]] size_type getStreamPosition() const { establishClassInvariants(); return getInputPosition() - (cache.fillLevel >> 3); } - [[nodiscard]] inline size_type getRemainingSize() const { + [[nodiscard]] size_type getRemainingSize() const { establishClassInvariants(); return replenisher.getRemainingSize(); } - [[nodiscard]] inline size_type RAWSPEED_READONLY getFillLevel() const { + [[nodiscard]] size_type RAWSPEED_READONLY getFillLevel() const { establishClassInvariants(); return cache.fillLevel; } - inline uint32_t RAWSPEED_READONLY peekBitsNoFill(int nbits) { + uint32_t RAWSPEED_READONLY peekBitsNoFill(int nbits) { establishClassInvariants(); invariant(nbits >= 0); invariant(nbits != 0); @@ -231,7 +230,7 @@ class BitStreamer { return cache.peek(nbits); } - inline void skipBitsNoFill(int nbits) { + void skipBitsNoFill(int nbits) { establishClassInvariants(); invariant(nbits >= 0); // `nbits` could be zero. @@ -239,7 +238,7 @@ class BitStreamer { cache.skip(nbits); } - inline uint32_t getBitsNoFill(int nbits) { + uint32_t getBitsNoFill(int nbits) { establishClassInvariants(); invariant(nbits >= 0); invariant(nbits != 0); @@ -249,7 +248,7 @@ class BitStreamer { return ret; } - inline uint32_t peekBits(int nbits) { + uint32_t peekBits(int nbits) { establishClassInvariants(); invariant(nbits >= 0); invariant(nbits != 0); @@ -258,13 +257,13 @@ class BitStreamer { return peekBitsNoFill(nbits); } - inline void skipBits(int nbits) { + void skipBits(int nbits) { establishClassInvariants(); fill(nbits); skipBitsNoFill(nbits); } - inline uint32_t getBits(int nbits) { + uint32_t getBits(int nbits) { establishClassInvariants(); invariant(nbits >= 0); invariant(nbits != 0); @@ -275,7 +274,7 @@ class BitStreamer { // This may be used to skip arbitrarily large number of *bytes*, // not limited by the fill level. - inline void skipBytes(int nbytes) { + void skipBytes(int nbytes) { establishClassInvariants(); int remainingBitsToSkip = 8 * nbytes; for (; remainingBitsToSkip >= Cache::MaxGetBits; diff --git a/src/librawspeed/bitstreams/BitVacuumer.h b/src/librawspeed/bitstreams/BitVacuumer.h index 9f270f456..2a411bfa6 100644 --- a/src/librawspeed/bitstreams/BitVacuumer.h +++ b/src/librawspeed/bitstreams/BitVacuumer.h @@ -53,7 +53,7 @@ class BitVacuumer { using chunk_type = uint32_t; static constexpr int chunk_bitwidth = 32; - inline void drainImpl() { + void drainImpl() { invariant(cache.fillLevel >= chunk_bitwidth); static_assert(chunk_bitwidth == 32); @@ -76,7 +76,7 @@ class BitVacuumer { } } - inline void drain() { + void drain() { invariant(!flushed); if (cache.fillLevel < chunk_bitwidth) @@ -86,7 +86,7 @@ class BitVacuumer { invariant(cache.fillLevel < chunk_bitwidth); } - inline void flush() { + void flush() { drain(); if (cache.fillLevel == 0) { @@ -113,11 +113,11 @@ class BitVacuumer { template requires std::same_as> - inline explicit BitVacuumer(U&& output_) : output(std::forward(output_)) {} + explicit BitVacuumer(U&& output_) : output(std::forward(output_)) {} - inline ~BitVacuumer() { flush(); } + ~BitVacuumer() { flush(); } - inline void put(uint32_t bits, int count) { + void put(uint32_t bits, int count) { invariant(count >= 0); // NOTE: count may be zero! drain(); diff --git a/src/librawspeed/bitstreams/BitVacuumerJPEG.h b/src/librawspeed/bitstreams/BitVacuumerJPEG.h index f3495849f..c2caa7efc 100644 --- a/src/librawspeed/bitstreams/BitVacuumerJPEG.h +++ b/src/librawspeed/bitstreams/BitVacuumerJPEG.h @@ -48,7 +48,7 @@ class BitVacuumerJPEG final friend void Base::drain(); // Allow it to actually call `drainImpl()`. - inline void drainImpl() { + void drainImpl() { invariant(Base::cache.fillLevel >= Base::chunk_bitwidth); invariant(Base::chunk_bitwidth == 32); diff --git a/src/librawspeed/codes/AbstractPrefixCode.h b/src/librawspeed/codes/AbstractPrefixCode.h index 20117a1af..e64ae5c3f 100644 --- a/src/librawspeed/codes/AbstractPrefixCode.h +++ b/src/librawspeed/codes/AbstractPrefixCode.h @@ -170,7 +170,7 @@ template class AbstractPrefixCode { return s0 == s1; } - inline bool RAWSPEED_READONLY operator==(const CodeSymbol& other) const { + bool RAWSPEED_READONLY operator==(const CodeSymbol& other) const { return code == other.code && code_len == other.code_len; } }; diff --git a/src/librawspeed/codes/AbstractPrefixCodeDecoder.h b/src/librawspeed/codes/AbstractPrefixCodeDecoder.h index 56a64241c..54f9a62b1 100644 --- a/src/librawspeed/codes/AbstractPrefixCodeDecoder.h +++ b/src/librawspeed/codes/AbstractPrefixCodeDecoder.h @@ -41,8 +41,8 @@ class AbstractPrefixCodeDecoder : public AbstractPrefixCodeTranscoder { using Base::Base; template - inline int processSymbol(BIT_STREAM& bs, CodeSymbol symbol, - typename Traits::CodeValueTy codeValue) const { + int processSymbol(BIT_STREAM& bs, CodeSymbol symbol, + typename Traits::CodeValueTy codeValue) const { invariant(symbol.code_len >= 0 && symbol.code_len <= Traits::MaxCodeLenghtBits); @@ -67,7 +67,7 @@ class AbstractPrefixCodeDecoder : public AbstractPrefixCodeTranscoder { // Figure F.12 – Extending the sign bit of a decoded value in V // WARNING: this is *not* your normal 2's complement sign extension! - inline static int RAWSPEED_READNONE extend(uint32_t diff, uint32_t len) { + static int RAWSPEED_READNONE extend(uint32_t diff, uint32_t len) { invariant(len > 0); auto ret = static_cast(diff); if ((diff & (1 << (len - 1))) == 0) diff --git a/src/librawspeed/codes/AbstractPrefixCodeEncoder.h b/src/librawspeed/codes/AbstractPrefixCodeEncoder.h index 6e02ed724..bf6bb5eed 100644 --- a/src/librawspeed/codes/AbstractPrefixCodeEncoder.h +++ b/src/librawspeed/codes/AbstractPrefixCodeEncoder.h @@ -44,7 +44,7 @@ class AbstractPrefixCodeEncoder : public AbstractPrefixCodeTranscoder { Base::setup(fullDecode_, fixDNGBug16_); } - inline static std::pair + static std::pair RAWSPEED_READNONE reduce(int32_t extendedDiff) { if (extendedDiff >= 0) { auto diff = static_cast(extendedDiff); diff --git a/src/librawspeed/codes/AbstractPrefixCodeTranscoder.h b/src/librawspeed/codes/AbstractPrefixCodeTranscoder.h index 20cdc206b..b00e01df8 100644 --- a/src/librawspeed/codes/AbstractPrefixCodeTranscoder.h +++ b/src/librawspeed/codes/AbstractPrefixCodeTranscoder.h @@ -58,11 +58,11 @@ template class AbstractPrefixCodeTranscoder { bool fullDecode = true; bool fixDNGBug16 = false; - [[nodiscard]] inline size_t RAWSPEED_READONLY maxCodeLength() const { + [[nodiscard]] size_t RAWSPEED_READONLY maxCodeLength() const { return code.nCodesPerLength.size() - 1; } - [[nodiscard]] inline size_t RAWSPEED_READONLY __attribute__((pure)) + [[nodiscard]] size_t RAWSPEED_READONLY __attribute__((pure)) maxCodePlusDiffLength() const { return maxCodeLength() + *(std::max_element(code.Base::codeValues.cbegin(), code.Base::codeValues.cend())); diff --git a/src/librawspeed/codes/DummyPrefixCodeDecoder.h b/src/librawspeed/codes/DummyPrefixCodeDecoder.h index 718adc3cd..bcf85b54b 100644 --- a/src/librawspeed/codes/DummyPrefixCodeDecoder.h +++ b/src/librawspeed/codes/DummyPrefixCodeDecoder.h @@ -51,7 +51,7 @@ class DummyPrefixCodeDecoder final { [[nodiscard]] bool isFullDecode() const { return fullDecode; } template - inline typename Traits::CodeValueTy decodeCodeValue(BIT_STREAM& bs) const { + typename Traits::CodeValueTy decodeCodeValue(BIT_STREAM& bs) const { static_assert( BitStreamerTraits::canUseWithPrefixCodeDecoder, "This BitStreamer specialization is not marked as usable here"); @@ -59,8 +59,7 @@ class DummyPrefixCodeDecoder final { return decode(bs); } - template - inline int decodeDifference(BIT_STREAM& bs) const { + template int decodeDifference(BIT_STREAM& bs) const { static_assert( BitStreamerTraits::canUseWithPrefixCodeDecoder, "This BitStreamer specialization is not marked as usable here"); @@ -73,7 +72,7 @@ class DummyPrefixCodeDecoder final { // one to return the fully decoded diff. // All ifs depending on this bool will be optimized out by the compiler template - inline int decode(BIT_STREAM& bs) const { + int decode(BIT_STREAM& bs) const { static_assert( BitStreamerTraits::canUseWithPrefixCodeDecoder, "This BitStreamer specialization is not marked as usable here"); diff --git a/src/librawspeed/codes/HuffmanCode.h b/src/librawspeed/codes/HuffmanCode.h index 19d414888..d978aa421 100644 --- a/src/librawspeed/codes/HuffmanCode.h +++ b/src/librawspeed/codes/HuffmanCode.h @@ -48,7 +48,7 @@ class HuffmanCode final : public AbstractPrefixCode { HuffmanCode() = default; protected: - [[nodiscard]] inline size_t RAWSPEED_READONLY maxCodeLength() const { + [[nodiscard]] size_t RAWSPEED_READONLY maxCodeLength() const { return nCodesPerLength.size() - 1; } @@ -58,7 +58,7 @@ class HuffmanCode final : public AbstractPrefixCode { // (there are always 0 codes of length 0) std::vector nCodesPerLength; // index is length of code - [[nodiscard]] inline unsigned int RAWSPEED_READONLY maxCodesCount() const { + [[nodiscard]] unsigned int RAWSPEED_READONLY maxCodesCount() const { return std::accumulate(nCodesPerLength.begin(), nCodesPerLength.end(), 0U); } diff --git a/src/librawspeed/codes/PrefixCodeLUTDecoder.h b/src/librawspeed/codes/PrefixCodeLUTDecoder.h index 245225110..41b0b1abc 100644 --- a/src/librawspeed/codes/PrefixCodeLUTDecoder.h +++ b/src/librawspeed/codes/PrefixCodeLUTDecoder.h @@ -148,8 +148,7 @@ class PrefixCodeLUTDecoder : public BackendPrefixCodeDecoder { } template - inline __attribute__((always_inline)) int - decodeCodeValue(BIT_STREAM& bs) const { + __attribute__((always_inline)) int decodeCodeValue(BIT_STREAM& bs) const { static_assert( BitStreamerTraits::canUseWithPrefixCodeDecoder, "This BitStreamer specialization is not marked as usable here"); @@ -158,8 +157,7 @@ class PrefixCodeLUTDecoder : public BackendPrefixCodeDecoder { } template - inline __attribute__((always_inline)) int - decodeDifference(BIT_STREAM& bs) const { + __attribute__((always_inline)) int decodeDifference(BIT_STREAM& bs) const { static_assert( BitStreamerTraits::canUseWithPrefixCodeDecoder, "This BitStreamer specialization is not marked as usable here"); @@ -172,7 +170,7 @@ class PrefixCodeLUTDecoder : public BackendPrefixCodeDecoder { // one to return the fully decoded diff. // All ifs depending on this bool will be optimized out by the compiler template - inline __attribute__((always_inline)) int decode(BIT_STREAM& bs) const { + __attribute__((always_inline)) int decode(BIT_STREAM& bs) const { static_assert( BitStreamerTraits::canUseWithPrefixCodeDecoder, "This BitStreamer specialization is not marked as usable here"); diff --git a/src/librawspeed/codes/PrefixCodeLookupDecoder.h b/src/librawspeed/codes/PrefixCodeLookupDecoder.h index c2b1ded4c..87ce51122 100644 --- a/src/librawspeed/codes/PrefixCodeLookupDecoder.h +++ b/src/librawspeed/codes/PrefixCodeLookupDecoder.h @@ -114,7 +114,7 @@ class PrefixCodeLookupDecoder : public AbstractPrefixCodeDecoder { } template - inline typename Traits::CodeValueTy decodeCodeValue(BIT_STREAM& bs) const { + typename Traits::CodeValueTy decodeCodeValue(BIT_STREAM& bs) const { static_assert( BitStreamerTraits::canUseWithPrefixCodeDecoder, "This BitStreamer specialization is not marked as usable here"); @@ -122,8 +122,7 @@ class PrefixCodeLookupDecoder : public AbstractPrefixCodeDecoder { return decode(bs); } - template - inline int decodeDifference(BIT_STREAM& bs) const { + template int decodeDifference(BIT_STREAM& bs) const { static_assert( BitStreamerTraits::canUseWithPrefixCodeDecoder, "This BitStreamer specialization is not marked as usable here"); @@ -133,7 +132,7 @@ class PrefixCodeLookupDecoder : public AbstractPrefixCodeDecoder { protected: template - inline std::pair + std::pair finishReadingPartialSymbol(BIT_STREAM& bs, typename Base::CodeSymbol partial) const { static_assert( @@ -166,7 +165,7 @@ class PrefixCodeLookupDecoder : public AbstractPrefixCodeDecoder { } template - inline std::pair + std::pair readSymbol(BIT_STREAM& bs) const { // Start from completely unknown symbol. typename Base::CodeSymbol partial; @@ -182,7 +181,7 @@ class PrefixCodeLookupDecoder : public AbstractPrefixCodeDecoder { // one to return the fully decoded diff. // All ifs depending on this bool will be optimized out by the compiler template - inline int decode(BIT_STREAM& bs) const { + int decode(BIT_STREAM& bs) const { invariant(FULL_DECODE == Base::fullDecode); bs.fill(32); diff --git a/src/librawspeed/codes/PrefixCodeTreeDecoder.h b/src/librawspeed/codes/PrefixCodeTreeDecoder.h index f3300f60f..07725befb 100644 --- a/src/librawspeed/codes/PrefixCodeTreeDecoder.h +++ b/src/librawspeed/codes/PrefixCodeTreeDecoder.h @@ -47,7 +47,7 @@ class PrefixCodeTreeDecoder : public AbstractPrefixCodeDecoder { protected: template - inline std::pair + std::pair finishReadingPartialSymbol(BIT_STREAM& bs, typename Base::CodeSymbol initialPartial) const { typename Base::CodeSymbol partial; @@ -104,7 +104,7 @@ class PrefixCodeTreeDecoder : public AbstractPrefixCodeDecoder { } template - inline std::pair + std::pair readSymbol(BIT_STREAM& bs) const { static_assert( BitStreamerTraits::canUseWithPrefixCodeDecoder, @@ -129,7 +129,7 @@ class PrefixCodeTreeDecoder : public AbstractPrefixCodeDecoder { } template - inline typename Traits::CodeValueTy decodeCodeValue(BIT_STREAM& bs) const { + typename Traits::CodeValueTy decodeCodeValue(BIT_STREAM& bs) const { static_assert( BitStreamerTraits::canUseWithPrefixCodeDecoder, "This BitStreamer specialization is not marked as usable here"); @@ -137,8 +137,7 @@ class PrefixCodeTreeDecoder : public AbstractPrefixCodeDecoder { return decode(bs); } - template - inline int decodeDifference(BIT_STREAM& bs) const { + template int decodeDifference(BIT_STREAM& bs) const { static_assert( BitStreamerTraits::canUseWithPrefixCodeDecoder, "This BitStreamer specialization is not marked as usable here"); @@ -151,7 +150,7 @@ class PrefixCodeTreeDecoder : public AbstractPrefixCodeDecoder { // one to return the fully decoded diff. // All ifs depending on this bool will be optimized out by the compiler template - inline int decode(BIT_STREAM& bs) const { + int decode(BIT_STREAM& bs) const { static_assert( BitStreamerTraits::canUseWithPrefixCodeDecoder, "This BitStreamer specialization is not marked as usable here"); diff --git a/src/librawspeed/codes/PrefixCodeVectorDecoder.h b/src/librawspeed/codes/PrefixCodeVectorDecoder.h index 0be293a00..6bcc11135 100644 --- a/src/librawspeed/codes/PrefixCodeVectorDecoder.h +++ b/src/librawspeed/codes/PrefixCodeVectorDecoder.h @@ -48,7 +48,7 @@ class PrefixCodeVectorDecoder : public AbstractPrefixCodeDecoder { protected: template - inline std::pair + std::pair finishReadingPartialSymbol(BIT_STREAM& bs, typename Base::CodeSymbol partial) const { static_assert( @@ -78,7 +78,7 @@ class PrefixCodeVectorDecoder : public AbstractPrefixCodeDecoder { } template - inline std::pair + std::pair readSymbol(BIT_STREAM& bs) const { // Start from completely unknown symbol. typename Base::CodeSymbol partial; @@ -104,7 +104,7 @@ class PrefixCodeVectorDecoder : public AbstractPrefixCodeDecoder { } template - inline typename Traits::CodeValueTy decodeCodeValue(BIT_STREAM& bs) const { + typename Traits::CodeValueTy decodeCodeValue(BIT_STREAM& bs) const { static_assert( BitStreamerTraits::canUseWithPrefixCodeDecoder, "This BitStreamer specialization is not marked as usable here"); @@ -112,8 +112,7 @@ class PrefixCodeVectorDecoder : public AbstractPrefixCodeDecoder { return decode(bs); } - template - inline int decodeDifference(BIT_STREAM& bs) const { + template int decodeDifference(BIT_STREAM& bs) const { static_assert( BitStreamerTraits::canUseWithPrefixCodeDecoder, "This BitStreamer specialization is not marked as usable here"); @@ -126,7 +125,7 @@ class PrefixCodeVectorDecoder : public AbstractPrefixCodeDecoder { // one to return the fully decoded diff. // All ifs depending on this bool will be optimized out by the compiler template - inline int decode(BIT_STREAM& bs) const { + int decode(BIT_STREAM& bs) const { static_assert( BitStreamerTraits::canUseWithPrefixCodeDecoder, "This BitStreamer specialization is not marked as usable here"); diff --git a/src/librawspeed/codes/PrefixCodeVectorEncoder.h b/src/librawspeed/codes/PrefixCodeVectorEncoder.h index a0e5f69f0..dadc04a1b 100644 --- a/src/librawspeed/codes/PrefixCodeVectorEncoder.h +++ b/src/librawspeed/codes/PrefixCodeVectorEncoder.h @@ -37,7 +37,7 @@ class PrefixCodeVectorEncoder : public AbstractPrefixCodeEncoder { private: template - inline void encodeCodeValueImpl(BIT_VACUUMER& bv, int codeIndex) const { + void encodeCodeValueImpl(BIT_VACUUMER& bv, int codeIndex) const { static_assert( BitVacuumerTraits::canUseWithPrefixCodeEncoder, "This BitVacuumer specialization is not marked as usable here"); @@ -66,8 +66,8 @@ class PrefixCodeVectorEncoder : public AbstractPrefixCodeEncoder { } template - inline void encodeCodeValue(BIT_VACUUMER& bv, - typename Traits::CodeValueTy codeValue) const { + void encodeCodeValue(BIT_VACUUMER& bv, + typename Traits::CodeValueTy codeValue) const { static_assert( BitVacuumerTraits::canUseWithPrefixCodeEncoder, "This BitVacuumer specialization is not marked as usable here"); @@ -77,7 +77,7 @@ class PrefixCodeVectorEncoder : public AbstractPrefixCodeEncoder { } template - inline void encodeDifference(BIT_VACUUMER& bv, int value) const { + void encodeDifference(BIT_VACUUMER& bv, int value) const { static_assert( BitVacuumerTraits::canUseWithPrefixCodeEncoder, "This BitVacuumer specialization is not marked as usable here"); @@ -90,7 +90,7 @@ class PrefixCodeVectorEncoder : public AbstractPrefixCodeEncoder { } template - inline void encode(BIT_VACUUMER& bv, int value) const { + void encode(BIT_VACUUMER& bv, int value) const { static_assert( BitVacuumerTraits::canUseWithPrefixCodeEncoder, "This BitVacuumer specialization is not marked as usable here"); diff --git a/src/librawspeed/common/DngOpcodes.cpp b/src/librawspeed/common/DngOpcodes.cpp index 34095fb82..6655b6fc4 100644 --- a/src/librawspeed/common/DngOpcodes.cpp +++ b/src/librawspeed/common/DngOpcodes.cpp @@ -514,11 +514,11 @@ class DngOpcodes::DeltaRowOrColBase : public PixelOpcode { public: struct SelectX final { - static inline uint32_t select(uint32_t x, uint32_t /*y*/) { return x; } + static uint32_t select(uint32_t x, uint32_t /*y*/) { return x; } }; struct SelectY final { - static inline uint32_t select(uint32_t /*x*/, uint32_t y) { return y; } + static uint32_t select(uint32_t /*x*/, uint32_t y) { return y; } }; protected: diff --git a/src/librawspeed/common/SimpleLUT.h b/src/librawspeed/common/SimpleLUT.h index d15a0caff..07c09b52e 100644 --- a/src/librawspeed/common/SimpleLUT.h +++ b/src/librawspeed/common/SimpleLUT.h @@ -60,7 +60,7 @@ template class SimpleLUT final { assert(table.size() == fullTableSize); } - inline value_type operator[](int x) const { + value_type operator[](int x) const { unsigned clampedX = clampBits(x, TableBitWidth); return table[clampedX]; } diff --git a/src/librawspeed/decoders/AbstractTiffDecoder.h b/src/librawspeed/decoders/AbstractTiffDecoder.h index 6d0964540..da968d1c0 100644 --- a/src/librawspeed/decoders/AbstractTiffDecoder.h +++ b/src/librawspeed/decoders/AbstractTiffDecoder.h @@ -45,24 +45,24 @@ class AbstractTiffDecoder : public RawDecoder { TiffIFD* getRootIFD() final { return mRootIFD.get(); } - inline bool checkCameraSupported(const CameraMetaData* meta, const TiffID& id, - const std::string& mode) { + bool checkCameraSupported(const CameraMetaData* meta, const TiffID& id, + const std::string& mode) { return RawDecoder::checkCameraSupported(meta, id.make, id.model, mode); } using RawDecoder::setMetaData; - inline void setMetaData(const CameraMetaData* meta, const TiffID& id, - const std::string& mode, int iso_speed) { + void setMetaData(const CameraMetaData* meta, const TiffID& id, + const std::string& mode, int iso_speed) { setMetaData(meta, id.make, id.model, mode, iso_speed); } - inline void setMetaData(const CameraMetaData* meta, const std::string& mode, - int iso_speed) { + void setMetaData(const CameraMetaData* meta, const std::string& mode, + int iso_speed) { setMetaData(meta, mRootIFD->getID(), mode, iso_speed); } - inline void checkSupportInternal(const CameraMetaData* meta) override { + void checkSupportInternal(const CameraMetaData* meta) override { checkCameraSupported(meta, mRootIFD->getID(), ""); } diff --git a/src/librawspeed/interpolators/Cr2sRawInterpolator.cpp b/src/librawspeed/interpolators/Cr2sRawInterpolator.cpp index 6da3de5f8..36eb1d090 100644 --- a/src/librawspeed/interpolators/Cr2sRawInterpolator.cpp +++ b/src/librawspeed/interpolators/Cr2sRawInterpolator.cpp @@ -39,16 +39,14 @@ struct Cr2sRawInterpolator::YCbCr final { int Cb = 0; int Cr = 0; - inline static void LoadY(YCbCr* p, - const CroppedArray1DRef in) { + static void LoadY(YCbCr* p, const CroppedArray1DRef in) { invariant(p); invariant(in.size() == 1); p->Y = in(0); } - inline static void LoadCbCr(YCbCr* p, - const CroppedArray1DRef in) { + static void LoadCbCr(YCbCr* p, const CroppedArray1DRef in) { invariant(p); invariant(in.size() == 2); @@ -56,7 +54,7 @@ struct Cr2sRawInterpolator::YCbCr final { p->Cr = in(1); } - inline static void CopyCbCr(YCbCr* p, const YCbCr& pSrc) { + static void CopyCbCr(YCbCr* p, const YCbCr& pSrc) { invariant(p); p->Cb = pSrc.Cb; @@ -65,30 +63,30 @@ struct Cr2sRawInterpolator::YCbCr final { YCbCr() = default; - inline void signExtend() { + void signExtend() { Cb -= 16384; Cr -= 16384; } - inline void applyHue(int hue_) { + void applyHue(int hue_) { Cb += hue_; Cr += hue_; } - inline void process(int hue_) { + void process(int hue_) { signExtend(); applyHue(hue_); } - inline void interpolateCbCr(const YCbCr& p0, const YCbCr& p2) { + void interpolateCbCr(const YCbCr& p0, const YCbCr& p2) { // Y is already good, need to interpolate Cb and Cr // FIXME: dcraw does +1 before >> 1 Cb = (p0.Cb + p2.Cb) >> 1; Cr = (p0.Cr + p2.Cr) >> 1; } - inline void interpolateCbCr(const YCbCr& p0, const YCbCr& p1, const YCbCr& p2, - const YCbCr& p3) { + void interpolateCbCr(const YCbCr& p0, const YCbCr& p1, const YCbCr& p2, + const YCbCr& p3) { // Y is already good, need to interpolate Cb and Cr // FIXME: dcraw does +1 before >> 1 Cb = (p0.Cb + p1.Cb + p2.Cb + p3.Cb) >> 2; diff --git a/src/librawspeed/io/Buffer.h b/src/librawspeed/io/Buffer.h index 843f97b8b..591cc8a71 100644 --- a/src/librawspeed/io/Buffer.h +++ b/src/librawspeed/io/Buffer.h @@ -104,20 +104,17 @@ class Buffer { // get memory of type T from byte offset 'offset + sizeof(T)*index' and swap // byte order if required template - [[nodiscard]] inline T get(bool inNativeByteOrder, size_type offset, - size_type index = 0) const { + [[nodiscard]] T get(bool inNativeByteOrder, size_type offset, + size_type index = 0) const { const Buffer buf = getSubView(offset + index * static_cast(sizeof(T)), static_cast(sizeof(T))); return getByteSwapped(buf.begin(), !inNativeByteOrder); } - [[nodiscard]] inline size_type RAWSPEED_READONLY getSize() const { - return size; - } + [[nodiscard]] size_type RAWSPEED_READONLY getSize() const { return size; } - [[nodiscard]] inline bool isValid(size_type offset, - size_type count = 1) const { + [[nodiscard]] bool isValid(size_type offset, size_type count = 1) const { return static_cast(offset) + count <= static_cast(getSize()); } @@ -147,16 +144,16 @@ class DataBuffer : public Buffer { // get memory of type T from byte offset 'offset + sizeof(T)*index' and swap // byte order if required template - [[nodiscard]] inline T get(size_type offset, size_type index = 0) const { + [[nodiscard]] T get(size_type offset, size_type index = 0) const { assert(Endianness::unknown != endianness); assert(Endianness::little == endianness || Endianness::big == endianness); return Buffer::get(getHostEndianness() == endianness, offset, index); } - [[nodiscard]] inline Endianness getByteOrder() const { return endianness; } + [[nodiscard]] Endianness getByteOrder() const { return endianness; } - inline Endianness setByteOrder(Endianness endianness_) { + Endianness setByteOrder(Endianness endianness_) { std::swap(endianness, endianness_); return endianness_; } diff --git a/src/librawspeed/io/ByteStream.h b/src/librawspeed/io/ByteStream.h index 3646f8568..e78fcc631 100644 --- a/src/librawspeed/io/ByteStream.h +++ b/src/librawspeed/io/ByteStream.h @@ -59,7 +59,7 @@ class ByteStream final : public DataBuffer { return ByteStream(DataBuffer(getSubView(offset), getByteOrder())); } - [[nodiscard]] inline size_type check(size_type bytes) const { + [[nodiscard]] size_type check(size_type bytes) const { if (!isValid(pos, bytes)) ThrowIOE("Out of bounds access in ByteStream"); [[maybe_unused]] Buffer tmp = getSubView(pos, bytes); @@ -68,72 +68,71 @@ class ByteStream final : public DataBuffer { return bytes; } - [[nodiscard]] inline size_type check(size_type nmemb, size_type size_) const { + [[nodiscard]] size_type check(size_type nmemb, size_type size_) const { if (size_ && nmemb > std::numeric_limits::max() / size_) ThrowIOE("Integer overflow when calculating stream length"); return check(nmemb * size_); } - [[nodiscard]] inline size_type getPosition() const { + [[nodiscard]] size_type getPosition() const { invariant(getSize() >= pos); (void)check(0); return pos; } - inline void setPosition(size_type newPos) { + void setPosition(size_type newPos) { pos = newPos; (void)check(0); } - [[nodiscard]] inline size_type RAWSPEED_READONLY getRemainSize() const { + [[nodiscard]] size_type RAWSPEED_READONLY getRemainSize() const { invariant(getSize() >= pos); (void)check(0); return getSize() - pos; } - [[nodiscard]] inline const uint8_t* peekData(size_type count) const { + [[nodiscard]] const uint8_t* peekData(size_type count) const { return Buffer::getSubView(pos, count).begin(); } - inline const uint8_t* getData(size_type count) { + const uint8_t* getData(size_type count) { const uint8_t* ret = peekData(count); pos += count; return ret; } - [[nodiscard]] inline Buffer peekBuffer(size_type size_) const { + [[nodiscard]] Buffer peekBuffer(size_type size_) const { return getSubView(pos, size_); } - inline Buffer getBuffer(size_type size_) { + Buffer getBuffer(size_type size_) { Buffer ret = peekBuffer(size_); pos += size_; return ret; } - [[nodiscard]] inline Buffer peekRemainingBuffer() const { + [[nodiscard]] Buffer peekRemainingBuffer() const { return getSubView(pos, getRemainSize()); } - [[nodiscard]] inline ByteStream peekStream(size_type size_) const { + [[nodiscard]] ByteStream peekStream(size_type size_) const { return getSubStream(pos, size_); } - [[nodiscard]] inline ByteStream peekStream(size_type nmemb, - size_type size_) const { + [[nodiscard]] ByteStream peekStream(size_type nmemb, size_type size_) const { if (size_ && nmemb > std::numeric_limits::max() / size_) ThrowIOE("Integer overflow when calculating stream length"); return peekStream(nmemb * size_); } - inline ByteStream getStream(size_type size_) { + ByteStream getStream(size_type size_) { ByteStream ret = peekStream(size_); pos += size_; return ret; } - inline ByteStream getStream(size_type nmemb, size_type size_) { + ByteStream getStream(size_type nmemb, size_type size_) { if (size_ && nmemb > std::numeric_limits::max() / size_) ThrowIOE("Integer overflow when calculating stream length"); return getStream(nmemb * size_); } - inline void skipBytes(size_type nbytes) { pos += check(nbytes); } - inline void skipBytes(size_type nmemb, size_type size_) { + void skipBytes(size_type nbytes) { pos += check(nbytes); } + void skipBytes(size_type nmemb, size_type size_) { pos += check(nmemb, size_); } - [[nodiscard]] inline bool hasPatternAt(std::string_view pattern, - size_type relPos) const { + [[nodiscard]] bool hasPatternAt(std::string_view pattern, + size_type relPos) const { if (!isValid(pos + relPos, implicit_cast(pattern.size()))) return false; auto tmp = @@ -142,41 +141,41 @@ class ByteStream final : public DataBuffer { return std::equal(tmp.begin(), tmp.end(), pattern.begin()); } - [[nodiscard]] inline bool hasPrefix(std::string_view prefix) const { + [[nodiscard]] bool hasPrefix(std::string_view prefix) const { return hasPatternAt(prefix, /*relPos=*/0); } - inline bool skipPrefix(std::string_view prefix) { + bool skipPrefix(std::string_view prefix) { bool has_prefix = hasPrefix(prefix); if (has_prefix) pos += prefix.size(); return has_prefix; } - template [[nodiscard]] inline T peek(size_type i = 0) const { + template [[nodiscard]] T peek(size_type i = 0) const { return DataBuffer::get(pos, i); } - template inline T get() { + template T get() { auto ret = peek(); pos += sizeof(T); return ret; } - [[nodiscard]] inline uint8_t peekByte(size_type i = 0) const { + [[nodiscard]] uint8_t peekByte(size_type i = 0) const { return peek(i); } - inline uint8_t getByte() { return get(); } + uint8_t getByte() { return get(); } - [[nodiscard]] inline uint16_t peekU16() const { return peek(); } + [[nodiscard]] uint16_t peekU16() const { return peek(); } - [[nodiscard]] inline uint32_t peekU32(size_type i = 0) const { + [[nodiscard]] uint32_t peekU32(size_type i = 0) const { return peek(i); } - inline uint16_t getU16() { return get(); } - inline int32_t getI32() { return get(); } - inline uint32_t getU32() { return get(); } - inline float getFloat() { return get(); } + uint16_t getU16() { return get(); } + int32_t getI32() { return get(); } + uint32_t getU32() { return get(); } + float getFloat() { return get(); } [[nodiscard]] std::string_view peekString() const { Buffer tmp = peekBuffer(getRemainSize()); diff --git a/src/librawspeed/tiff/TiffEntry.h b/src/librawspeed/tiff/TiffEntry.h index c036e4fbb..b8d347fa8 100644 --- a/src/librawspeed/tiff/TiffEntry.h +++ b/src/librawspeed/tiff/TiffEntry.h @@ -104,26 +104,24 @@ class TiffEntry { [[nodiscard]] float getFloat(uint32_t index = 0) const; [[nodiscard]] std::string getString() const; - [[nodiscard]] inline std::vector - getU16Array(uint32_t count_) const { + [[nodiscard]] std::vector getU16Array(uint32_t count_) const { return getArray(count_); } - [[nodiscard]] inline std::vector - getU32Array(uint32_t count_) const { + [[nodiscard]] std::vector getU32Array(uint32_t count_) const { return getArray(count_); } - [[nodiscard]] inline std::vector getFloatArray(uint32_t count_) const { + [[nodiscard]] std::vector getFloatArray(uint32_t count_) const { return getArray(count_); } - [[nodiscard]] inline std::vector> + [[nodiscard]] std::vector> getRationalArray(uint32_t count_) const { return getArray, &TiffEntry::getRational>(count_); } - [[nodiscard]] inline std::vector> + [[nodiscard]] std::vector> getSRationalArray(uint32_t count_) const { return getArray, &TiffEntry::getSRational>(count_); } diff --git a/src/utilities/rstest/md5.h b/src/utilities/rstest/md5.h index 6859a85d5..4e5f4fef1 100644 --- a/src/utilities/rstest/md5.h +++ b/src/utilities/rstest/md5.h @@ -88,14 +88,13 @@ template class BufferCoalescer final { public: template - inline void take_block_impl(ArgTy& arg, - Array1DRef message) const = delete; + void take_block_impl(ArgTy& arg, + Array1DRef message) const = delete; private: template requires std::same_as - inline void take_block_impl(NoBuffer& arg, - Array1DRef message) { + void take_block_impl(NoBuffer& arg, Array1DRef message) { invariant(message.size() != 0); if (message.size() == N) { @@ -110,8 +109,8 @@ template class BufferCoalescer final { template requires std::same_as - inline void take_block_impl(CoalescingBuffer& arg, - Array1DRef message) const { + void take_block_impl(CoalescingBuffer& arg, + Array1DRef message) const { invariant(message.size() != 0); invariant(message.size() < N); @@ -124,13 +123,12 @@ template class BufferCoalescer final { arg.block_length += message.size(); } - [[nodiscard]] __attribute__((always_inline)) inline int - length() const noexcept { + [[nodiscard]] __attribute__((always_inline)) int length() const noexcept { return std::visit([](const auto& arg) { return arg.block_length; }, state); } public: - [[nodiscard]] __attribute__((always_inline)) inline int + [[nodiscard]] __attribute__((always_inline)) int bytesAvaliable() const noexcept { return N - length(); } @@ -145,7 +143,7 @@ template class BufferCoalescer final { void reset() noexcept { state = NoBuffer(); } - __attribute__((always_inline)) inline void + __attribute__((always_inline)) void take_block(Array1DRef message) noexcept { invariant(message.size() != 0); invariant(message.size() <= N); From ab0a9342843f75785b5842d9d1010920e733a84a Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Sat, 16 Mar 2024 03:50:48 +0300 Subject: [PATCH 5/8] Apply clang-tidy's `performance-enum-size` check --- src/librawspeed/codes/BinaryPrefixTree.h | 2 +- src/librawspeed/common/BayerPhase.h | 2 +- src/librawspeed/common/Common.h | 2 +- src/librawspeed/common/RawImage.h | 4 ++-- src/librawspeed/decoders/Cr2Decoder.cpp | 2 +- src/librawspeed/decoders/IiqDecoder.cpp | 4 ++-- src/librawspeed/decoders/IiqDecoder.h | 2 +- src/librawspeed/decompressors/Cr2DecompressorImpl.h | 6 +++++- src/librawspeed/decompressors/FujiDecompressor.cpp | 2 +- src/librawspeed/decompressors/SamsungV2Decompressor.cpp | 2 +- src/librawspeed/decompressors/SamsungV2Decompressor.h | 2 +- src/librawspeed/io/Endianness.h | 6 +++++- src/librawspeed/metadata/Camera.h | 2 +- src/librawspeed/tiff/CiffEntry.h | 2 +- src/librawspeed/tiff/CiffTag.h | 3 ++- src/librawspeed/tiff/TiffEntry.h | 2 +- src/librawspeed/tiff/TiffTag.h | 4 +++- 17 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/librawspeed/codes/BinaryPrefixTree.h b/src/librawspeed/codes/BinaryPrefixTree.h index 77d4c6961..a12501dcc 100644 --- a/src/librawspeed/codes/BinaryPrefixTree.h +++ b/src/librawspeed/codes/BinaryPrefixTree.h @@ -41,7 +41,7 @@ class BinaryPrefixTree final /* : public BinarySearchTree */ { struct Leaf; struct Node { - enum class Type { Branch, Leaf }; + enum class Type : uint8_t { Branch, Leaf }; explicit virtual operator Type() const = 0; diff --git a/src/librawspeed/common/BayerPhase.h b/src/librawspeed/common/BayerPhase.h index 5f2cdfa6a..f971036c6 100644 --- a/src/librawspeed/common/BayerPhase.h +++ b/src/librawspeed/common/BayerPhase.h @@ -45,7 +45,7 @@ namespace rawspeed { // ..GBGBGB.. // .......... // and there are only 4 flavours of the 2x2 pattern, since position is mod-2: -enum class BayerPhase : int { +enum class BayerPhase : uint8_t { // The top-left pixel of the image is red pixel. RGGB = 0b00, // 0 // The top-left pixel of the image is green pixel in a green/red row. diff --git a/src/librawspeed/common/Common.h b/src/librawspeed/common/Common.h index 17516a4a6..b195d09d0 100644 --- a/src/librawspeed/common/Common.h +++ b/src/librawspeed/common/Common.h @@ -199,7 +199,7 @@ inline std::array to_array(const std::vector& v) { return a; } -enum class BitOrder { +enum class BitOrder : uint8_t { LSB, /* Memory order */ MSB, /* Input is added to stack byte by byte, and output is lifted from top */ diff --git a/src/librawspeed/common/RawImage.h b/src/librawspeed/common/RawImage.h index 34fe6835c..6a31ec66f 100644 --- a/src/librawspeed/common/RawImage.h +++ b/src/librawspeed/common/RawImage.h @@ -51,11 +51,11 @@ namespace rawspeed { class RawImage; class RawImageData; -enum class RawImageType { UINT16, F32 }; +enum class RawImageType : uint8_t { UINT16, F32 }; class RawImageWorker final { public: - enum class RawImageWorkerTask { + enum class RawImageWorkerTask : uint16_t { SCALE_VALUES = 1, FIX_BAD_PIXELS = 2, APPLY_LOOKUP = 3 | 0x1000, diff --git a/src/librawspeed/decoders/Cr2Decoder.cpp b/src/librawspeed/decoders/Cr2Decoder.cpp index ff70fa6bb..8c6b84846 100644 --- a/src/librawspeed/decoders/Cr2Decoder.cpp +++ b/src/librawspeed/decoders/Cr2Decoder.cpp @@ -228,7 +228,7 @@ void Cr2Decoder::checkSupportInternal(const CameraMetaData* meta) { namespace { -enum class ColorDataFormat { +enum class ColorDataFormat : uint8_t { ColorData1, ColorData2, ColorData3, diff --git a/src/librawspeed/decoders/IiqDecoder.cpp b/src/librawspeed/decoders/IiqDecoder.cpp index 7f4a33b4d..869d1a3f4 100644 --- a/src/librawspeed/decoders/IiqDecoder.cpp +++ b/src/librawspeed/decoders/IiqDecoder.cpp @@ -117,7 +117,7 @@ IiqDecoder::computeSripes(Buffer raw_data, std::vector offsets, namespace { -enum class IIQFormat { +enum class IIQFormat : uint8_t { RAW_1, RAW_2, IIQ_L, @@ -149,7 +149,7 @@ Optional getAsIIQFormat(uint32_t v) { } // namespace -enum class IiqDecoder::IiqCorr { LUMA, CHROMA }; +enum class IiqDecoder::IiqCorr : uint8_t { LUMA, CHROMA }; RawImage IiqDecoder::decodeRawInternal() { const Buffer buf(mFile.getSubView(8)); diff --git a/src/librawspeed/decoders/IiqDecoder.h b/src/librawspeed/decoders/IiqDecoder.h index 165c8c0ff..409c47bbe 100644 --- a/src/librawspeed/decoders/IiqDecoder.h +++ b/src/librawspeed/decoders/IiqDecoder.h @@ -67,7 +67,7 @@ class IiqDecoder final : public AbstractTiffDecoder { uint32_t split_col) const; void CorrectQuadrantMultipliersCombined(ByteStream data, uint32_t split_row, uint32_t split_col) const; - enum class IiqCorr; + enum class IiqCorr : uint8_t; void PhaseOneFlatField(ByteStream data, IiqCorr corr) const; void correctSensorDefects(ByteStream data) const; void correctBadColumn(uint16_t col) const; diff --git a/src/librawspeed/decompressors/Cr2DecompressorImpl.h b/src/librawspeed/decompressors/Cr2DecompressorImpl.h index c70ab8656..3fc9a6bca 100644 --- a/src/librawspeed/decompressors/Cr2DecompressorImpl.h +++ b/src/librawspeed/decompressors/Cr2DecompressorImpl.h @@ -51,7 +51,11 @@ class ByteStream; // NOLINTNEXTLINE(google-build-namespaces) namespace { -enum class TileSequenceStatus { ContinuesColumn, BeginsNewColumn, Invalid }; +enum class TileSequenceStatus : uint8_t { + ContinuesColumn, + BeginsNewColumn, + Invalid +}; inline TileSequenceStatus evaluateConsecutiveTiles(const iRectangle2D& rect, diff --git a/src/librawspeed/decompressors/FujiDecompressor.cpp b/src/librawspeed/decompressors/FujiDecompressor.cpp index 1602bf917..81ef007ea 100644 --- a/src/librawspeed/decompressors/FujiDecompressor.cpp +++ b/src/librawspeed/decompressors/FujiDecompressor.cpp @@ -70,7 +70,7 @@ struct int_pair final { int value2; }; -enum xt_lines { +enum xt_lines : uint8_t { R0 = 0, R1, R2, diff --git a/src/librawspeed/decompressors/SamsungV2Decompressor.cpp b/src/librawspeed/decompressors/SamsungV2Decompressor.cpp index d33382fc3..0a2f09033 100644 --- a/src/librawspeed/decompressors/SamsungV2Decompressor.cpp +++ b/src/librawspeed/decompressors/SamsungV2Decompressor.cpp @@ -44,7 +44,7 @@ namespace rawspeed { // in contact and Loring von Palleske (Samsung) for pointing to the open-source // code of Samsung's DNG converter at http://opensource.samsung.com/ -enum struct SamsungV2Decompressor::OptFlags : uint32_t { +enum struct SamsungV2Decompressor::OptFlags : uint8_t { NONE = 0U, // no flags SKIP = 1U << 0U, // Skip checking if we need differences from previous line MV = 1U << 1U, // Simplify motion vector definition diff --git a/src/librawspeed/decompressors/SamsungV2Decompressor.h b/src/librawspeed/decompressors/SamsungV2Decompressor.h index 3e2b9219f..8e572b64a 100644 --- a/src/librawspeed/decompressors/SamsungV2Decompressor.h +++ b/src/librawspeed/decompressors/SamsungV2Decompressor.h @@ -33,7 +33,7 @@ class RawImage; // Decoder for third generation compressed SRW files (NX1) class SamsungV2Decompressor final : public AbstractSamsungDecompressor { public: - enum struct OptFlags : uint32_t; + enum struct OptFlags : uint8_t; private: uint32_t bitDepth; diff --git a/src/librawspeed/io/Endianness.h b/src/librawspeed/io/Endianness.h index 35e3ca45e..e2b0217d7 100644 --- a/src/librawspeed/io/Endianness.h +++ b/src/librawspeed/io/Endianness.h @@ -28,7 +28,11 @@ namespace rawspeed { -enum class Endianness { little = 0xDEAD, big = 0xBEEF, unknown = 0x0BAD }; +enum class Endianness : uint16_t { + little = 0xDEAD, + big = 0xBEEF, + unknown = 0x0BAD +}; inline Endianness getHostEndiannessRuntime() { uint16_t testvar = 0xfeff; diff --git a/src/librawspeed/metadata/Camera.h b/src/librawspeed/metadata/Camera.h index 1b0b8dc98..f07a2bb41 100644 --- a/src/librawspeed/metadata/Camera.h +++ b/src/librawspeed/metadata/Camera.h @@ -76,7 +76,7 @@ class Hints final { class Camera final { public: - enum class SupportStatus { + enum class SupportStatus : uint8_t { SupportedNoSamples, // Tentatively supported, no RPU samples. Supported, // Claimed as supported (explicitly). Unknown, // Placeholder camera, support is unknown. diff --git a/src/librawspeed/tiff/CiffEntry.h b/src/librawspeed/tiff/CiffEntry.h index fd2305d9f..a719f0c10 100644 --- a/src/librawspeed/tiff/CiffEntry.h +++ b/src/librawspeed/tiff/CiffEntry.h @@ -40,7 +40,7 @@ template class NORangesSet; /* * Tag data type information. */ -enum class CiffDataType { +enum class CiffDataType : uint16_t { BYTE = 0x0000, /* 8-bit unsigned integer */ ASCII = 0x0800, /* 8-bit bytes w/ last byte null */ SHORT = 0x1000, /* 16-bit unsigned integer */ diff --git a/src/librawspeed/tiff/CiffTag.h b/src/librawspeed/tiff/CiffTag.h index 8973b9250..889cf2ba8 100644 --- a/src/librawspeed/tiff/CiffTag.h +++ b/src/librawspeed/tiff/CiffTag.h @@ -21,11 +21,12 @@ #pragma once +#include #include namespace rawspeed { -enum class CiffTag { +enum class CiffTag : uint16_t { NULL_TAG = 0x0000, MAKEMODEL = 0x080a, SHOTINFO = 0x102a, diff --git a/src/librawspeed/tiff/TiffEntry.h b/src/librawspeed/tiff/TiffEntry.h index b8d347fa8..50ca87979 100644 --- a/src/librawspeed/tiff/TiffEntry.h +++ b/src/librawspeed/tiff/TiffEntry.h @@ -42,7 +42,7 @@ class Buffer; * * Note: RATIONALs are the ratio of two 32-bit integer values. */ -enum class TiffDataType { +enum class TiffDataType : uint8_t { NOTYPE = 0, /* placeholder */ BYTE = 1, /* 8-bit unsigned integer */ ASCII = 2, /* 8-bit bytes w/ last byte null */ diff --git a/src/librawspeed/tiff/TiffTag.h b/src/librawspeed/tiff/TiffTag.h index 098958c01..066ea65fc 100644 --- a/src/librawspeed/tiff/TiffTag.h +++ b/src/librawspeed/tiff/TiffTag.h @@ -25,9 +25,11 @@ #pragma once +#include + namespace rawspeed { -enum class TiffTag { +enum class TiffTag : uint16_t { INTEROPERABILITYINDEX = 0x0001, INTEROPERABILITYVERSION = 0x0002, CANONSHOTINFO = 0x0004, From 85c90d098a9729494e0f358237eaf308d70c81b9 Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Sat, 16 Mar 2024 03:54:46 +0300 Subject: [PATCH 6/8] Apply clang-tidy's `readability-redundant-casting` check --- src/librawspeed/bitstreams/BitStreamerJPEG.h | 2 +- src/librawspeed/bitstreams/BitVacuumerJPEG.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librawspeed/bitstreams/BitStreamerJPEG.h b/src/librawspeed/bitstreams/BitStreamerJPEG.h index 88454de7e..5a8efdb3a 100644 --- a/src/librawspeed/bitstreams/BitStreamerJPEG.h +++ b/src/librawspeed/bitstreams/BitStreamerJPEG.h @@ -123,7 +123,7 @@ BitStreamerJPEG::fillCache(Array1DRef input) { // short-cut path for the most common case (no FF marker in the next 4 bytes) // this is slightly faster than the else-case alone. - if (std::accumulate(&prefetch[0], &prefetch[4], bool(true), + if (std::accumulate(&prefetch[0], &prefetch[4], true, [](bool b, std::byte byte) { return b && (byte != std::byte{0xFF}); })) { diff --git a/src/librawspeed/bitstreams/BitVacuumerJPEG.h b/src/librawspeed/bitstreams/BitVacuumerJPEG.h index c2caa7efc..b682eafcb 100644 --- a/src/librawspeed/bitstreams/BitVacuumerJPEG.h +++ b/src/librawspeed/bitstreams/BitVacuumerJPEG.h @@ -67,7 +67,7 @@ class BitVacuumerJPEG final // short-cut path for the most common case (no FF marker in the next 4 // bytes) this is slightly faster than the else-case alone. - if (std::accumulate(bytes.begin(), bytes.end(), bool(true), + if (std::accumulate(bytes.begin(), bytes.end(), true, [](bool b, std::byte byte) { return b && (byte != std::byte{0xFF}); })) { From 8255e1b518d06a2596ac0f9a4dc3378024f2f569 Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Sat, 16 Mar 2024 03:59:42 +0300 Subject: [PATCH 7/8] Include cleanup pass --- src/librawspeed/adt/Bit.h | 1 + src/librawspeed/adt/CoalescingOutputIterator.h | 2 ++ src/librawspeed/adt/Optional.h | 1 + src/librawspeed/adt/PartitioningOutputIterator.h | 3 +++ src/librawspeed/bitstreams/BitStreamerJPEG.h | 1 + src/librawspeed/bitstreams/BitVacuumer.h | 5 +++-- src/librawspeed/codes/BinaryPrefixTree.h | 1 + src/librawspeed/common/BayerPhase.h | 1 + src/librawspeed/decoders/RafDecoder.h | 1 + src/utilities/rstest/md5.h | 1 + test/librawspeed/adt/CoalescingOutputIteratorTest.cpp | 2 ++ 11 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/librawspeed/adt/Bit.h b/src/librawspeed/adt/Bit.h index 806318e19..019df144b 100644 --- a/src/librawspeed/adt/Bit.h +++ b/src/librawspeed/adt/Bit.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include diff --git a/src/librawspeed/adt/CoalescingOutputIterator.h b/src/librawspeed/adt/CoalescingOutputIterator.h index 2ec0cfaf9..7d41da93a 100644 --- a/src/librawspeed/adt/CoalescingOutputIterator.h +++ b/src/librawspeed/adt/CoalescingOutputIterator.h @@ -24,8 +24,10 @@ #include "adt/Invariant.h" #include "io/Endianness.h" #include +#include #include #include +#include namespace rawspeed { diff --git a/src/librawspeed/adt/Optional.h b/src/librawspeed/adt/Optional.h index 04cd93ec5..d99c23fba 100644 --- a/src/librawspeed/adt/Optional.h +++ b/src/librawspeed/adt/Optional.h @@ -22,6 +22,7 @@ #include "rawspeedconfig.h" #include "adt/Invariant.h" +#include #include // IWYU pragma: export namespace rawspeed { diff --git a/src/librawspeed/adt/PartitioningOutputIterator.h b/src/librawspeed/adt/PartitioningOutputIterator.h index 3227b5f1a..7d217e4b8 100644 --- a/src/librawspeed/adt/PartitioningOutputIterator.h +++ b/src/librawspeed/adt/PartitioningOutputIterator.h @@ -22,7 +22,10 @@ #include "adt/Bit.h" #include +#include +#include #include +#include namespace rawspeed { diff --git a/src/librawspeed/bitstreams/BitStreamerJPEG.h b/src/librawspeed/bitstreams/BitStreamerJPEG.h index 5a8efdb3a..ccf3de656 100644 --- a/src/librawspeed/bitstreams/BitStreamerJPEG.h +++ b/src/librawspeed/bitstreams/BitStreamerJPEG.h @@ -30,6 +30,7 @@ #include "io/Endianness.h" #include #include +#include #include #include #include diff --git a/src/librawspeed/bitstreams/BitVacuumer.h b/src/librawspeed/bitstreams/BitVacuumer.h index 2a411bfa6..79217a548 100644 --- a/src/librawspeed/bitstreams/BitVacuumer.h +++ b/src/librawspeed/bitstreams/BitVacuumer.h @@ -20,12 +20,13 @@ #pragma once -#include "adt/Array1DRef.h" #include "adt/Invariant.h" #include "bitstreams/BitStream.h" #include "io/Endianness.h" -#include +#include #include +#include +#include namespace rawspeed { diff --git a/src/librawspeed/codes/BinaryPrefixTree.h b/src/librawspeed/codes/BinaryPrefixTree.h index a12501dcc..f70110d51 100644 --- a/src/librawspeed/codes/BinaryPrefixTree.h +++ b/src/librawspeed/codes/BinaryPrefixTree.h @@ -24,6 +24,7 @@ #include "codes/AbstractPrefixCode.h" #include #include +#include #include #include // IWYU pragma: keep #include diff --git a/src/librawspeed/common/BayerPhase.h b/src/librawspeed/common/BayerPhase.h index f971036c6..b4d476d38 100644 --- a/src/librawspeed/common/BayerPhase.h +++ b/src/librawspeed/common/BayerPhase.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include diff --git a/src/librawspeed/decoders/RafDecoder.h b/src/librawspeed/decoders/RafDecoder.h index 8dc9e759c..ca1a6756a 100644 --- a/src/librawspeed/decoders/RafDecoder.h +++ b/src/librawspeed/decoders/RafDecoder.h @@ -21,6 +21,7 @@ #pragma once +#include "adt/Point.h" #include "common/RawImage.h" #include "decoders/AbstractTiffDecoder.h" #include "io/Buffer.h" diff --git a/src/utilities/rstest/md5.h b/src/utilities/rstest/md5.h index 4e5f4fef1..2322b2ec3 100644 --- a/src/utilities/rstest/md5.h +++ b/src/utilities/rstest/md5.h @@ -35,6 +35,7 @@ #include "adt/CroppedArray1DRef.h" // IWYU pragma: keep #include "adt/Invariant.h" #include +#include #include #include #include diff --git a/test/librawspeed/adt/CoalescingOutputIteratorTest.cpp b/test/librawspeed/adt/CoalescingOutputIteratorTest.cpp index 0d72d63ff..a4749be6f 100644 --- a/test/librawspeed/adt/CoalescingOutputIteratorTest.cpp +++ b/test/librawspeed/adt/CoalescingOutputIteratorTest.cpp @@ -23,8 +23,10 @@ #include "adt/Casts.h" #include "common/Common.h" #include +#include #include #include +#include #include #include #include From b5c16e313ddd896e9101b2f388f84b7d58e8f6fe Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Sat, 16 Mar 2024 04:14:35 +0300 Subject: [PATCH 8/8] Un-disable `modernize-use-std-numbers` clang-tidy check --- .clang-tidy | 1 - src/librawspeed/decoders/NefDecoder.cpp | 16 ++++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index fcdc1b1dc..160ab2aed 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -119,7 +119,6 @@ Checks: > -readability-implicit-bool-conversion, -readability-inconsistent-declaration-parameter-name, -readability-magic-numbers, - -modernize-use-std-numbers, -readability-avoid-nested-conditional-operator, -rawspeed-std-array-no-operator-at diff --git a/src/librawspeed/decoders/NefDecoder.cpp b/src/librawspeed/decoders/NefDecoder.cpp index a24a39b1a..5ae7920bf 100644 --- a/src/librawspeed/decoders/NefDecoder.cpp +++ b/src/librawspeed/decoders/NefDecoder.cpp @@ -757,9 +757,11 @@ void NefDecoder::DecodeNikonSNef(ByteStream input) const { reinterpret_cast(&out(row, col + 1)), &random); mRaw->setWithLookUp( - clampBits(static_cast(implicit_cast(y1) + - 1.732446 * implicit_cast(cb)), - 12), + clampBits( + static_cast(implicit_cast(y1) + + 1.732446 // NOLINT(modernize-use-std-numbers) + * implicit_cast(cb)), + 12), tmpch, &random); out(row, col + 2) = clampBits((inv_wb_b * tmp + (1 << 9)) >> 10, 15); @@ -778,9 +780,11 @@ void NefDecoder::DecodeNikonSNef(ByteStream input) const { reinterpret_cast(&out(row, col + 4)), &random); mRaw->setWithLookUp( - clampBits(static_cast(implicit_cast(y2) + - 1.732446 * implicit_cast(cb2)), - 12), + clampBits( + static_cast(implicit_cast(y2) + + 1.732446 // NOLINT(modernize-use-std-numbers) + * implicit_cast(cb2)), + 12), tmpch, &random); out(row, col + 5) = clampBits((inv_wb_b * tmp + (1 << 9)) >> 10, 15); }