Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Test] Add cpp linter workflow #94

Closed
wants to merge 21 commits into from
26 changes: 26 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-const-correctness,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-misc-no-recursion,-misc-use-anonymous-namespace,readability-identifier-naming,-misc-include-cleaner,-llvm-header-guard'
CheckOptions:
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.EnumCase
value: CamelCase
- key: readability-identifier-naming.FunctionCase
value: camelBack
# Exclude from scanning as this is an exported symbol used for fuzzing
# throughout the code base.
- key: readability-identifier-naming.FunctionIgnoredRegexp
value: "LLVMFuzzerTestOneInput"
- key: readability-identifier-naming.MemberCase
value: CamelCase
- key: readability-identifier-naming.ParameterCase
value: CamelCase
- key: readability-identifier-naming.UnionCase
value: CamelCase
- key: readability-identifier-naming.VariableCase
value: CamelCase
- key: readability-identifier-naming.IgnoreMainLikeFunctions
value: 1
- key: readability-redundant-member-init.IgnoreBaseInCopyConstructors
value: 1
- key: modernize-use-default-member-init.UseAssignment
value: 1
20 changes: 0 additions & 20 deletions .github/workflows/check-clang-format.yml

This file was deleted.

64 changes: 64 additions & 0 deletions .github/workflows/cpp-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: cpp-linter

on:
pull_request:
#paths:
# - "common/*"
# - "pass/*"
# - "lib/*"

jobs:
cpp-linter:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
defaults:
run:
shell: bash -el {0}
steps:
- uses: actions/checkout@v4

- name: Setup conda
uses: conda-incubator/setup-miniconda@v3
with:
conda-remove-defaults: true

# Install Clang/LLVM using conda
- name: Create environment
run: |
conda install -y -q -c conda-forge \
clang=18.1.3 \
clangxx=18.1.3 \
llvmdev=18.1.3 \
lit=18.1.3
ln -s ${CONDA_PREFIX}/libexec/llvm/FileCheck ${CONDA_PREFIX}/bin

- name: Run cmake to export compilation database
run: |
mkdir -p build
pushd build
cmake .. \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_EXPORT_COMPILE_COMMANDS=on

- uses: cpp-linter/cpp-linter-action@v2
id: linter
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
version: 18
ignore: .github | tests | scripts
style: file
tidy-checks: ''
database: build
lines-changed-only: true
format-review: true
tidy-review: true
passive-reviews: true

- name: Check linter status
if: steps.linter.outputs.checks-failed != 0
run: exit 1
3 changes: 3 additions & 0 deletions lib/JitEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ std::string JitEngine::mangleSuffix(uint64_t HashValue) {
void JitEngine::optimizeIR(Module &M, StringRef Arch) {
TIMESCOPE("Optimize IR");
runOptimizationPassPipeline(M, Arch);

for (int I = 0; I < 10; I++)
printf("Senseless code\n");
}

} // namespace proteus
3 changes: 3 additions & 0 deletions lib/JitEngineDeviceCUDA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,4 +311,7 @@ JitEngineDeviceCUDA::JitEngineDeviceCUDA() {
DeviceArch = "sm_" + std::to_string(CCMajor * 10 + CCMinor);

DBG(Logger::logs("proteus") << "CUDA Arch " << DeviceArch << "\n");

for (int I = 0; I < 10; ++I)
printf("Senseless code\n");
}
3 changes: 3 additions & 0 deletions pass/ProteusPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ class ProteusJitPassImpl {
bool run(Module &M, bool IsLTO) {
parseAnnotations(M);

for (int I = 0; I < 10; ++I)
printf("Senseless code\n");

DEBUG(Logger::logs("proteus-pass")
<< "=== Pre Original Host Module\n"
<< M << "=== End of Pre Original Host Module\n");
Expand Down
Loading