Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[*.{json,yml,yaml}]
indent_size = 2

[CMakeLists.txt]
indent_size = 2

[*.cmake]
indent_size = 2

[Makefile]
indent_style = tab
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* text=auto eol=lf
*.png binary
18 changes: 18 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: Bug report
about: The compiler, runtime or tooling misbehaves
labels: bug
---

**Uinx version / commit**

**Host and target triple**

**Smallest reproducing source**

```uinx
```

**Command line**

**Expected vs. actual behavior**
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: Security report
url: https://github.com/ViudiraTech/Uinx/blob/main/SECURITY.md
about: Compiler crashes, borrow-checker soundness failures and memory-safety escapes
10 changes: 10 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Summary

<!-- What does this change and why? -->

## Checklist

- [ ] `cmake --preset ci && cmake --build --preset ci && ctest --preset ci` passes
- [ ] `clang-format` is clean (`cmake --build <dir> --target format`)
- [ ] New language behavior has a test under `tests/` (`conformance/`, `safety/`, `codegen/` or `runtime/`)
- [ ] User-visible changes are recorded in `CHANGELOG.md`
46 changes: 46 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CI

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

jobs:
build-test:
name: ${{ matrix.compiler }} / ${{ matrix.preset }}
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
- { compiler: gcc, cc: gcc, cxx: g++, preset: ci }
- { compiler: clang, cc: clang, cxx: clang++, preset: ci }
- { compiler: clang, cc: clang, cxx: clang++, preset: asan }
steps:
- uses: actions/checkout@v4
- name: Install toolchain
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends ninja-build clang lld
- name: Configure
run: cmake --preset ${{ matrix.preset }} -DCMAKE_C_COMPILER=${{ matrix.cc }} -DCMAKE_CXX_COMPILER=${{ matrix.cxx }}
- name: Build
run: cmake --build --preset ${{ matrix.preset }}
- name: Test
run: ctest --preset ${{ matrix.preset }}

format:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install clang-format
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends clang-format
- name: Check formatting
run: git ls-files '*.cpp' '*.hpp' '*.c' '*.h' | xargs clang-format --dry-run --Werror
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
# Build trees
/build/
/build-*/
/Testing/
CMakeUserPresets.json
compile_commands.json

# Uinx outputs
.uinx/
target/
*.o
*.ll
*.elf

# Editor / tooling
*.vsix
.vscode/
.idea/
.cache/
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

**Copyright © 2026 ViudiraTech · Code by JiTianYu391**

- Fixed a heap-use-after-free in `uinx::Type` copy assignment (`t = *t.pointee`) found by AddressSanitizer.
- Repository hygiene: added `CMakePresets.json`, GitHub Actions CI (GCC, Clang, ASan/UBSan, clang-format), issue/PR templates, `CONTRIBUTING.md`, `.editorconfig` and `.gitattributes`; moved `ARCHITECTURE.md` and `BUILD.md` into `docs/`; moved test registration into `tests/CMakeLists.txt`; added `UINX_WARNINGS_AS_ERRORS` and `UINX_ENABLE_SANITIZERS` options; removed the stale `MANIFEST.sha256` and checked-in `verification/` transcripts.
- Reworked borrow checking around backward liveness plus forward control-flow fixed points instead of block-local statement numbering.
- Added HIR `SymbolId`-based place identity so shadowed locals cannot erase or inherit another binding's move/loan state.
- Added partial move/reinitialization tracking, branch/loop joins, break/continue/return reachability handling, field-level reference provenance, method-receiver provenance, aggregate escape checking, and conservative async suspension checks.
Expand Down
40 changes: 16 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,26 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

option(UINX_BUILD_TESTS "Build Uinx compiler tests" ON)
option(UINX_BUILD_FUZZ "Build libFuzzer targets when supported" OFF)
option(UINX_WARNINGS_AS_ERRORS "Treat compiler warnings as errors" OFF)
option(UINX_ENABLE_SANITIZERS "Build with AddressSanitizer and UndefinedBehaviorSanitizer" OFF)

if(MSVC)
add_compile_options(/W4 /permissive-)
if(UINX_WARNINGS_AS_ERRORS)
add_compile_options(/WX)
endif()
else()
add_compile_options(-Wall -Wextra -Wpedantic -Wconversion -Wshadow)
if(UINX_WARNINGS_AS_ERRORS)
add_compile_options(-Werror)
endif()
if(UINX_ENABLE_SANITIZERS)
# C++ only: the C runtime is linked into programs built by uinxc, which are
# not sanitized.
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fsanitize=address,undefined>
$<$<COMPILE_LANGUAGE:CXX>:-fno-omit-frame-pointer>)
add_link_options(-fsanitize=address,undefined)
endif()
endif()

add_library(uinx_compiler
Expand Down Expand Up @@ -76,30 +91,7 @@ endif()

if(UINX_BUILD_TESTS)
enable_testing()
add_executable(uinx-unit-tests tests/unit/compiler_unit.cpp)
target_link_libraries(uinx-unit-tests PRIVATE uinx_compiler)
add_test(NAME unit.compiler COMMAND uinx-unit-tests)
add_executable(uinx-runtime-tests tests/unit/runtime_unit.c)
target_link_libraries(uinx-runtime-tests PRIVATE uinx_runtime)
add_test(NAME unit.runtime COMMAND uinx-runtime-tests)
add_test(NAME codegen.asm-object COMMAND $<TARGET_FILE:uinxc> ${CMAKE_CURRENT_SOURCE_DIR}/tests/codegen/asm/x86_64_nop.ux --emit=obj -o ${CMAKE_CURRENT_BINARY_DIR}/asm-test.o)
add_test(NAME codegen.asm-input-output COMMAND ${CMAKE_COMMAND} -DUINXC=$<TARGET_FILE:uinxc> -DSOURCE=${CMAKE_CURRENT_SOURCE_DIR}/tests/codegen/asm/x86_64_io.ux -DOUTPUT=${CMAKE_CURRENT_BINARY_DIR}/asm-io -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/RunExecutableTest.cmake)
add_test(NAME codegen.asm-inout COMMAND ${CMAKE_COMMAND} -DUINXC=$<TARGET_FILE:uinxc> -DSOURCE=${CMAKE_CURRENT_SOURCE_DIR}/tests/codegen/asm/x86_64_inout.ux -DOUTPUT=${CMAKE_CURRENT_BINARY_DIR}/asm-inout -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/RunExecutableTest.cmake)
add_test(NAME codegen.asm-multiple-outputs COMMAND ${CMAKE_COMMAND} -DUINXC=$<TARGET_FILE:uinxc> -DSOURCE=${CMAKE_CURRENT_SOURCE_DIR}/tests/codegen/asm/x86_64_multiout.ux -DOUTPUT=${CMAKE_CURRENT_BINARY_DIR}/asm-multiout -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/RunExecutableTest.cmake)
add_test(NAME runtime.slice-index-bounds COMMAND ${CMAKE_COMMAND} -DUINXC=$<TARGET_FILE:uinxc> -DSOURCE=${CMAKE_CURRENT_SOURCE_DIR}/tests/conformance/pass/slice_index.ux -DOUTPUT=${CMAKE_CURRENT_BINARY_DIR}/slice-index -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/RunExecutableTest.cmake)
add_test(NAME runtime.slice-index-oob-traps COMMAND ${CMAKE_COMMAND} -DUINXC=$<TARGET_FILE:uinxc> -DSOURCE=${CMAKE_CURRENT_SOURCE_DIR}/tests/conformance/pass/slice_oob.ux -DOUTPUT=${CMAKE_CURRENT_BINARY_DIR}/slice-oob -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/RunExpectedRuntimeFailure.cmake)
add_test(NAME runtime.c-ffi COMMAND ${CMAKE_COMMAND} -DUINXC=$<TARGET_FILE:uinxc> -DSOURCE=${CMAKE_CURRENT_SOURCE_DIR}/examples/c_ffi.ux -DOUTPUT=${CMAKE_CURRENT_BINARY_DIR}/c-ffi -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/RunExecutableTest.cmake)
add_test(NAME headers.enabled COMMAND ${CMAKE_COMMAND} -DUINXC=$<TARGET_FILE:uinxc> -DSOURCE=${CMAKE_CURRENT_SOURCE_DIR}/tests/headers/main.ux -DINCLUDE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/tests/headers/include -DOUTPUT=${CMAKE_CURRENT_BINARY_DIR}/header-test -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/RunHeaderTest.cmake)
add_test(NAME codegen.cross-target-objects COMMAND ${CMAKE_COMMAND} -DUINXC=$<TARGET_FILE:uinxc> -DSOURCE=${CMAKE_CURRENT_SOURCE_DIR}/examples/freestanding.ux -DBINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/RunCrossTargetTests.cmake)
add_test(NAME codegen.asm-cross-targets COMMAND ${CMAKE_COMMAND} -DUINXC=$<TARGET_FILE:uinxc> -DSOURCE=${CMAKE_CURRENT_SOURCE_DIR}/tests/codegen/asm/cross_nop.ux -DBINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/RunAsmCrossTargets.cmake)
add_test(NAME codegen.asm-invalid-target-register COMMAND ${CMAKE_COMMAND} -DUINXC=$<TARGET_FILE:uinxc> -DSOURCE=${CMAKE_CURRENT_SOURCE_DIR}/tests/codegen/asm/invalid_aarch64_reg.ux -DOUTPUT=${CMAKE_CURRENT_BINARY_DIR}/asm-invalid.o -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/RunInvalidAsmConstraint.cmake)
add_test(NAME codegen.baremetal-cross-link COMMAND ${CMAKE_COMMAND} -DUINXC=$<TARGET_FILE:uinxc> -DCLANG=clang -DLD_LLD=ld.lld -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/examples/baremetal -DBINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/RunBareMetalTests.cmake)
add_test(NAME runtime.async-suspend-resume COMMAND ${CMAKE_COMMAND} -DUINXC=$<TARGET_FILE:uinxc> -DSOURCE=${CMAKE_CURRENT_SOURCE_DIR}/tests/runtime/async/suspend_resume.ux -DUINX_OBJ=${CMAKE_CURRENT_BINARY_DIR}/async-test.o -DCLANG=clang -DRUNTIME_INCLUDE=${CMAKE_CURRENT_SOURCE_DIR}/runtime -DHARNESS=${CMAKE_CURRENT_SOURCE_DIR}/tests/support/async_harness.c -DRUNTIME_LIB=$<TARGET_FILE:uinx_runtime> -DOUTPUT=${CMAKE_CURRENT_BINARY_DIR}/async-test -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/RunAsyncTest.cmake)
add_test(NAME conformance.positive COMMAND ${CMAKE_COMMAND} -DUINXC=$<TARGET_FILE:uinxc> -DTEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/tests/conformance/pass -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/RunPassTests.cmake)
add_test(NAME conformance.negative COMMAND ${CMAKE_COMMAND} -DUINXC=$<TARGET_FILE:uinxc> -DTEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/tests/conformance/fail -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/RunFailTests.cmake)
add_test(NAME safety.borrow-negative COMMAND ${CMAKE_COMMAND} -DUINXC=$<TARGET_FILE:uinxc> -DTEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/tests/safety/borrow-fail -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/RunFailTests.cmake)
add_test(NAME safety.smp-negative COMMAND ${CMAKE_COMMAND} -DUINXC=$<TARGET_FILE:uinxc> -DTEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/tests/safety/smp-fail -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/RunFailTests.cmake)
add_test(NAME tooling.package-integration COMMAND ${CMAKE_COMMAND} -DUINX=$<TARGET_FILE:uinx> -DWORK=${CMAKE_CURRENT_BINARY_DIR}/package-tooling -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/RunPackageToolingTest.cmake)
add_subdirectory(tests)
endif()

if(UINX_BUILD_FUZZ AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
Expand Down
68 changes: 68 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"version": 6,
"cmakeMinimumRequired": { "major": 3, "minor": 25, "patch": 0 },
"configurePresets": [
{
"name": "base",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}"
},
{
"name": "debug",
"inherits": "base",
"displayName": "Debug",
"cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" }
},
{
"name": "release",
"inherits": "base",
"displayName": "Release",
"cacheVariables": { "CMAKE_BUILD_TYPE": "Release" }
},
{
"name": "ci",
"inherits": "release",
"displayName": "CI (Release, warnings as errors)",
"cacheVariables": { "UINX_WARNINGS_AS_ERRORS": "ON" }
},
{
"name": "asan",
"inherits": "base",
"displayName": "Debug + ASan/UBSan",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"UINX_ENABLE_SANITIZERS": "ON"
}
},
{
"name": "fuzz",
"inherits": "release",
"displayName": "Clang + libFuzzer",
"cacheVariables": {
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++",
"UINX_BUILD_FUZZ": "ON"
}
}
],
"buildPresets": [
{ "name": "debug", "configurePreset": "debug" },
{ "name": "release", "configurePreset": "release" },
{ "name": "ci", "configurePreset": "ci" },
{ "name": "asan", "configurePreset": "asan" },
{ "name": "fuzz", "configurePreset": "fuzz" }
],
"testPresets": [
{
"name": "default",
"hidden": true,
"output": { "outputOnFailure": true }
},
{ "name": "debug", "inherits": "default", "configurePreset": "debug" },
{ "name": "release", "inherits": "default", "configurePreset": "release" },
{ "name": "ci", "inherits": "default", "configurePreset": "ci" },
{ "name": "asan", "inherits": "default", "configurePreset": "asan" },
{ "name": "fuzz", "inherits": "default", "configurePreset": "fuzz" }
]
}
56 changes: 56 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Contributing to Uinx

Thanks for helping out. Security-relevant reports (compiler crashes,
borrow-checker soundness failures, safe-language memory-safety escapes) should
follow [SECURITY.md](SECURITY.md) instead of the public issue tracker.

## Build and test

```sh
cmake --preset ci
cmake --build --preset ci
ctest --preset ci
```

Other presets: `debug`, `release`, `asan` (ASan + UBSan), `fuzz` (Clang +
libFuzzer). Toolchain requirements are listed in [docs/BUILD.md](docs/BUILD.md).

## Repository layout

| Path | Contents |
|---|---|
| `include/uinx/` | public compiler headers |
| `src/` | compiler front end, borrow checker, MIR, LLVM IR backend |
| `tools/` | `uinx`, `uinxc`, `uinx-lsp` executables |
| `runtime/` | C runtime linked into hosted programs |
| `stdlib/` | standard library in Uinx |
| `tests/` | unit, conformance, safety, codegen and runtime tests |
| `cmake/` | CTest driver scripts (`Run*.cmake`) |
| `examples/` | sample programs, also exercised by tests |
| `fuzz/`, `benchmarks/` | libFuzzer targets and compiler benchmark |
| `editors/` | editor integrations (VS Code) |
| `docs/` | specification, architecture, build and design documents |

## Tests

Every language-level change needs a test in `tests/`; see
[tests/README.md](tests/README.md). Negative tests must carry the stable
`EXPECT-DIAGNOSTIC` code they are meant to hit.

## Style

C and C++ are formatted with `clang-format` using the checked-in `.clang-format`:

```sh
cmake --build build/ci --target format
```

CI runs `clang-format --dry-run --Werror` and builds with warnings as errors.

## Commits and pull requests

Use short imperative subjects, preferably `area: change` (for example
`borrowck: reject dangling field reference`). Record user-visible changes in
[CHANGELOG.md](CHANGELOG.md).

Build outputs, logs and benchmark transcripts are not committed.
Loading
Loading