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
40 changes: 40 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
BasedOnStyle: LLVM

# --- Indentation ---
IndentWidth: 4
TabWidth: 4
UseTab: Never
IndentCaseLabels: false # case labels flush with switch, not indented further

# --- Braces ---
BreakBeforeBraces: Allman # opening brace always on its own line

# --- Lines ---
ColumnLimit: 0 # no wrapping — code uses long lines for comment alignment

# --- Pointers ---
PointerAlignment: Right # WCHAR *out, not WCHAR* out
DerivePointerAlignment: false

# --- Short constructs ---
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: WithoutElse # if (!x) return; stays on one line
AllowShortLoopsOnASingleLine: false
AllowShortBlocksOnASingleLine: Never

# --- Spacing ---
SpaceBeforeParens: ControlStatements # space before if/for/while, not before foo()
SpacesInParentheses: false

# --- Includes ---
SortIncludes: Never # include order is intentional

# --- Alignment ---
# Disabled — the code uses manual alignment for readability, clang-format
# would fight it and produce worse output.
AlignConsecutiveAssignments: None
AlignConsecutiveDeclarations: None
AlignTrailingComments:
Kind: Never
...
32 changes: 32 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
# clang-tidy configuration for CatiaMenuWin32 (C11 / Win32)
# Targets real bugs and security issues only.
# Style and modernise checks are excluded — the codebase has its own conventions.

Checks: >
-*,
bugprone-implicit-widening-of-multiplication-result,
bugprone-integer-division,
bugprone-misplaced-widening-cast,
bugprone-not-null-terminated-result,
bugprone-signed-char-misuse,
bugprone-sizeof-expression,
bugprone-suspicious-memset-usage,
bugprone-suspicious-missing-comma,
bugprone-too-small-loop-variable,
bugprone-undefined-memory-manipulation,
cert-err33-c,
cert-err34-c,
misc-redundant-expression,
clang-analyzer-security.insecureAPI.UncheckedReturn,
clang-analyzer-security.insecureAPI.rand,
clang-analyzer-security.insecureAPI.strcpy,
clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling

WarningsAsErrors: ''

# Only report diagnostics from project source files — suppresses noise from
# Windows SDK, MSVC CRT, and third-party headers.
HeaderFilterRegex: 'src/.*\.h$'

FormatStyle: none
12 changes: 12 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## Summary


## Changes


## Test plan

- [ ] Build passes (LLVM Clang MSVC Release)
- [ ] Feature / fix tested manually
- [ ] No regressions in adjacent features
- [ ] Docs / wiki updated if user-visible behaviour changed
43 changes: 43 additions & 0 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: clang-tidy

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
tidy:
name: clang-tidy (C/C++)
runs-on: windows-latest

steps:
- uses: actions/checkout@v4

- name: Set up MSVC environment
uses: ilammy/msvc-dev-cmd@v1

- name: Add LLVM to PATH
run: echo "C:\Program Files\LLVM\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

- name: Configure CMake (generate compile_commands.json)
run: |
cmake -S . -B build -G "Ninja" `
-DCMAKE_BUILD_TYPE=Debug `
-DCMAKE_C_COMPILER=clang-cl `
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON

- name: Run clang-tidy
shell: pwsh
run: |
$files = Get-ChildItem -Path src -Filter "*.c" | Select-Object -ExpandProperty FullName
$failed = $false
foreach ($f in $files) {
Write-Host "-- $f"
clang-tidy -p build $f
if ($LASTEXITCODE -ne 0) { $failed = $true }
}
if ($failed) { exit 1 }
41 changes: 41 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Format

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
clang-format:
name: clang-format check
runs-on: windows-latest

steps:
- uses: actions/checkout@v4

- name: Add LLVM to PATH
run: echo "C:\Program Files\LLVM\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

- name: Check formatting
shell: pwsh
run: |
$files = Get-ChildItem -Path src -Include "*.c","*.h" -Recurse |
Select-Object -ExpandProperty FullName
$failed = $false
foreach ($f in $files) {
$result = & clang-format --dry-run --Werror $f 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Host "NEEDS FORMAT: $f"
$failed = $true
}
}
if ($failed) {
Write-Host ""
Write-Host "Run 'clang-format -i src/*.c src/*.h' locally to fix formatting."
exit 1
}
Write-Host "All files formatted correctly."
Loading
Loading