diff --git a/.clang-format b/.clang-format index 93219e3a..35c378a2 100644 --- a/.clang-format +++ b/.clang-format @@ -12,24 +12,62 @@ AlignConsecutiveAssignments: AcrossEmptyLines: false AcrossComments: false AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false PadOperators: true AlignConsecutiveBitFields: Enabled: false AcrossEmptyLines: false AcrossComments: false AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false PadOperators: false AlignConsecutiveDeclarations: Enabled: false AcrossEmptyLines: false AcrossComments: false AlignCompound: false + AlignFunctionDeclarations: true + AlignFunctionPointers: false PadOperators: false AlignConsecutiveMacros: Enabled: true AcrossEmptyLines: false AcrossComments: true AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveShortCaseStatements: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCaseArrows: false + AlignCaseColons: false +AlignConsecutiveTableGenBreakingDAGArgColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveTableGenCondOperatorColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveTableGenDefinitionColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false PadOperators: false AlignEscapedNewlines: Right AlignOperands: Align @@ -38,17 +76,19 @@ AlignTrailingComments: OverEmptyLines: 1 AllowAllArgumentsOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: true +AllowBreakBeforeNoexceptSpecifier: Never AllowShortBlocksOnASingleLine: Never +AllowShortCaseExpressionOnASingleLine: true AllowShortCaseLabelsOnASingleLine: false +AllowShortCompoundRequirementOnASingleLine: true AllowShortEnumsOnASingleLine: false AllowShortFunctionsOnASingleLine: None AllowShortIfStatementsOnASingleLine: Never AllowShortLambdasOnASingleLine: Inline AllowShortLoopsOnASingleLine: false +AllowShortNamespacesOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: Yes AttributeMacros: - __capability - DPLX_ATTR_FORCE_INLINE @@ -56,7 +96,7 @@ AttributeMacros: - DPLX_ATTR_DP_DEPRECATED - DPLX_ATTR_DP_DEPRECATED_ BinPackArguments: true -BinPackParameters: false +BinPackParameters: OnePerLine BitFieldColonSpacing: Both BraceWrapping: AfterCaseLabel: false @@ -77,17 +117,22 @@ BraceWrapping: SplitEmptyFunction: true SplitEmptyRecord: true SplitEmptyNamespace: true +BreakAdjacentStringLiterals: true BreakAfterAttributes: Leave BreakAfterJavaFieldAnnotations: true +BreakAfterReturnType: None BreakArrays: false BreakBeforeBinaryOperators: All BreakBeforeConceptDeclarations: Always BreakBeforeBraces: Custom BreakBeforeInlineASMColon: OnlyMultiline BreakBeforeTernaryOperators: true +BreakBinaryOperations: Never BreakConstructorInitializers: BeforeComma +BreakFunctionDefinitionParameters: false BreakInheritanceList: BeforeComma BreakStringLiterals: true +BreakTemplateDeclarations: Yes ColumnLimit: 80 CommentPragmas: '^ IWYU pragma:' CompactNamespaces: false @@ -109,27 +154,34 @@ IncludeBlocks: Regroup IncludeCategories: - Regex: '^<[[:alpha:]_]*>$' Priority: 2 + SortPriority: 0 CaseSensitive: false - Regex: '^ boost-*, + -boost-use-ranges, bugprone-*, -bugprone-easily-swappable-parameters, + -bugprone-forward-declaration-namespace, clang-analyzer-*, -clang-analyzer-core.uninitialized.Assign, + -clang-analyzer-optin.core.EnumCastOutOfRange, clang-diagnostic-*, cppcoreguidelines-*, -cppcoreguidelines-avoid-c-arrays, -cppcoreguidelines-avoid-do-while, + -cppcoreguidelines-missing-std-forward, + -cppcoreguidelines-rvalue-reference-param-not-moved, -cppcoreguidelines-special-member-functions, + -cppcoreguidelines-use-default-member-init, modernize-*, -modernize-avoid-c-arrays, -cppcoreguidelines-avoid-do-while, -modernize-use-default-member-init, + -modernize-use-designated-initializers, + -modernize-use-ranges, performance-*, + -performance-enum-size, portability-*, + -portability-template-virtual-member-function, readability-*, -readability-identifier-length, -readability-magic-numbers, -readability-named-parameter, + -readability-redundant-inline-specifier, -readability-redundant-member-init, -readability-static-accessed-through-instance WarningsAsErrors: true diff --git a/.copier-answers.yml b/.copier-answers.yml index 63d18192..de093cf9 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,5 +1,5 @@ # Changes here will be overwritten by Copier -_commit: v0.3.4 +_commit: v0.4.0 _src_path: gh:deeplex/copier-cpp email: henrik@gassmann.onl full_name: Henrik Steffen Gaßmann diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 1b85d78e..e328bd51 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,21 +1,37 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the -// README at: https://github.com/devcontainers/templates/tree/main/src/cpp { - "name": "C++", + "name": "Deeplex | C++", "image": "ghcr.io/deeplex/devcontainer-cpp:ubuntu-24.04", "customizations": { "vscode": { "extensions": [ + // general editor utility "EditorConfig.EditorConfig", + // GitHub integration "github.vscode-github-actions", + "GitHub.vscode-pull-request-github", + // C++ + "llvm-vs-code-extensions.vscode-clangd", + "ms-vscode.cmake-tools", + // sphinx "lextudio.restructuredtext", "ms-python.python", - "ms-vscode.cpptools", - "ms-vscode.cmake-tools", "trond-snekvik.simple-rst", - "twxs.cmake", ] } }, + "features": { + "ghcr.io/devcontainers/features/common-utils:2": { + "installZsh": true, + "installOhMyZsh": true, + "installOhMyZshConfig": true, + "upgradePackages": true, + "username": "vscode" + }, + "ghcr.io/devcontainers/features/python:1": { + "version": "os-provided", + "installTools": true, + "toolsToInstall": "copier,pipenv" + } + }, "postCreateCommand": "cd ${containerWorkspaceFolder}/docs && pipenv sync --dev", } \ No newline at end of file diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 8d5fd830..b7eba1f5 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -1,2 +1,4 @@ # style: Reformat sources with clang-format-16 581f623d89802e5be3982df44dad979feeb6cf8d +# style: reformat sources with clang-format v20 +132b0409fe81d68b611d09316f1ed92890a77f25 diff --git a/.github/workflows/cpp-ci.yml b/.github/workflows/cpp-ci.yml index 1dd10a23..bc48de39 100644 --- a/.github/workflows/cpp-ci.yml +++ b/.github/workflows/cpp-ci.yml @@ -14,10 +14,10 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-22.04, windows-2022] + os: [ubuntu-24.04, windows-2022] compiler: [gcc, clang, msvc] exclude: - - os: ubuntu-22.04 + - os: ubuntu-24.04 compiler: msvc - os: windows-2022 compiler: gcc @@ -25,24 +25,27 @@ jobs: - os: macos-13 compiler: gcc triplet: x64-macos - - os: macos-14 + - os: macos-15 compiler: clang triplet: arm64-macos install: | - HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 brew install llvm@16 - - os: ubuntu-22.04 + HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 brew install llvm@19 + - os: ubuntu-24.04 triplet: x64-linux - - os: ubuntu-22.04 + - os: ubuntu-24.04 triplet: x64-linux compiler: clang install: | sudo cp tools/llvm-snapshot.gpg.key.asc /etc/apt/trusted.gpg.d/llvm-snapshot.asc - sudo add-apt-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main" + sudo add-apt-repository "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-19 main" sudo apt-get -qq update - sudo apt-get -qq -y install clang-16 + sudo apt-get -qq -y install clang-19 - os: windows-2022 triplet: x64-windows + permissions: + actions: read + env: CTEST_OUTPUT_ON_FAILURE: "1" @@ -55,61 +58,81 @@ jobs: - uses: lukka/get-cmake@latest with: - cmakeVersion: 3.22.6 + cmakeVersion: 3.31.7 + + - name: Restore vcpkg cache + id: vcpkg-cache + uses: TAServers/vcpkg-cache@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + prefix: vcpkg/${{ matrix.triplet }}-${{ matrix.compiler }}/ - name: Initialize vcpkg - uses: lukka/run-vcpkg@v11 + uses: lukka/run-vcpkg@b3dd708d38df5c856fe1c18dc0d59ab771f93921 with: vcpkgDirectory: ${{ github.workspace }}/build/vcpkg - - name: Build ${{ matrix.triplet }}-${{ matrix.compiler }} preset + - name: Build ${{ matrix.triplet }}-${{ matrix.compiler }}-ci preset uses: lukka/run-cmake@v10 with: - configurePreset: ${{ matrix.triplet }}-${{ matrix.compiler }} - buildPreset: ${{ matrix.triplet }}-${{ matrix.compiler }} - testPreset: ${{ matrix.triplet }}-${{ matrix.compiler }} + configurePreset: ${{ matrix.triplet }}-${{ matrix.compiler }}-ci + buildPreset: ${{ matrix.triplet }}-${{ matrix.compiler }}-ci + testPreset: ${{ matrix.triplet }}-${{ matrix.compiler }}-ci env: CC: '' CXX: '' + VCPKG_BINARY_SOURCES: "clear;files,${{ steps.vcpkg-cache.outputs.path }},readwrite" - - name: Build ${{ matrix.triplet }}-${{ matrix.compiler }}-release preset + - name: Build ${{ matrix.triplet }}-${{ matrix.compiler }}-ci-release preset uses: lukka/run-cmake@v10 with: - configurePreset: ${{ matrix.triplet }}-${{ matrix.compiler }} - buildPreset: ${{ matrix.triplet }}-${{ matrix.compiler }}-release - testPreset: ${{ matrix.triplet }}-${{ matrix.compiler }}-release + configurePreset: ${{ matrix.triplet }}-${{ matrix.compiler }}-ci + buildPreset: ${{ matrix.triplet }}-${{ matrix.compiler }}-ci-release + testPreset: ${{ matrix.triplet }}-${{ matrix.compiler }}-ci-release env: CC: '' CXX: '' - + VCPKG_BINARY_SOURCES: "clear;files,${{ steps.vcpkg-cache.outputs.path }},readwrite" check-format: name: clang-tidy & clang-format - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 + + permissions: + actions: read steps: - uses: actions/checkout@v3 - - name: "Install clang-tools-16" + - name: "Install clang-tools-20" run: | sudo cp ${{ github.workspace }}/tools/llvm-snapshot.gpg.key.asc /etc/apt/trusted.gpg.d/llvm-snapshot.asc - sudo add-apt-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main" + sudo add-apt-repository "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-20 main" sudo apt-get -qq update - sudo apt-get -qq -y install clang-16 clang-tidy-16 clang-format-16 + sudo apt-get -qq -y install clang-20 clang-tidy-20 clang-format-20 - uses: lukka/get-cmake@latest with: - cmakeVersion: 3.22.6 + cmakeVersion: 3.31.7 + + - name: Restore vcpkg cache + id: vcpkg-cache + uses: TAServers/vcpkg-cache@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + prefix: vcpkg/lint/ - name: Initialize vcpkg - uses: lukka/run-vcpkg@v11 + uses: lukka/run-vcpkg@b3dd708d38df5c856fe1c18dc0d59ab771f93921 with: vcpkgDirectory: ${{ github.workspace }}/../vcpkg - - name: Configure x64-linux-clang preset + - name: Configure x64-linux-ci-lint preset uses: lukka/run-cmake@v10 with: configurePreset: x64-linux-ci-lint + env: + VCPKG_BINARY_SOURCES: "clear;files,${{ steps.vcpkg-cache.outputs.path }},readwrite" - uses: cpp-linter/cpp-linter-action@v2 name: Lint with clang-format and clang-tidy @@ -117,7 +140,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - version: 16.0.6 + version: 20 style: file # use .clang-format settings tidy-checks: '' # use .clang-tidy settings extensions: cpp,hpp diff --git a/.gitignore b/.gitignore index 6c24a331..3a240ec7 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,5 @@ build/ /.idea /cmake-build-debug /cmake-build-release +# cache directory used eg by clangd +.cache diff --git a/.vscode/extensions.json b/.vscode/extensions.json index d61d5390..7bbe9cf9 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,12 +1,16 @@ { "recommendations": [ + // general editor utility "EditorConfig.EditorConfig", + // GitHub integration "github.vscode-github-actions", + "GitHub.vscode-pull-request-github", + // C++ + "llvm-vs-code-extensions.vscode-clangd", + "ms-vscode.cmake-tools", + // sphinx "lextudio.restructuredtext", "ms-python.python", - "ms-vscode.cpptools-extension-pack", - "ms-vscode.cmake-tools", "trond-snekvik.simple-rst", - "twxs.cmake", ] } \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index edb5b7c1..90c9fb05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ # http://creativecommons.org/publicdomain/zero/1.0/ # ######################################################################## -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.23...4.0) list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/tools/cmake/") if (POLICY CMP0127) diff --git a/CMakePresets.json b/CMakePresets.json index 06e7c883..48681368 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -16,6 +16,7 @@ "BUILD_TESTING": true, "WARNINGS_AS_ERRORS": true, "CMAKE_DEBUG_POSTFIX": "-dbg", + "CMAKE_EXPORT_COMPILE_COMMANDS": true, "CMAKE_INSTALL_PREFIX": "${sourceDir}/build/zinstall" } }, @@ -33,8 +34,7 @@ "CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$:Debug>", "VCPKG_TARGET_TRIPLET": "x64-windows-static" }, - "environment": { - }, + "environment": {}, "vendor": { "microsoft.com/VisualStudioSettings/CMake/1.0": { "hostOS": [ @@ -52,6 +52,12 @@ "CMAKE_CXX_COMPILER": "cl" } }, + { + "name": "x64-windows-msvc-ci", + "inherits": [ + "x64-windows-msvc" + ] + }, { "name": "x64-windows-msvc-lto", "inherits": [ @@ -86,6 +92,12 @@ } } }, + { + "name": "x64-windows-clang-ci", + "inherits": [ + "x64-windows-clang" + ] + }, { "name": "x64-linux", "hidden": true, @@ -126,40 +138,76 @@ "x64-linux" ], "cacheVariables": { - "VCPKG_TARGET_TRIPLET": "x64-linux-clang-16", - "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/tools/toolchains/x64-linux-clang-16.cmake" + "VCPKG_TARGET_TRIPLET": "x64-linux-clang", + "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/tools/toolchains/x64-linux-clang.cmake" } }, { - "name": "x64-linux-ci-lint", + "name": "x64-linux-clang-19", + "inherits": [ + "x64-linux-clang" + ], + "cacheVariables": { + "VCPKG_TARGET_TRIPLET": "x64-linux-clang-19", + "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/tools/toolchains/x64-linux-clang-19.cmake" + } + }, + { + "name": "x64-linux-clang-20", "inherits": [ "x64-linux-clang" ], "cacheVariables": { - "VCPKG_TARGET_TRIPLET": "x64-linux-clang-16", - "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/tools/toolchains/x64-linux-clang-16.cmake", - "CMAKE_EXPORT_COMPILE_COMMANDS": true + "VCPKG_TARGET_TRIPLET": "x64-linux-clang-20", + "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/tools/toolchains/x64-linux-clang-20.cmake" } }, + { + "name": "x64-linux-clang-ci", + "inherits": [ + "x64-linux-clang-19" + ] + }, + { + "name": "x64-linux-ci-lint", + "inherits": [ + "x64-linux-clang-20" + ] + }, { "name": "x64-linux-gcc", "inherits": [ "x64-linux" ], "cacheVariables": { - "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/tools/toolchains/x64-linux-gcc-12.cmake", + "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/tools/toolchains/x64-linux-gcc.cmake", "CMAKE_CXX_FLAGS": "-fconcepts-diagnostics-depth=0 -ftemplate-backtrace-limit=0 -fsanitize=address,leak,undefined -g -fno-omit-frame-pointer", "CMAKE_EXE_LINKER_FLAGS": "-fsanitize=address,leak,undefined" } }, + { + "name": "x64-linux-gcc-12", + "inherits": [ + "x64-linux-gcc" + ], + "cacheVariables": { + "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/tools/toolchains/x64-linux-gcc-12.cmake" + } + }, + { + "name": "x64-linux-gcc-ci", + "inherits": [ + "x64-linux-gcc-12" + ] + }, { "name": "arm64-macos-clang", "inherits": [ "base" ], "cacheVariables": { - "VCPKG_TARGET_TRIPLET": "arm64-macos-clang-16-brew", - "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/tools/toolchains/arm64-macos-clang-16-brew.cmake" + "VCPKG_TARGET_TRIPLET": "arm64-macos-clang-19-brew", + "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/tools/toolchains/arm64-macos-clang-19-brew.cmake" }, "vendor": { "microsoft.com/VisualStudioSettings/CMake/1.0": { @@ -169,6 +217,12 @@ } } }, + { + "name": "arm64-macos-clang-ci", + "inherits": [ + "arm64-macos-clang" + ] + }, { "name": "x64-macos-gcc", "inherits": [ @@ -185,6 +239,12 @@ ] } } + }, + { + "name": "x64-macos-gcc-ci", + "inherits": [ + "x64-macos-gcc" + ] } ], "buildPresets": [ @@ -198,6 +258,16 @@ "inherits": "x64-windows-msvc", "configuration": "RelWithDebInfo" }, + { + "name": "x64-windows-msvc-ci", + "configurePreset": "x64-windows-msvc-ci", + "configuration": "Debug" + }, + { + "name": "x64-windows-msvc-ci-release", + "inherits": "x64-windows-msvc-ci", + "configuration": "RelWithDebInfo" + }, { "name": "x64-windows-clang", "configurePreset": "x64-windows-clang", @@ -208,6 +278,16 @@ "inherits": "x64-windows-clang", "configuration": "RelWithDebInfo" }, + { + "name": "x64-windows-clang-ci", + "configurePreset": "x64-windows-clang-ci", + "configuration": "Debug" + }, + { + "name": "x64-windows-clang-ci-release", + "inherits": "x64-windows-clang-ci", + "configuration": "RelWithDebInfo" + }, { "name": "x64-linux-clang", "configurePreset": "x64-linux-clang", @@ -218,6 +298,16 @@ "inherits": "x64-linux-clang", "configuration": "RelWithDebInfo" }, + { + "name": "x64-linux-clang-ci", + "configurePreset": "x64-linux-clang-ci", + "configuration": "Debug" + }, + { + "name": "x64-linux-clang-ci-release", + "inherits": "x64-linux-clang-ci", + "configuration": "RelWithDebInfo" + }, { "name": "x64-linux-gcc", "configurePreset": "x64-linux-gcc", @@ -228,6 +318,16 @@ "inherits": "x64-linux-gcc", "configuration": "RelWithDebInfo" }, + { + "name": "x64-linux-gcc-ci", + "configurePreset": "x64-linux-gcc-ci", + "configuration": "Debug" + }, + { + "name": "x64-linux-gcc-ci-release", + "inherits": "x64-linux-gcc-ci", + "configuration": "RelWithDebInfo" + }, { "name": "arm64-macos-clang", "configurePreset": "arm64-macos-clang", @@ -238,6 +338,16 @@ "inherits": "arm64-macos-clang", "configuration": "RelWithDebInfo" }, + { + "name": "arm64-macos-clang-ci", + "configurePreset": "arm64-macos-clang-ci", + "configuration": "Debug" + }, + { + "name": "arm64-macos-clang-ci-release", + "inherits": "arm64-macos-clang-ci", + "configuration": "RelWithDebInfo" + }, { "name": "x64-macos-gcc", "configurePreset": "x64-macos-gcc", @@ -247,6 +357,16 @@ "name": "x64-macos-gcc-release", "inherits": "x64-macos-gcc", "configuration": "RelWithDebInfo" + }, + { + "name": "x64-macos-gcc-ci", + "configurePreset": "x64-macos-gcc-ci", + "configuration": "Debug" + }, + { + "name": "x64-macos-gcc-ci-release", + "inherits": "x64-macos-gcc-ci", + "configuration": "RelWithDebInfo" } ], "testPresets": [ @@ -268,6 +388,16 @@ "inherits": "x64-windows-msvc", "configuration": "RelWithDebInfo" }, + { + "name": "x64-windows-msvc-ci", + "configurePreset": "x64-windows-msvc-ci", + "configuration": "Debug" + }, + { + "name": "x64-windows-msvc-ci-release", + "inherits": "x64-windows-msvc-ci", + "configuration": "RelWithDebInfo" + }, { "name": "x64-windows-clang", "configurePreset": "x64-windows-clang", @@ -278,6 +408,16 @@ "inherits": "x64-windows-clang", "configuration": "RelWithDebInfo" }, + { + "name": "x64-windows-clang-ci", + "configurePreset": "x64-windows-clang-ci", + "configuration": "Debug" + }, + { + "name": "x64-windows-clang-ci-release", + "inherits": "x64-windows-clang-ci", + "configuration": "RelWithDebInfo" + }, { "name": "x64-linux-clang", "configurePreset": "x64-linux-clang", @@ -288,6 +428,16 @@ "inherits": "x64-linux-clang", "configuration": "RelWithDebInfo" }, + { + "name": "x64-linux-clang-ci", + "configurePreset": "x64-linux-clang-ci", + "configuration": "Debug" + }, + { + "name": "x64-linux-clang-ci-release", + "inherits": "x64-linux-clang-ci", + "configuration": "RelWithDebInfo" + }, { "name": "x64-linux-gcc", "inherits": "sanitizer_env", @@ -299,6 +449,17 @@ "inherits": "x64-linux-gcc", "configuration": "RelWithDebInfo" }, + { + "name": "x64-linux-gcc-ci", + "inherits": "sanitizer_env", + "configurePreset": "x64-linux-gcc-ci", + "configuration": "Debug" + }, + { + "name": "x64-linux-gcc-ci-release", + "inherits": "x64-linux-gcc-ci", + "configuration": "RelWithDebInfo" + }, { "name": "arm64-macos-clang", "configurePreset": "arm64-macos-clang", @@ -309,6 +470,16 @@ "inherits": "arm64-macos-clang", "configuration": "RelWithDebInfo" }, + { + "name": "arm64-macos-clang-ci", + "configurePreset": "arm64-macos-clang-ci", + "configuration": "Debug" + }, + { + "name": "arm64-macos-clang-ci-release", + "inherits": "arm64-macos-clang-ci", + "configuration": "RelWithDebInfo" + }, { "name": "x64-macos-gcc", "inherits": "sanitizer_env", @@ -319,6 +490,16 @@ "name": "x64-macos-gcc-release", "inherits": "x64-macos-gcc", "configuration": "RelWithDebInfo" + }, + { + "name": "x64-macos-gcc-ci", + "configurePreset": "x64-macos-gcc-ci", + "configuration": "Debug" + }, + { + "name": "x64-macos-gcc-ci-release", + "inherits": "x64-macos-gcc-ci", + "configuration": "RelWithDebInfo" } ] } \ No newline at end of file diff --git a/src/dp_tests/blob_matcher.hpp b/src/dp_tests/blob_matcher.hpp index 62aaa44b..f0b3c6df 100644 --- a/src/dp_tests/blob_matcher.hpp +++ b/src/dp_tests/blob_matcher.hpp @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -33,14 +34,9 @@ concept blob_like class BlobMatcher { - std::ptrdiff_t mMismatchOffset; + std::ptrdiff_t mMismatchOffset{-2}; public: - BlobMatcher() - : mMismatchOffset(-2) - { - } - template [[nodiscard]] auto match(ArgT const &arg, ExpectedT const &expected) noexcept -> bool @@ -56,8 +52,7 @@ class BlobMatcher return mMismatchOffset == -1; } - [[nodiscard]] inline auto mismatch_position() const noexcept - -> std::ptrdiff_t + [[nodiscard]] auto mismatch_position() const noexcept -> std::ptrdiff_t { return mMismatchOffset; } @@ -66,8 +61,7 @@ class BlobMatcher struct byte_equal { template - [[nodiscard]] inline auto operator()(LV lv, RV rv) const noexcept - -> bool + [[nodiscard]] auto operator()(LV lv, RV rv) const noexcept -> bool { return static_cast(lv) == static_cast(rv); @@ -78,7 +72,7 @@ class BlobMatcher struct as_printable_ascii { template - [[nodiscard]] inline auto operator()(C const c) const noexcept -> char + [[nodiscard]] auto operator()(C const c) const noexcept -> char { constexpr C isprint_ascii_lower_bound{0x32}; constexpr C isprint_ascii_upper_bound{0x7E}; @@ -88,6 +82,14 @@ struct as_printable_ascii } }; +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnon-virtual-dtor" +#elif defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" +#endif + template class BlobMatchExpr final : public Catch::ITransientExpression { @@ -98,9 +100,9 @@ class BlobMatchExpr final : public Catch::ITransientExpression BlobMatcher mMatcher; public: - inline BlobMatchExpr(ArgT &&arg, - ExpectedT &&expected, - BlobMatcher blobMatcher) + virtual ~BlobMatchExpr() = default; + // NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved) + BlobMatchExpr(ArgT &&arg, ExpectedT &&expected, BlobMatcher blobMatcher) : ITransientExpression{true, blobMatcher.match(arg, expected)} , mArg(CATCH_FORWARD(arg)) , mExpected(CATCH_FORWARD(expected)) @@ -156,21 +158,28 @@ class BlobMatchExpr final : public Catch::ITransientExpression as_printable_ascii{}); // this is a bit brittle, but Catch isn't exactly helpful in this case… - auto const prefixAlign = mismatchOffset * 3 + 1; + auto const prefixAlign = (mismatchOffset * 3) + 1; fmt::print(os, "pos: {:>{}}{:#06x}\n", " vv ", prefixAlign + 3, mismatchPosition); fmt::print(os, "val: {:>{}}{:02x} {:>{}}\n", " /", prefixAlign, fmt::join(argMismatch, argDisplayEnd, " "), strArg, - argNumSkipped * 3 + argNumDisplayed - 1); + (argNumSkipped * 3) + argNumDisplayed - 1); fmt::print(os, " {:02x}<\n", fmt::join(argDisplayBegin, argMismatch, " ")); fmt::print(os, "exp: {:>{}}{:02x} {:>{}}\n", " \\", prefixAlign, fmt::join(expectedMismatch, expectedDisplayEnd, " "), strExp, - expectedNumSkipped * 3 + expectedNumDisplayed - 1); + (expectedNumSkipped * 3) + expectedNumDisplayed - 1); } }; +#if defined(__clang__) +#pragma clang diagnostic pop +#elif defined(__GNUC__) +#pragma GCC diagnostic pop +#endif + template +// NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward) auto make_blob_match_expr(ArgT &&arg, ExpectedT &&expected) { return ::dp_tests::BlobMatchExpr( @@ -194,7 +203,7 @@ auto make_blob_match_expr(ArgT &&arg, ExpectedT &&expected) ::dp_tests::make_blob_match_expr(arg, expected)); \ } \ INTERNAL_CATCH_CATCH(catchAssertionHandler) \ - INTERNAL_CATCH_REACT(catchAssertionHandler) \ + catchAssertionHandler.complete(); \ } \ while (false) diff --git a/src/dp_tests/core_samples.hpp b/src/dp_tests/core_samples.hpp index 1a20fa6c..928fada1 100644 --- a/src/dp_tests/core_samples.hpp +++ b/src/dp_tests/core_samples.hpp @@ -55,7 +55,7 @@ auto integer_samples(item_sample_ct const (&samples)[N]) } constexpr item_sample_ct posint_samples[] = { - // Appendix A.Examples + // Appendix A.Examples {0x00, 1, {0b000'00000}}, {0x01, 1, {0b000'00001}}, {0x0a, 1, {0b000'01010}}, @@ -67,7 +67,7 @@ constexpr item_sample_ct posint_samples[] = { 0x0000'00e8'd4a5'1000, 9, {0x1b, 0x00, 0x00, 0x00, 0xe8, 0xd4, 0xa5, 0x10, 0x00}, }, - // boundary test cases + // boundary test cases {0x00, 1, {0b000'00000}}, {0x17, 1, {0b000'10111}}, {0x18, 2, {0x18, 0x18}}, @@ -101,11 +101,11 @@ constexpr item_sample_ct posint_samples[] = { }; constexpr item_sample_ct negint_samples[] = { - // Appendix A.Examples + // Appendix A.Examples {-10LL, 1, {0b001'01001}}, {-100LL, 2, {0x38, 0x63}}, {-1000LL, 3, {0x39, 0x03, 0xe7}}, - // boundary test cases + // boundary test cases {-0x01LL, 1, {0b001'00000}}, {-1 - 0x17LL, 1, {0b001'10111}}, {-1 - 0x18LL, 2, {0x38, 0x18}}, diff --git a/src/dp_tests/hex_decode.hpp b/src/dp_tests/hex_decode.hpp index 65a4e315..686742e7 100644 --- a/src/dp_tests/hex_decode.hpp +++ b/src/dp_tests/hex_decode.hpp @@ -25,9 +25,9 @@ constexpr auto is_hex_digit(char const digit) noexcept -> bool constexpr auto value_of_hex_digit(char const digit) noexcept -> std::uint8_t { - return static_cast((static_cast(digit) & 0xfU) - + (static_cast(digit) >> 6U) - * 9U); + return static_cast( + (static_cast(digit) & 0xfU) + + ((static_cast(digit) >> 6U) * 9U)); } constexpr auto hex_decode(std::uint8_t *const decoded, diff --git a/src/dp_tests/item_sample_ct.hpp b/src/dp_tests/item_sample_ct.hpp index 3859b322..943f8f79 100644 --- a/src/dp_tests/item_sample_ct.hpp +++ b/src/dp_tests/item_sample_ct.hpp @@ -17,6 +17,7 @@ #include #include #include +#include #include "dplx/dp/items/type_code.hpp" #include "test_utils.hpp" @@ -45,16 +46,17 @@ struct item_sample_ct friend inline auto operator<<(std::ostream &os, item_sample_ct const &sample) - -> std::ostream &requires(!detail::is_fmt_formattable) { - fmt::print( - os, - "{{item_value: , {}, 0x{:02x}}}", - sample.encoded_length, - fmt::join(sample.encoded_bytes(), "'")); - return os; - } friend inline auto - operator<<(std::ostream &os, item_sample_ct const &sample) - -> std::ostream & + -> std::ostream & + requires(!detail::is_fmt_formattable) + { + fmt::print(os, "{{item_value: , {}, 0x{:02x}}}", + sample.encoded_length, + fmt::join(sample.encoded_bytes(), "'")); + return os; + } + friend inline auto operator<<(std::ostream &os, + item_sample_ct const &sample) + -> std::ostream & { fmt::print(os, "{{item_value: {}, {}, 0x{:02x}}}", sample.value, sample.encoded_length, diff --git a/src/dp_tests/item_sample_rt.hpp b/src/dp_tests/item_sample_rt.hpp index b0f6b0e3..76741103 100644 --- a/src/dp_tests/item_sample_rt.hpp +++ b/src/dp_tests/item_sample_rt.hpp @@ -16,6 +16,7 @@ #include #include #include +#include #include "test_utils.hpp" @@ -42,15 +43,16 @@ struct item_sample_rt friend inline auto operator<<(std::ostream &os, item_sample_rt const &sample) - -> std::ostream &requires(!detail::is_fmt_formattable) { - fmt::print( - os, - "{{item_value[{}]: , 0x{:02x}}}", - sample.name, fmt::join(sample.encoded, "'")); - return os; - } friend inline auto - operator<<(std::ostream &os, item_sample_rt const &sample) - -> std::ostream & + -> std::ostream & + requires(!detail::is_fmt_formattable) + { + fmt::print(os, "{{item_value[{}]: , 0x{:02x}}}", + sample.name, fmt::join(sample.encoded, "'")); + return os; + } + friend inline auto operator<<(std::ostream &os, + item_sample_rt const &sample) + -> std::ostream & { fmt::print(os, "{{item_value[{}]: {}, 0x{:02x}}}", sample.name, sample.value, fmt::join(sample.encoded, "'")); diff --git a/src/dp_tests/yaml_sample_generator.hpp b/src/dp_tests/yaml_sample_generator.hpp index 0fc834b8..0ec228a6 100644 --- a/src/dp_tests/yaml_sample_generator.hpp +++ b/src/dp_tests/yaml_sample_generator.hpp @@ -115,7 +115,9 @@ class yaml_sample_loader final : public gens::IGenerator> public: explicit yaml_sample_loader(std::filesystem::path const &filename, std::string_view const slice) - try : mSamples(), mCurrent() + try + : mSamples() + , mCurrent() { std::ifstream file(filename); file.exceptions(std::ios_base::badbit | std::ios_base::failbit); diff --git a/src/dplx/dp/codecs/auto_object.test.cpp b/src/dplx/dp/codecs/auto_object.test.cpp index 65feca7a..035daa70 100644 --- a/src/dplx/dp/codecs/auto_object.test.cpp +++ b/src/dplx/dp/codecs/auto_object.test.cpp @@ -267,7 +267,8 @@ TEST_CASE("object codec helpers with layout descriptor") auto const &head = decodeHeadRx.assume_value(); CHECK(head.version == descriptor.version); - CHECK(head.num_properties == descriptor.num_properties); + CHECK(static_cast(head.num_properties) + == descriptor.num_properties); std::remove_cvref_t value{}; REQUIRE(dp::decode_object_properties( diff --git a/src/dplx/dp/codecs/auto_tuple.hpp b/src/dplx/dp/codecs/auto_tuple.hpp index 018d15a2..306a3650 100644 --- a/src/dplx/dp/codecs/auto_tuple.hpp +++ b/src/dplx/dp/codecs/auto_tuple.hpp @@ -8,6 +8,7 @@ #pragma once #include +#include #include @@ -212,7 +213,7 @@ inline auto decode_tuple_properties(parse_context &ctx, -> result { constexpr std::size_t expectedNumProps = descriptor.num_properties; - if (numProperties != expectedNumProps) + if (std::cmp_not_equal(numProperties, expectedNumProps)) { return errc::tuple_size_mismatch; } diff --git a/src/dplx/dp/codecs/fixed_u8string.test.cpp b/src/dplx/dp/codecs/fixed_u8string.test.cpp index b37525fb..70e6221c 100644 --- a/src/dplx/dp/codecs/fixed_u8string.test.cpp +++ b/src/dplx/dp/codecs/fixed_u8string.test.cpp @@ -27,10 +27,9 @@ namespace dp_tests static_assert(std::same_as, decltype(dp::fixed_u8string(u8"hello"))>); -static_assert( - std::same_as, - typename std::common_type, - dp::fixed_u8string<5>>::type>); +static_assert(std::same_as, + std::common_type_t, + dp::fixed_u8string<5>>>); // NOLINTEND(cppcoreguidelines-avoid-magic-numbers) TEST_CASE("fixed_u8string has a codec") diff --git a/src/dplx/dp/detail/perfect_hash.hpp b/src/dplx/dp/detail/perfect_hash.hpp index d7a68423..d84eaac5 100644 --- a/src/dplx/dp/detail/perfect_hash.hpp +++ b/src/dplx/dp/detail/perfect_hash.hpp @@ -115,19 +115,19 @@ struct least_uint using type = std::size_t; }; template - requires(N <= 0xffU) + requires(N <= UINT8_MAX) struct least_uint { using type = std::uint8_t; }; template - requires(0xffU < N && N <= 0xffffU) + requires(UINT8_MAX < N && N <= UINT16_MAX) struct least_uint { using type = std::uint16_t; }; template - requires(0xffffU < N && N <= 0xffff'ffffU) + requires(UINT16_MAX < N && N <= UINT32_MAX) struct least_uint { using type = std::uint32_t; diff --git a/src/dplx/dp/disappointment.hpp b/src/dplx/dp/disappointment.hpp index 006fed3c..784d1dfd 100644 --- a/src/dplx/dp/disappointment.hpp +++ b/src/dplx/dp/disappointment.hpp @@ -7,9 +7,9 @@ #pragma once -#include -#include -#include +#include +#include +#include #include #include @@ -22,10 +22,11 @@ namespace oc = outcome; using outcome::failure; using outcome::success; -enum class errc +// NOLINTNEXTLINE(performance-enum-size) +enum class errc : std::uint32_t { nothing = 0, - bad = 1, + bad, end_of_stream, invalid_additional_information, item_type_mismatch, @@ -61,7 +62,7 @@ struct status_enum_definition<::dplx::dp::errc> static constexpr char domain_name[] = "dplx::dp error domain"; static constexpr value_descriptor values[] = { - // clang-format off + // clang-format off { code::nothing, generic_errc::success, "no error/success" }, { code::bad, generic_errc::unknown, @@ -102,7 +103,7 @@ struct status_enum_definition<::dplx::dp::errc> "A binary/string CBOR item exceeded a size limit imposed by the user." }, { code::buffer_size_exceeded, generic_errc::no_buffer_space, "The require_input(amount)/ensure_size(amount) call failed due to `amount` exceeding the streams internal buffer size." }, - // clang-format on + // clang-format on }; static_assert(std::size(values) == static_cast(code::LIMIT)); diff --git a/src/dplx/dp/items/copy_item.cpp b/src/dplx/dp/items/copy_item.cpp index df9ffb10..850d89ee 100644 --- a/src/dplx/dp/items/copy_item.cpp +++ b/src/dplx/dp/items/copy_item.cpp @@ -148,6 +148,7 @@ auto copy_item_to(parse_context &ctx, output_buffer &out) noexcept do { auto &item = stack.back(); + // NOLINTNEXTLINE(bugprone-switch-missing-default-case) switch (static_cast(item.type) >> majorTypeBitOffset) { case static_cast(type_code::special) >> majorTypeBitOffset: diff --git a/src/dplx/dp/items/emit_core.hpp b/src/dplx/dp/items/emit_core.hpp index be0ce300..7376352d 100644 --- a/src/dplx/dp/items/emit_core.hpp +++ b/src/dplx/dp/items/emit_core.hpp @@ -37,6 +37,7 @@ inline auto store_var_uint_eos(output_buffer &out, auto *const dest = out.data(); // NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers) // NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic) + // NOLINTNEXTLINE(bugprone-switch-missing-default-case) switch (bytePowerPlus2) { case 1U: diff --git a/src/dplx/dp/items/parse_core.hpp b/src/dplx/dp/items/parse_core.hpp index 5c8891bf..c3453513 100644 --- a/src/dplx/dp/items/parse_core.hpp +++ b/src/dplx/dp/items/parse_core.hpp @@ -137,6 +137,7 @@ inline auto do_parse_item_head(parse_context &ctx) noexcept -> result { // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) std::byte const *const payload = ctx.in.data() + 1; + // NOLINTNEXTLINE(bugprone-switch-missing-default-case) switch (sizeBytesPower) { case 0U: diff --git a/src/dplx/dp/items/parse_core.test.cpp b/src/dplx/dp/items/parse_core.test.cpp index aac323dd..c5a1f9ff 100644 --- a/src/dplx/dp/items/parse_core.test.cpp +++ b/src/dplx/dp/items/parse_core.test.cpp @@ -25,7 +25,7 @@ namespace dp_tests using enum dp::type_code; constexpr item_sample_ct parse_samples[] = { - // clang-format off + // clang-format off // Appendix A.Examples { @@ -117,7 +117,7 @@ constexpr item_sample_ct parse_samples[] = { 1, {0xff}, }, - // clang-format on + // clang-format on }; TEST_CASE("parse_item_head_speculative can parse basic item_heads") @@ -314,7 +314,7 @@ TEMPLATE_TEST_CASE("parse_integer parses positive integers", { simple_test_parse_context ctx(sample.encoded_bytes()); - TestType value; + TestType value{}; result rx = dp::parse_integer(ctx.as_parse_context(), value); if (std::in_range(sample.value)) @@ -333,7 +333,7 @@ TEMPLATE_TEST_CASE("parse_integer parses positive integers", { simple_test_parse_context ctx(as_bytes(std::span(sample.encoded))); - TestType value; + TestType value{}; result rx = dp::parse_integer(ctx.as_parse_context(), value); if (std::in_range(sample.value)) diff --git a/src/dplx/dp/items/skip_item.cpp b/src/dplx/dp/items/skip_item.cpp index e7a83642..7e6e2c07 100644 --- a/src/dplx/dp/items/skip_item.cpp +++ b/src/dplx/dp/items/skip_item.cpp @@ -79,6 +79,7 @@ auto skip_item(parse_context &ctx) noexcept -> result do { auto &item = stack.back(); + // NOLINTNEXTLINE(bugprone-switch-missing-default-case) switch (static_cast(item.type) >> majorTypeBitOffset) { case static_cast(type_code::special) >> majorTypeBitOffset: diff --git a/src/dplx/dp/legacy/chunked_input_stream.hpp b/src/dplx/dp/legacy/chunked_input_stream.hpp index 53d20d89..25f61d1b 100644 --- a/src/dplx/dp/legacy/chunked_input_stream.hpp +++ b/src/dplx/dp/legacy/chunked_input_stream.hpp @@ -23,6 +23,8 @@ namespace dplx::dp::legacy template class chunked_input_stream_base : public input_buffer { + friend Impl; + memory_view mReadArea; static constexpr unsigned int small_buffer_size @@ -33,18 +35,21 @@ class chunked_input_stream_base : public input_buffer protected: ~chunked_input_stream_base() noexcept = default; + +private: // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) explicit chunked_input_stream_base( std::span const initialReadArea, std::uint64_t streamSize) : input_buffer( - initialReadArea.data(), initialReadArea.size(), streamSize) + initialReadArea.data(), initialReadArea.size(), streamSize) , mReadArea(initialReadArea) , mBufferStart(-1) , mSmallBuffer{} { } +protected: [[nodiscard]] inline auto current_read_area() const noexcept -> memory_view { memory_view readArea{mReadArea}; diff --git a/src/dplx/dp/legacy/chunked_input_stream.test.cpp b/src/dplx/dp/legacy/chunked_input_stream.test.cpp index 790ac3c6..157d7bd6 100644 --- a/src/dplx/dp/legacy/chunked_input_stream.test.cpp +++ b/src/dplx/dp/legacy/chunked_input_stream.test.cpp @@ -34,7 +34,8 @@ class test_legacy_chunked_input_stream final std::array, 2> mChunks; unsigned int mNext = 0; - static constexpr auto partition = dp::minimum_guaranteed_read_size * 2 - 1; + static constexpr auto partition + = (dp::minimum_guaranteed_read_size * 2) - 1; explicit test_legacy_chunked_input_stream(unsigned int streamSize) : base_type({}, streamSize) , mChunks() @@ -70,7 +71,7 @@ class test_legacy_chunked_input_stream final TEST_CASE("legacy_chunked_input_stream smoke tests") { test_legacy_chunked_input_stream subject( - dp::minimum_guaranteed_read_size * 4 - 1); + (dp::minimum_guaranteed_read_size * 4) - 1); std::array vals{}; REQUIRE(subject.bulk_read(vals.data(), vals.size())); diff --git a/src/dplx/dp/legacy/chunked_output_stream.hpp b/src/dplx/dp/legacy/chunked_output_stream.hpp index eee2c6f0..3d9c0a24 100644 --- a/src/dplx/dp/legacy/chunked_output_stream.hpp +++ b/src/dplx/dp/legacy/chunked_output_stream.hpp @@ -22,6 +22,8 @@ namespace dplx::dp::legacy template class chunked_output_stream_base : public output_buffer { + friend Impl; + std::span mCurrentChunk; size_type mRemaining; @@ -33,6 +35,8 @@ class chunked_output_stream_base : public output_buffer protected: ~chunked_output_stream_base() noexcept = default; + +private: // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) chunked_output_stream_base(std::span initialWriteArea, size_type remaining) noexcept @@ -44,7 +48,6 @@ class chunked_output_stream_base : public output_buffer { } -private: auto impl() noexcept -> Impl * { return static_cast(this); @@ -59,9 +62,10 @@ class chunked_output_stream_base : public output_buffer using byte_span = std::span; DPLX_TRY(byte_span const nextChunk, impl()->acquire_next_chunk_impl()); - mCurrentChunk = nextChunk.size() > mRemaining ? nextChunk.first( - static_cast(mRemaining)) - : nextChunk; + mCurrentChunk = nextChunk.size() > mRemaining + ? nextChunk.first( + static_cast(mRemaining)) + : nextChunk; mRemaining -= mCurrentChunk.size(); @@ -92,12 +96,13 @@ class chunked_output_stream_base : public output_buffer auto const chunkPart = mCurrentChunk.last( static_cast(mDecomissionThreshold)); - auto const consumedSize = static_cast( - data() - static_cast(mSmallBuffer)); - if (consumedSize < static_cast(mDecomissionThreshold)) + auto const consumedSize + = data() - static_cast(mSmallBuffer); + if (consumedSize < mDecomissionThreshold) { std::memcpy(chunkPart.data(), - static_cast(mSmallBuffer), consumedSize); + static_cast(mSmallBuffer), + static_cast(consumedSize)); reset(static_cast(mSmallBuffer), small_buffer_size); mDecomissionThreshold -= static_cast(consumedSize); @@ -115,16 +120,18 @@ class chunked_output_stream_base : public output_buffer chunkPart.size()); } - auto const overlap = consumedSize - - static_cast(mDecomissionThreshold); + auto const overlap = consumedSize - mDecomissionThreshold; if (auto acquireRx = acquire_next_chunk(); acquireRx.has_error()) [[unlikely]] { - move_remaining_small_buffer_to_front(overlap); + move_remaining_small_buffer_to_front( + static_cast(overlap)); return std::move(acquireRx).assume_error(); } - if (!try_move_small_buffer_to_next_chunk(overlap) && mRemaining == 0) + if (!try_move_small_buffer_to_next_chunk( + static_cast(overlap)) + && mRemaining == 0) { return errc::end_of_stream; } @@ -199,14 +206,15 @@ class chunked_output_stream_base : public output_buffer auto const chunkPart = mCurrentChunk.last( static_cast(mDecomissionThreshold)); - auto const consumedSize = static_cast( - data() - static_cast(mSmallBuffer)); - if (consumedSize <= static_cast(mDecomissionThreshold)) + auto const consumedSize + = data() - static_cast(mSmallBuffer); + if (consumedSize <= mDecomissionThreshold) { // written data still does not exceed current chunk std::memcpy(chunkPart.data(), - static_cast(mSmallBuffer), consumedSize); - if (consumedSize == static_cast(mDecomissionThreshold)) + static_cast(mSmallBuffer), + static_cast(consumedSize)); + if (consumedSize == mDecomissionThreshold) { // avoid acquiring a new chunk as sync_output is usually called // as a cleanup operation and a new chunk would go to waste @@ -226,16 +234,17 @@ class chunked_output_stream_base : public output_buffer std::memcpy(chunkPart.data(), static_cast(mSmallBuffer), chunkPart.size()); - auto const overlap = consumedSize - - static_cast(mDecomissionThreshold); + auto const overlap = consumedSize - mDecomissionThreshold; if (auto acquireRx = acquire_next_chunk(); acquireRx.has_error()) [[unlikely]] { - move_remaining_small_buffer_to_front(overlap); + move_remaining_small_buffer_to_front( + static_cast(overlap)); return std::move(acquireRx).assume_error(); } - if (!try_move_small_buffer_to_next_chunk(overlap)) + if (!try_move_small_buffer_to_next_chunk( + static_cast(overlap))) { return errc::end_of_stream; } diff --git a/src/dplx/dp/legacy/chunked_output_stream.test.cpp b/src/dplx/dp/legacy/chunked_output_stream.test.cpp index 1b472417..d4874152 100644 --- a/src/dplx/dp/legacy/chunked_output_stream.test.cpp +++ b/src/dplx/dp/legacy/chunked_output_stream.test.cpp @@ -36,7 +36,7 @@ class test_legacy_chunked_output_stream final unsigned mNext; static constexpr auto partition - = dp::minimum_guaranteed_write_size * 2U - 1U; + = (dp::minimum_guaranteed_write_size * 2U) - 1U; explicit test_legacy_chunked_output_stream(unsigned streamSize) : base_type({}, streamSize) @@ -80,7 +80,7 @@ class test_legacy_chunked_output_stream final TEST_CASE("legacy_chunked_output_stream smoke tests") { test_legacy_chunked_output_stream subject( - dp::minimum_guaranteed_write_size * 4 - 1); + (dp::minimum_guaranteed_write_size * 4) - 1); std::array vals{}; REQUIRE(subject.bulk_write(vals.data(), vals.size())); @@ -92,7 +92,7 @@ TEST_CASE("legacy_chunked_output_stream smoke tests") // NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic) TEST_CASE("legacy_chunked_output_stream wraps correctly with do_grow") { - constexpr unsigned streamSize = dp::minimum_guaranteed_write_size * 4 - 1; + constexpr unsigned streamSize = (dp::minimum_guaranteed_write_size * 4) - 1; test_legacy_chunked_output_stream subject(streamSize); REQUIRE(subject.ensure_size(1U)); diff --git a/src/dplx/dp/legacy/memory_buffer.hpp b/src/dplx/dp/legacy/memory_buffer.hpp index b5e25829..8fd1778a 100644 --- a/src/dplx/dp/legacy/memory_buffer.hpp +++ b/src/dplx/dp/legacy/memory_buffer.hpp @@ -56,7 +56,7 @@ class basic_memory_buffer requires(std::convertible_to) explicit constexpr basic_memory_buffer(std::span const &memory) : basic_memory_buffer( - memory.data(), static_cast(memory.size_bytes()), 0) + memory.data(), static_cast(memory.size_bytes()), 0) { } template diff --git a/src/dplx/dp/legacy/memory_input_stream.hpp b/src/dplx/dp/legacy/memory_input_stream.hpp index 36e9d9e5..bec0b248 100644 --- a/src/dplx/dp/legacy/memory_input_stream.hpp +++ b/src/dplx/dp/legacy/memory_input_stream.hpp @@ -28,6 +28,7 @@ template // NOLINTNEXTLINE(cppcoreguidelines-virtual-class-destructor) class legacy_memory_input_stream final : public input_buffer { + // NOLINTNEXTLINE(cppcoreguidelines-avoid-const-or-ref-data-members) basic_memory_buffer &mImpl; public: diff --git a/src/dplx/dp/legacy/memory_input_stream.test.cpp b/src/dplx/dp/legacy/memory_input_stream.test.cpp index 8c4972a0..d65a7d1e 100644 --- a/src/dplx/dp/legacy/memory_input_stream.test.cpp +++ b/src/dplx/dp/legacy/memory_input_stream.test.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include diff --git a/src/dplx/dp/legacy/memory_output_stream.hpp b/src/dplx/dp/legacy/memory_output_stream.hpp index 7c0f81e7..f2960fc0 100644 --- a/src/dplx/dp/legacy/memory_output_stream.hpp +++ b/src/dplx/dp/legacy/memory_output_stream.hpp @@ -23,6 +23,7 @@ namespace detail // NOLINTNEXTLINE(cppcoreguidelines-virtual-class-destructor) class legacy_memory_output_stream final : public output_buffer { + // NOLINTNEXTLINE(cppcoreguidelines-avoid-const-or-ref-data-members) memory_buffer &mImpl; public: diff --git a/src/dplx/dp/state.hpp b/src/dplx/dp/state.hpp index 102f99e5..49093810 100644 --- a/src/dplx/dp/state.hpp +++ b/src/dplx/dp/state.hpp @@ -208,7 +208,7 @@ using flat_hash_map = boost::unordered_flat_map< T, std::hash, std::equal_to<>, - std::pmr::polymorphic_allocator>>; + std::pmr::polymorphic_allocator>>; } diff --git a/tools/cmake/CompilerWarnings.cmake b/tools/cmake/CompilerWarnings.cmake index 8dc0ffc4..44be4443 100644 --- a/tools/cmake/CompilerWarnings.cmake +++ b/tools/cmake/CompilerWarnings.cmake @@ -30,8 +30,6 @@ set(CLANG_WARNINGS -Wall -Wextra # reasonable and standard -Wshadow # warn the user if a variable declaration shadows one from a parent context - -Wnon-virtual-dtor # warn the user if a class with virtual functions has a non-virtual destructor. This helps - # catch hard to track down memory errors -Wold-style-cast # warn for c-style casts -Wcast-align # warn for potential performance problem casts -Wunused # warn on anything being unused diff --git a/tools/cmake/VcpkgDefaults.cmake b/tools/cmake/VcpkgDefaults.cmake index 618a940f..dfc96bec 100644 --- a/tools/cmake/VcpkgDefaults.cmake +++ b/tools/cmake/VcpkgDefaults.cmake @@ -11,6 +11,3 @@ endif() if(NOT DEFINED VCPKG_FEATURE_FLAGS) set(VCPKG_FEATURE_FLAGS "registries" CACHE STRING "") endif() -if(NOT DEFINED VCPKG_OVERLAY_TRIPLETS) - set(VCPKG_OVERLAY_TRIPLETS "${CMAKE_SOURCE_DIR}/tools/triplets" CACHE STRING "") -endif() diff --git a/tools/config.hpp.in b/tools/config.hpp.in index 861d0969..d1c901b0 100644 --- a/tools/config.hpp.in +++ b/tools/config.hpp.in @@ -9,11 +9,13 @@ // NOLINTBEGIN(modernize-macro-to-enum) // NOLINTBEGIN(cppcoreguidelines-macro-usage) +// NOLINTBEGIN(cppcoreguidelines-macro-to-enum) #cmakedefine01 DPLX_DP_USE_BRANCHING_INTEGER_ENCODER #cmakedefine01 DPLX_DP_DISABLE_WORKAROUNDS #cmakedefine01 DPLX_DP_FLAG_OUTDATED_WORKAROUNDS +// NOLINTEND(cppcoreguidelines-macro-to-enum) // NOLINTEND(cppcoreguidelines-macro-usage) // NOLINTEND(modernize-macro-to-enum) diff --git a/tools/ports/fmt/portfile.cmake b/tools/ports/fmt/portfile.cmake new file mode 100644 index 00000000..81fd4ff4 --- /dev/null +++ b/tools/ports/fmt/portfile.cmake @@ -0,0 +1,28 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO fmtlib/fmt + REF "${VERSION}" + SHA512 46974efd36e613477351aa357c451cee434da797c2a505f9f86d73e394dcb35dc2dc0cda66abb98c023e8f24deac9d8e3ee6f9f6c0971cc4c00e37c34aa7f15f + HEAD_REF master +) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DFMT_CMAKE_DIR=share/fmt + -DFMT_TEST=OFF + -DFMT_DOC=OFF +) + +vcpkg_cmake_install() +vcpkg_cmake_config_fixup() +vcpkg_fixup_pkgconfig() +vcpkg_copy_pdbs() + +file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/debug/include" + "${CURRENT_PACKAGES_DIR}/debug/share" +) + +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") diff --git a/tools/ports/fmt/usage b/tools/ports/fmt/usage new file mode 100644 index 00000000..e5a9d704 --- /dev/null +++ b/tools/ports/fmt/usage @@ -0,0 +1,8 @@ +The package fmt provides CMake targets: + + find_package(fmt CONFIG REQUIRED) + target_link_libraries(main PRIVATE fmt::fmt) + + # Or use the header-only version + find_package(fmt CONFIG REQUIRED) + target_link_libraries(main PRIVATE fmt::fmt-header-only) diff --git a/tools/ports/fmt/vcpkg.json b/tools/ports/fmt/vcpkg.json new file mode 100644 index 00000000..0ed7a4f6 --- /dev/null +++ b/tools/ports/fmt/vcpkg.json @@ -0,0 +1,17 @@ +{ + "name": "fmt", + "version": "11.2.0", + "description": "{fmt} is an open-source formatting library providing a fast and safe alternative to C stdio and C++ iostreams.", + "homepage": "https://github.com/fmtlib/fmt", + "license": "MIT", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ] +} \ No newline at end of file diff --git a/tools/toolchains/arm64-macos-clang-16-brew.cmake b/tools/toolchains/arm64-macos-clang-19-brew.cmake similarity index 60% rename from tools/toolchains/arm64-macos-clang-16-brew.cmake rename to tools/toolchains/arm64-macos-clang-19-brew.cmake index cdd66d85..68587e6d 100644 --- a/tools/toolchains/arm64-macos-clang-16-brew.cmake +++ b/tools/toolchains/arm64-macos-clang-19-brew.cmake @@ -1,14 +1,14 @@ set(CMAKE_SYSTEM_PROCESSOR arm64) -execute_process(COMMAND brew --prefix llvm@16 OUTPUT_VARIABLE BREW_LLVM_PATH OUTPUT_STRIP_TRAILING_WHITESPACE) +execute_process(COMMAND brew --prefix llvm@19 OUTPUT_VARIABLE BREW_LLVM_PATH OUTPUT_STRIP_TRAILING_WHITESPACE) set(CMAKE_C_COMPILER "${BREW_LLVM_PATH}/bin/clang") set(CMAKE_CXX_COMPILER "${BREW_LLVM_PATH}/bin/clang++") -set(CMAKE_OSX_DEPLOYMENT_TARGET 14.0 CACHE STRING "OSX deployment target") +set(CMAKE_OSX_DEPLOYMENT_TARGET 15.5 CACHE STRING "OSX deployment target") set(CMAKE_OSX_ARCHITECTURES arm64 CACHE STRING "OSX target architectures") -set(CMAKE_OSX_SYSROOT /Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk CACHE FILEPATH "The macos SDK to use") set(CMAKE_C_STANDARD 17 CACHE STRING "C standard") set(CMAKE_CXX_STANDARD 20 CACHE STRING "C++ standard") set(CMAKE_CXX_FLAGS_INIT "-fsized-deallocation") +set(CMAKE_CXX_SCAN_FOR_MODULES OFF) diff --git a/tools/toolchains/x64-linux-clang-16.cmake b/tools/toolchains/x64-linux-clang-19.cmake similarity index 57% rename from tools/toolchains/x64-linux-clang-16.cmake rename to tools/toolchains/x64-linux-clang-19.cmake index a7d3ef9a..f2967806 100644 --- a/tools/toolchains/x64-linux-clang-16.cmake +++ b/tools/toolchains/x64-linux-clang-19.cmake @@ -1,11 +1,10 @@ set(CMAKE_SYSTEM_PROCESSOR AMD64) -set(CMAKE_C_COMPILER clang-16) -set(CMAKE_CXX_COMPILER clang++-16) +set(CMAKE_C_COMPILER clang-19) +set(CMAKE_CXX_COMPILER clang++-19) set(CMAKE_C_STANDARD 17) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_FLAGS_INIT "-fsized-deallocation") - -set(CMAKE_CXX_SCAN_FOR_MODULES 0) +set(CMAKE_CXX_SCAN_FOR_MODULES OFF) diff --git a/tools/toolchains/x64-linux-clang-20.cmake b/tools/toolchains/x64-linux-clang-20.cmake new file mode 100644 index 00000000..274a7833 --- /dev/null +++ b/tools/toolchains/x64-linux-clang-20.cmake @@ -0,0 +1,10 @@ +set(CMAKE_SYSTEM_PROCESSOR AMD64) + +set(CMAKE_C_COMPILER clang-20) +set(CMAKE_CXX_COMPILER clang++-20) + +set(CMAKE_C_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) + +set(CMAKE_CXX_FLAGS_INIT "-fsized-deallocation") +set(CMAKE_CXX_SCAN_FOR_MODULES OFF) diff --git a/tools/toolchains/x64-linux-clang.cmake b/tools/toolchains/x64-linux-clang.cmake index 5220a4fa..20e20f7a 100644 --- a/tools/toolchains/x64-linux-clang.cmake +++ b/tools/toolchains/x64-linux-clang.cmake @@ -7,3 +7,4 @@ set(CMAKE_C_STANDARD 17) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_FLAGS_INIT "-fsized-deallocation") +set(CMAKE_CXX_SCAN_FOR_MODULES OFF) diff --git a/tools/toolchains/x64-linux-gcc-12.cmake b/tools/toolchains/x64-linux-gcc-12.cmake index a1790c6c..92919b50 100644 --- a/tools/toolchains/x64-linux-gcc-12.cmake +++ b/tools/toolchains/x64-linux-gcc-12.cmake @@ -5,3 +5,5 @@ set(CMAKE_CXX_COMPILER g++-12) set(CMAKE_C_STANDARD 17) set(CMAKE_CXX_STANDARD 20) + +set(CMAKE_CXX_SCAN_FOR_MODULES OFF) diff --git a/tools/toolchains/x64-linux-gcc.cmake b/tools/toolchains/x64-linux-gcc.cmake new file mode 100644 index 00000000..d16cb894 --- /dev/null +++ b/tools/toolchains/x64-linux-gcc.cmake @@ -0,0 +1,9 @@ +set(CMAKE_SYSTEM_PROCESSOR AMD64) + +set(CMAKE_C_COMPILER gcc) +set(CMAKE_CXX_COMPILER g++) + +set(CMAKE_C_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) + +set(CMAKE_CXX_SCAN_FOR_MODULES OFF) diff --git a/tools/toolchains/x64-macos-gcc-12.cmake b/tools/toolchains/x64-macos-gcc-12.cmake index e048e984..9a2f9dce 100644 --- a/tools/toolchains/x64-macos-gcc-12.cmake +++ b/tools/toolchains/x64-macos-gcc-12.cmake @@ -2,11 +2,12 @@ set(CMAKE_SYSTEM_PROCESSOR AMD64) set(CMAKE_C_COMPILER gcc-12) set(CMAKE_CXX_COMPILER g++-12) -set(CMAKE_OSX_DEPLOYMENT_TARGET 14.0 CACHE STRING "OSX deployment target") +set(CMAKE_OSX_DEPLOYMENT_TARGET 14.2 CACHE STRING "OSX deployment target") set(CMAKE_OSX_ARCHITECTURES x86_64 CACHE STRING "OSX target architectures") -set(CMAKE_OSX_SYSROOT /Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk CACHE FILEPATH "The macos SDK to use") -# the new linker currently segfaults with gcc (I believe this is fixed with gcc 14) -set(CMAKE_CXX_FLAGS_INIT "-Wl,-ld_classic") set(CMAKE_C_STANDARD 17) set(CMAKE_CXX_STANDARD 20) + +# the new linker currently segfaults with gcc (I believe this is fixed with gcc 14) +set(CMAKE_CXX_FLAGS_INIT "-Wl,-ld_classic") +set(CMAKE_CXX_SCAN_FOR_MODULES OFF) diff --git a/tools/triplets/arm64-macos-clang-16-brew.cmake b/tools/triplets/arm64-macos-clang-19-brew.cmake similarity index 88% rename from tools/triplets/arm64-macos-clang-16-brew.cmake rename to tools/triplets/arm64-macos-clang-19-brew.cmake index 536b7ad3..d3431d14 100644 --- a/tools/triplets/arm64-macos-clang-16-brew.cmake +++ b/tools/triplets/arm64-macos-clang-19-brew.cmake @@ -4,7 +4,7 @@ set(VCPKG_LIBRARY_LINKAGE static) set(VCPKG_CMAKE_SYSTEM_NAME Darwin) set(VCPKG_OSX_ARCHITECTURES arm64) -set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/../toolchains/arm64-macos-clang-16-brew.cmake") +set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/../toolchains/arm64-macos-clang-19-brew.cmake") if(PORT STREQUAL "status-code") set(VCPKG_CMAKE_CONFIGURE_OPTIONS "-DBUILD_TESTING=OFF") diff --git a/tools/triplets/x64-linux-clang-16.cmake b/tools/triplets/x64-linux-clang-19.cmake similarity index 83% rename from tools/triplets/x64-linux-clang-16.cmake rename to tools/triplets/x64-linux-clang-19.cmake index c06c8bb9..869cca43 100644 --- a/tools/triplets/x64-linux-clang-16.cmake +++ b/tools/triplets/x64-linux-clang-19.cmake @@ -3,4 +3,4 @@ set(VCPKG_CRT_LINKAGE dynamic) set(VCPKG_LIBRARY_LINKAGE static) set(VCPKG_CMAKE_SYSTEM_NAME Linux) -set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/../toolchains/x64-linux-clang-16.cmake") +set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/../toolchains/x64-linux-clang-19.cmake") diff --git a/tools/triplets/x64-linux-clang-20.cmake b/tools/triplets/x64-linux-clang-20.cmake new file mode 100644 index 00000000..08e130f4 --- /dev/null +++ b/tools/triplets/x64-linux-clang-20.cmake @@ -0,0 +1,6 @@ +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) + +set(VCPKG_CMAKE_SYSTEM_NAME Linux) +set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/../toolchains/x64-linux-clang-20.cmake") diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json index 2e8038ec..8e4ede36 100644 --- a/vcpkg-configuration.json +++ b/vcpkg-configuration.json @@ -2,16 +2,22 @@ "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg-configuration.schema.json", "default-registry": { "kind": "builtin", - "baseline": "a42af01b72c28a8e1d7b48107b33e4f286a55ef6" + "baseline": "ce613c41372b23b1f51333815feb3edd87ef8a8b" }, + "overlay-triplets": [ + "tools/triplets" + ], "registries": [ { "kind": "git", "repository": "https://github.com/deeplex/vcpkg-registry", - "baseline": "0a1cf2aba847e4074950a3061f5f7251f388e61f", + "baseline": "90373c127f67e25393120e7332270aa1a27d54f8", "packages": [ "concrete" ] } + ], + "overlay-ports": [ + "tools/ports" ] } \ No newline at end of file