From c5d74818eb485a84a55c77fc78ca2a782c985ab8 Mon Sep 17 00:00:00 2001 From: elsid Date: Sun, 20 Jul 2025 11:09:20 +0200 Subject: [PATCH 1/4] Disable portability-template-virtual-member-function clang tidy warning There is no compatibility problem in practice. /home/elsid/dev/openmw/components/settings/sanitizer.hpp:11:19: error: unspecified virtual member function instantiation; the virtual member function is not instantiated but it might be with a different compiler [portability-template-virtual-member-function,-warnings-as-errors] 11 | virtual T apply(const T& value) const = 0; | ^ /home/elsid/dev/openmw/components/settings/sanitizerimpl.cpp:20:28: note: template instantiated here 20 | struct Max final : Sanitizer | ^ --- .clang-tidy | 1 + 1 file changed, 1 insertion(+) diff --git a/.clang-tidy b/.clang-tidy index 90c72765ca..8597ea5c13 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,6 +1,7 @@ Checks: > -*, portability-*, + -portability-template-virtual-member-function, clang-analyzer-*, -clang-analyzer-optin.*, -clang-analyzer-cplusplus.NewDeleteLeaks, From ec0c76d2f3cbbbc2af082155f46b6f5c6192494d Mon Sep 17 00:00:00 2001 From: elsid Date: Sun, 27 Jul 2025 12:11:21 +0200 Subject: [PATCH 2/4] Ignore false positive warning cellSize > 1 so the result of the division cannot be undefined. /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:18:35: error: The result of the '/' expression is undefined [clang-analyzer-core.UndefinedBinaryOperatorResult,-warnings-as-errors] 18 | std::size_t cell = global / (cellSize - 1); | ^ /home/elsid/dev/openmw/components/esmterrain/storage.cpp:244:13: note: Assuming 'lodLevel' is >= 0 244 | if (lodLevel < 0 || 63 < lodLevel) | ^~~~~~~~~~~~ /home/elsid/dev/openmw/components/esmterrain/storage.cpp:244:13: note: Left side of '||' is false /home/elsid/dev/openmw/components/esmterrain/storage.cpp:244:29: note: Assuming 'lodLevel' is <= 63 244 | if (lodLevel < 0 || 63 < lodLevel) | ^~~~~~~~~~~~~ /home/elsid/dev/openmw/components/esmterrain/storage.cpp:244:9: note: Taking false branch 244 | if (lodLevel < 0 || 63 < lodLevel) | ^ /home/elsid/dev/openmw/components/esmterrain/storage.cpp:247:13: note: Assuming 'size' is > 0 247 | if (size <= 0) | ^~~~~~~~~ /home/elsid/dev/openmw/components/esmterrain/storage.cpp:247:9: note: Taking false branch 247 | if (size <= 0) | ^ /home/elsid/dev/openmw/components/esmterrain/storage.cpp:272:13: note: Assuming the condition is false 272 | if (land != nullptr) | ^~~~~~~~~~~~~~~ /home/elsid/dev/openmw/components/esmterrain/storage.cpp:272:9: note: Taking false branch 272 | if (land != nullptr) | ^ /home/elsid/dev/openmw/components/esmterrain/storage.cpp:363:9: note: Calling 'sampleCellGrid' 363 | sampleCellGrid(cellSize, sampleSize, beginX, beginY, distance, handleSample); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:72:13: note: Assuming 'cellSize' is >= 2 72 | if (cellSize < 2 || !Misc::isPowerOfTwo(cellSize - 1)) | ^~~~~~~~~~~~ /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:72:13: note: Left side of '||' is false /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:72:9: note: Taking false branch 72 | if (cellSize < 2 || !Misc::isPowerOfTwo(cellSize - 1)) | ^ /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:75:13: note: Assuming 'sampleSize' is not equal to 0 75 | if (sampleSize == 0 || !Misc::isPowerOfTwo(sampleSize)) | ^~~~~~~~~~~~~~~ /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:75:13: note: Left side of '||' is false /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:75:9: note: Taking false branch 75 | if (sampleSize == 0 || !Misc::isPowerOfTwo(sampleSize)) | ^ /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:78:13: note: Assuming 'distance' is >= 2 78 | if (distance < 2 || !Misc::isPowerOfTwo(distance - 1)) | ^~~~~~~~~~~~ /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:78:13: note: Left side of '||' is false /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:78:9: note: Taking false branch 78 | if (distance < 2 || !Misc::isPowerOfTwo(distance - 1)) | ^ /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:84:13: note: Assuming 'distance' is >= 'cellSize' 84 | if (distance < cellSize || sampleSize > cellSize - 1) | ^~~~~~~~~~~~~~~~~~~ /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:84:13: note: Left side of '||' is false /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:84:36: note: Assuming the condition is true 84 | if (distance < cellSize || sampleSize > cellSize - 1) | ^~~~~~~~~~~~~~~~~~~~~~~~~ /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:84:9: note: Taking true branch 84 | if (distance < cellSize || sampleSize > cellSize - 1) | ^ /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:85:20: note: Calling 'sampleCellGridSimple' 85 | return sampleCellGridSimple(cellSize, sampleSize, beginX, beginY, endX, endY, f); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:56:16: note: 'cellSize' is > 1 56 | assert(cellSize > 1); | ^ /usr/include/assert.h:100:27: note: expanded from macro 'assert' 100 | (static_cast (expr) \ | ^~~~ /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:56:9: note: '?' condition is true 56 | assert(cellSize > 1); | ^ /usr/include/assert.h:100:7: note: expanded from macro 'assert' 100 | (static_cast (expr) \ | ^ /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:57:9: note: '?' condition is true 57 | assert(Misc::isPowerOfTwo(cellSize - 1)); | ^ /usr/include/assert.h:100:7: note: expanded from macro 'assert' 100 | (static_cast (expr) \ | ^ /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:58:16: note: 'sampleSize' is not equal to 0 58 | assert(sampleSize != 0); | ^ /usr/include/assert.h:100:27: note: expanded from macro 'assert' 100 | (static_cast (expr) \ | ^~~~ /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:58:9: note: '?' condition is true 58 | assert(sampleSize != 0); | ^ /usr/include/assert.h:100:7: note: expanded from macro 'assert' 100 | (static_cast (expr) \ | ^ /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:60:9: note: Calling 'sampleGrid<(lambda at /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:61:13)>' 60 | sampleGrid(sampleSize, beginX, beginY, endX, endY, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 61 | [&](std::size_t globalX, std::size_t globalY, std::size_t vertX, std::size_t vertY) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 62 | const auto [cellX, x] = toCellAndLocal(beginX, globalX, cellSize); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 63 | const auto [cellY, y] = toCellAndLocal(beginY, globalY, cellSize); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 64 | f(cellX, cellY, x, y, vertX, vertY); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 65 | }); | ~~ /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:33:38: note: Assuming 'y' is < 'endY' 33 | for (std::size_t y = beginY; y < endY; y += sampleSize) | ^~~~~~~~ /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:33:9: note: Loop condition is true. Entering loop body 33 | for (std::size_t y = beginY; y < endY; y += sampleSize) | ^ /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:36:42: note: Assuming 'x' is < 'endX' 36 | for (std::size_t x = beginX; x < endX; x += sampleSize) | ^~~~~~~~ /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:36:13: note: Loop condition is true. Entering loop body 36 | for (std::size_t x = beginX; x < endX; x += sampleSize) | ^ /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:36:42: note: Assuming 'x' is < 'endX' 36 | for (std::size_t x = beginX; x < endX; x += sampleSize) | ^~~~~~~~ /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:36:13: note: Loop condition is true. Entering loop body 36 | for (std::size_t x = beginX; x < endX; x += sampleSize) | ^ /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:37:17: note: Calling 'operator()' 37 | f(x, y, vertX++, vertY); | ^~~~~~~~~~~~~~~~~~~~~~~ /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:62:41: note: Calling 'toCellAndLocal' 62 | const auto [cellX, x] = toCellAndLocal(beginX, globalX, cellSize); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/elsid/dev/openmw/components/esmterrain/gridsampling.hpp:18:35: note: The result of the '/' expression is undefined 18 | std::size_t cell = global / (cellSize - 1); | ~~~~~~~^~~~~~~~~~~~~~~~ --- components/esmterrain/gridsampling.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/esmterrain/gridsampling.hpp b/components/esmterrain/gridsampling.hpp index e71dfc5152..86544a214b 100644 --- a/components/esmterrain/gridsampling.hpp +++ b/components/esmterrain/gridsampling.hpp @@ -15,7 +15,9 @@ namespace ESMTerrain inline std::pair toCellAndLocal( std::size_t begin, std::size_t global, std::size_t cellSize) { + // NOLINTBEGIN(clang-analyzer-core.UndefinedBinaryOperatorResult) std::size_t cell = global / (cellSize - 1); + // NOLINTEND(clang-analyzer-core.UndefinedBinaryOperatorResult) std::size_t local = global & (cellSize - 2); if (global != begin && local == 0) { From 8682ea522f6c742e1ac1676e44ebc56207f72582 Mon Sep 17 00:00:00 2001 From: elsid Date: Sun, 27 Jul 2025 12:20:10 +0200 Subject: [PATCH 3/4] Remove unused namespace alias --- apps/mwiniimporter/importer.cpp | 2 -- apps/mwiniimporter/main.cpp | 1 - 2 files changed, 3 deletions(-) diff --git a/apps/mwiniimporter/importer.cpp b/apps/mwiniimporter/importer.cpp index a8dee709da..4b8e7acd61 100644 --- a/apps/mwiniimporter/importer.cpp +++ b/apps/mwiniimporter/importer.cpp @@ -9,8 +9,6 @@ #include #include -namespace sfs = std::filesystem; - namespace { // from configfileparser.cpp diff --git a/apps/mwiniimporter/main.cpp b/apps/mwiniimporter/main.cpp index 6e4242cb4e..c5f21ac67f 100644 --- a/apps/mwiniimporter/main.cpp +++ b/apps/mwiniimporter/main.cpp @@ -10,7 +10,6 @@ #include namespace bpo = boost::program_options; -namespace sfs = std::filesystem; #ifndef _WIN32 int main(int argc, char* argv[]) From c6f381f1c4d050f9a98690f126680bd1a8621c84 Mon Sep 17 00:00:00 2001 From: elsid Date: Sun, 27 Jul 2025 12:21:13 +0200 Subject: [PATCH 4/4] Ignore readability-identifier-naming for boost::program_options namespace alias --- .clang-tidy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.clang-tidy b/.clang-tidy index 8597ea5c13..1f37003f8e 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -17,4 +17,4 @@ CheckOptions: - key: readability-identifier-naming.NamespaceCase value: CamelCase - key: readability-identifier-naming.NamespaceIgnoredRegexp - value: 'osg(DB|FX|Particle|Shadow|Viewer|Util)?' + value: 'bpo|osg(DB|FX|Particle|Shadow|Viewer|Util)?'