From 449f5b6eac2dd6e07233fb1cc57a358f994c539d Mon Sep 17 00:00:00 2001 From: vla5924 Date: Sun, 9 Mar 2025 18:17:22 +0300 Subject: [PATCH 1/3] add --- .github/workflows/ci.yml | 48 ++++++----------------------------- compiler/lib/cli/compiler.cpp | 1 - 2 files changed, 8 insertions(+), 41 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f6b509ab..81b0457e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,8 +39,8 @@ jobs: extensions: 'hpp,cpp' clangFormatVersion: 17 - build-gcc: - name: Build on Ubuntu GCC + build-test-gcc: + name: Build and test on Ubuntu GCC runs-on: ubuntu-latest needs: code-style-check container: @@ -62,6 +62,7 @@ jobs: git config --global --add safe.directory $(pwd) cmake -S compiler -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DENABLE_CODEGEN='ast_to_llvmir;optree_to_llvmir' cmake --build build --parallel + ctest --test-dir build --output-on-failure - name: Archive binaries run: tar cf binaries.tar -C build bin - name: Upload binaries @@ -70,7 +71,7 @@ jobs: name: binaries-ubuntu-latest-gcc path: binaries.tar - build-clang: + build-test-clang: name: Build on Ubuntu Clang runs-on: ubuntu-latest needs: code-style-check @@ -92,8 +93,9 @@ jobs: run: | cmake -S compiler -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DENABLE_CODEGEN='ast_to_llvmir;optree_to_llvmir' cmake --build build --parallel + ctest --test-dir build --output-on-failure - build-msvc: + build-test-msvc: name: Build on Windows MSVC runs-on: windows-latest needs: code-style-check @@ -106,45 +108,12 @@ jobs: run: | cmake -S compiler -B build -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release cmake --build build --parallel - - unit-test: - name: Unit test - runs-on: ubuntu-latest - needs: build-gcc - container: - image: ghcr.io/vla5924-practice/compiler-project/devcontainer:latest - options: --user root - credentials: - username: ${{ github.actor }} - password: ${{ secrets.github_token }} - steps: - - name: Download binaries - uses: actions/download-artifact@v4 - with: - name: binaries-ubuntu-latest-gcc - - name: Extract binaries - run: tar xf binaries.tar - - name: Run AST interface tests - run: ./bin/ast_test - - name: Run operation tree interface tests - run: ./bin/optree_test - - name: Run frontend tests - run: ./bin/frontend_test - - name: Run AST-based backend tests - run: ./bin/backend_ast_test - - name: Run optree-based backend tests - run: ./bin/backend_optree_test - - name: Run codegen tests (AST to LLVM IR) - run: ./bin/codegen_ast_to_llvmir_test - - name: Run codegen tests (optree to LLVM IR) - run: ./bin/codegen_optree_to_llvmir_test - - name: Run utility tests - run: ./bin/utils_test + ctest --test-dir build --output-on-failure code-coverage: name: Code coverage runs-on: ubuntu-latest - needs: build-gcc + needs: build-test-gcc container: image: ghcr.io/vla5924-practice/compiler-project/devcontainer:latest options: --user root @@ -209,7 +178,6 @@ jobs: - name: Build compilation database run: | cmake -S compiler -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DENABLE_CODEGEN='ast_to_llvmir;optree_to_llvmir' - cmake --build build --parallel - name: Run clang-tidy analysis run: | git diff -U0 origin/main | clang-tidy-diff -p1 -path build > clang-tidy.log diff --git a/compiler/lib/cli/compiler.cpp b/compiler/lib/cli/compiler.cpp index 348bcacd..98c4f04f 100644 --- a/compiler/lib/cli/compiler.cpp +++ b/compiler/lib/cli/compiler.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include #include From 383aea4b684fdc15145bd0ef3507e0450c0829af Mon Sep 17 00:00:00 2001 From: vla5924 Date: Sun, 9 Mar 2025 18:22:07 +0300 Subject: [PATCH 2/3] add --- .github/workflows/ci.yml | 15 +++++++++------ .../lib/backend/optree/optimizer/optimizer.cpp | 2 +- compiler/lib/cli/compiler.cpp | 1 + 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 81b0457e..e831ccfc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,7 +40,7 @@ jobs: clangFormatVersion: 17 build-test-gcc: - name: Build and test on Ubuntu GCC + name: Build and test (Ubuntu GCC) runs-on: ubuntu-latest needs: code-style-check container: @@ -62,7 +62,8 @@ jobs: git config --global --add safe.directory $(pwd) cmake -S compiler -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DENABLE_CODEGEN='ast_to_llvmir;optree_to_llvmir' cmake --build build --parallel - ctest --test-dir build --output-on-failure + - name: Run tests + run: ctest --test-dir build --output-on-failure - name: Archive binaries run: tar cf binaries.tar -C build bin - name: Upload binaries @@ -72,7 +73,7 @@ jobs: path: binaries.tar build-test-clang: - name: Build on Ubuntu Clang + name: Build and test (Ubuntu Clang) runs-on: ubuntu-latest needs: code-style-check container: @@ -93,10 +94,11 @@ jobs: run: | cmake -S compiler -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DENABLE_CODEGEN='ast_to_llvmir;optree_to_llvmir' cmake --build build --parallel - ctest --test-dir build --output-on-failure + - name: Run tests + run: ctest --test-dir build --output-on-failure build-test-msvc: - name: Build on Windows MSVC + name: Build and test (Windows MSVC) runs-on: windows-latest needs: code-style-check steps: @@ -108,7 +110,8 @@ jobs: run: | cmake -S compiler -B build -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release cmake --build build --parallel - ctest --test-dir build --output-on-failure + - name: Run tests + run: ctest --test-dir build --output-on-failure code-coverage: name: Code coverage diff --git a/compiler/lib/backend/optree/optimizer/optimizer.cpp b/compiler/lib/backend/optree/optimizer/optimizer.cpp index a34eaf13..a5a68719 100644 --- a/compiler/lib/backend/optree/optimizer/optimizer.cpp +++ b/compiler/lib/backend/optree/optimizer/optimizer.cpp @@ -55,7 +55,7 @@ class OperationSet { return op; } - void erase(const Operation::Ptr &op) { + void erase(Operation::Ptr op) { auto it = positions.find(op.get()); if (it == positions.end()) return; diff --git a/compiler/lib/cli/compiler.cpp b/compiler/lib/cli/compiler.cpp index 98c4f04f..348bcacd 100644 --- a/compiler/lib/cli/compiler.cpp +++ b/compiler/lib/cli/compiler.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include From e9869d4c2711efba05d45000992119bed9d6f17a Mon Sep 17 00:00:00 2001 From: vla5924 Date: Sun, 9 Mar 2025 18:23:58 +0300 Subject: [PATCH 3/3] add --- compiler/lib/backend/optree/optimizer/optimizer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/lib/backend/optree/optimizer/optimizer.cpp b/compiler/lib/backend/optree/optimizer/optimizer.cpp index a5a68719..a34eaf13 100644 --- a/compiler/lib/backend/optree/optimizer/optimizer.cpp +++ b/compiler/lib/backend/optree/optimizer/optimizer.cpp @@ -55,7 +55,7 @@ class OperationSet { return op; } - void erase(Operation::Ptr op) { + void erase(const Operation::Ptr &op) { auto it = positions.find(op.get()); if (it == positions.end()) return;