diff --git a/.github/workflows/cpp-ci-serial-programs.yml b/.github/workflows/cpp-ci-serial-programs.yml index 140bc1362..7500689d0 100644 --- a/.github/workflows/cpp-ci-serial-programs.yml +++ b/.github/workflows/cpp-ci-serial-programs.yml @@ -50,7 +50,7 @@ jobs: run: | sudo apt update sudo apt upgrade - sudo apt install libopencv-dev + sudo apt install libopencv-dev clang-tools sudo apt install ./Arduino-Source/3rdPartyBinaries/libdpp-10.0.28-linux-x64.deb - name: Install dependencies if: startsWith(matrix.os, 'mac') @@ -68,6 +68,25 @@ jobs: cd bin cmake .. -DQT_MAJOR:STRING=${{ matrix.qt_version_major }} ${{ matrix.cmake_additional_param }} cmake --build . --config RelWithDebInfo --parallel 10 + - name: Run clang query + if: startsWith(matrix.os, 'ubuntu') + run : | + cd Arduino-Source + echo 'match cxxConstructExpr( ' >> query.txt + echo ' hasDeclaration(cxxConstructorDecl(ofClass(hasName("std::filesystem::path")))),' >> query.txt + echo ' hasArgument(0, ' >> query.txt + echo ' ignoringParenImpCasts( ' >> query.txt + echo ' hasType(hasDeclaration(hasName("std::basic_string"))) ' >> query.txt + echo ' ) ' >> query.txt + echo ' ) ' >> query.txt + echo ') ' >> query.txt + files=$(jq -r '.[].file' SerialPrograms/bin/compile_commands.json) + clang-query -p SerialPrograms/bin/ -f query.txt /home/runner/work/Arduino-Source/Arduino-Source/Arduino-Source/SerialPrograms/Source/CommonFramework/Globals.cpp + echo "$files" | xargs --max-args=150 clang-query -p SerialPrograms/bin/ -f query.txt >> output.txt + if grep --silent "Match #" output.txt; then + echo "::error Forbidden std::filesystem::path construction detected!" + exit 1 + fi - name: Prepare upload folder if: startsWith(matrix.os, 'windows') run: | diff --git a/SerialPrograms/Source/CommonFramework/Globals.cpp b/SerialPrograms/Source/CommonFramework/Globals.cpp index 02fa6c41a..d210240c9 100644 --- a/SerialPrograms/Source/CommonFramework/Globals.cpp +++ b/SerialPrograms/Source/CommonFramework/Globals.cpp @@ -229,6 +229,8 @@ namespace { void set_program_path(const char* argv0){ if (argv0 != nullptr) { + std::string str{}; + std::filesystem::path{str} std::filesystem::path program_path(argv0); g_program_absolute_path = std::filesystem::absolute(program_path).string(); g_program_filename = program_path.filename().string();