From 0a653170caa5c006aca28f34a2209d850293bfc1 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Mon, 14 Jul 2025 20:01:35 +0200 Subject: [PATCH 1/2] Add alignment support for UnboundedArrayType Signed-off-by: Roberto Raggi --- .gitignore | 2 ++ src/parser/cxx/memory_layout.cc | 5 +++++ tests/unit_tests/sema/alignof_01.cc | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/.gitignore b/.gitignore index 35ea4ce0..2b581915 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ node_modules .cache .clangd *.pch +__pycache__ +*.pyc diff --git a/src/parser/cxx/memory_layout.cc b/src/parser/cxx/memory_layout.cc index d27916fd..9417372b 100644 --- a/src/parser/cxx/memory_layout.cc +++ b/src/parser/cxx/memory_layout.cc @@ -255,6 +255,11 @@ struct AlignmentOf { return type->symbol()->alignment(); } + auto operator()(const UnboundedArrayType* type) const + -> std::optional { + return memoryLayout.alignmentOf(type->elementType()); + } + auto operator()(auto type) const -> std::optional { // ### TODO if (!type) return std::nullopt; diff --git a/tests/unit_tests/sema/alignof_01.cc b/tests/unit_tests/sema/alignof_01.cc index 926cb2ef..09c4dbce 100644 --- a/tests/unit_tests/sema/alignof_01.cc +++ b/tests/unit_tests/sema/alignof_01.cc @@ -22,3 +22,8 @@ static_assert(alignof(long) == 4); static_assert(alignof(unsigned long) == 4); static_assert(alignof(long double) == 16); #endif + +static_assert(alignof(char[]) == 1); +static_assert(alignof(int[]) == 4); +static_assert(alignof(double[]) == 8); +static_assert(alignof(__int128_t) == 16); \ No newline at end of file From 0bba250c6c65f3a19291cc34142eb427cd061010 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Mon, 14 Jul 2025 20:03:02 +0200 Subject: [PATCH 2/2] Disable flatbuffers option in CMake configuration Flatbuffers support is disabled because serialization for C++ modules is not fully implemented yet. This should speed up a the CI until we need to re-enable it. Signed-off-by: Roberto Raggi --- .github/workflows/ci.yml | 24 +++++++++--------------- CMakeLists.txt | 2 +- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d0c6b4a..a0fcc9a4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,11 +22,9 @@ jobs: run: | . .venv/bin/activate - cmake . \ - -Bbuild \ - -DCMAKE_BUILD_TYPE=Release + cmake . -Bbuild -DCMAKE_BUILD_TYPE=Release - cmake --build build + cmake --build build --parallel - name: Test working-directory: build @@ -40,11 +38,10 @@ jobs: ./build/src/frontend/cxx \ -I src/parser \ -I src/lsp \ - -I build/_deps/fmt-src/include \ -I build/_deps/utfcpp-src/source \ - -I build/_deps/flatbuffers-src/include \ -I build/_deps/nlohmann_json-src/include \ -I build/src/parser \ + -DCXX_NO_FLATBUFFERS \ -DCXX_NO_FILESYSTEM \ -DCXX_NO_THREADS \ $i @@ -58,11 +55,10 @@ jobs: -toolchain linux \ -I src/parser \ -I src/lsp \ - -I build/_deps/fmt-src/include \ -I build/_deps/utfcpp-src/source \ - -I build/_deps/flatbuffers-src/include \ -I build/_deps/nlohmann_json-src/include \ -I build/src/parser \ + -DCXX_NO_FLATBUFFERS \ $i done @@ -95,7 +91,7 @@ jobs: -DCXX_ENABLE_MLIR=ON \ -DMLIR_DIR=/usr/lib/llvm-18/lib/cmake/mlir - cmake --build build + cmake --build build --parallel - name: Test working-directory: build @@ -119,7 +115,7 @@ jobs: cmake . -Bbuild - cmake --build build --config Release + cmake --build build --parallel --config Release - name: Test working-directory: build @@ -193,7 +189,7 @@ jobs: -Bbuild \ -DCMAKE_BUILD_TYPE=Release - cmake --build build + cmake --build build --parallel - name: Test working-directory: build @@ -208,11 +204,10 @@ jobs: -toolchain macos \ -I src/parser \ -I src/lsp \ - -I build/_deps/fmt-src/include \ -I build/_deps/utfcpp-src/source \ - -I build/_deps/flatbuffers-src/include \ -I build/_deps/nlohmann_json-src/include \ -I build/src/parser \ + -DCXX_NO_FLATBUFFERS \ $i done @@ -259,11 +254,10 @@ jobs: build.wasi/install/usr/bin/cxx.wasm \ -I src/parser \ -I src/lsp \ - -I build.wasi/_deps/fmt-src/include \ -I build.wasi/_deps/utfcpp-src/source \ - -I build.wasi/_deps/flatbuffers-src/include \ -I build.wasi/_deps/nlohmann_json-src/include \ -I build.wasi/src/parser \ + -DCXX_NO_FLATBUFFERS \ -DCXX_NO_FILESYSTEM \ -DCXX_NO_THREADS \ $i diff --git a/CMakeLists.txt b/CMakeLists.txt index 91bfb8a3..41634425 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,7 @@ file(READ "${CMAKE_CURRENT_SOURCE_DIR}/package.json" package_json) # option to install tools option(CXX_INSTALL_TOOLS "Install tools" ON) option(CXX_INSTALL_WASI_SYSROOT "Install wasi sysroot" OFF) -option(CXX_ENABLE_FLATBUFFERS "Enable flatbuffers" ON) +option(CXX_ENABLE_FLATBUFFERS "Enable flatbuffers" OFF) option(CXX_ENABLE_MLIR "Enable MLIR" OFF) option(CXX_LIBCXX_WITH_CLANG "Link with libc++" OFF) option(CXX_BUILD_TESTS "Build tests" ON)