Skip to content

Commit

Permalink
Don't perform last increment diff of for stmt when there's a break stmt
Browse files Browse the repository at this point in the history
  • Loading branch information
kchristin22 committed Sep 8, 2024
1 parent 24b733f commit fb07f8e
Show file tree
Hide file tree
Showing 224 changed files with 15,263 additions and 8,930 deletions.
16 changes: 16 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,19 @@ CheckOptions:
value: 1
- key: readability-magic-numbers.IgnoredIntegerValues
value: 4;8;16;
- key: bugprone-argument-comment.CommentNullPtrs
value: 1
- key: bugprone-argument-comment.CommentBoolLiterals
value: 1
- key: bugprone-argument-comment.StrictMode
value: 1
- key: bugprone-argument-comment.CommentIntegerLiterals
value: 1
- key: bugprone-argument-comment.CommentUserDefinedLiterals
value: 1
- key: bugprone-argument-comment.CommentStringLiterals
value: 1
- key: bugprone-argument-comment.CommentFloatLiterals
value: 1
- key: bugprone-argument-comment.CommentCharacterLiterals
value: 1
14 changes: 7 additions & 7 deletions .github/workflows/arch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,31 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: "Setup latest Alpine Linux"
uses: jirutka/setup-alpine@v1
with:
arch: ${{ matrix.target }}
branch: edge
packages: >
llvm-dev
clang-dev
clang-static
llvm17-dev
clang17-dev
clang17-static
clang17-extra-tools
llvm17-static
llvm17-gtest
cmake
llvm
clang
make
git
- name: "Setup"
run: |
clang --version
make --version
shell: alpine.sh {0}

- name: "Compile library"
run: |
export CC=/usr/bin/clang-17
export CXX=/usr/bin/clang++-17
mkdir build && cd build
cmake -DLLVM_EXTERNAL_LIT="$(which lit)" ../../clad
make -j 8 check-clad
Expand Down
32 changes: 21 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,13 @@ jobs:
clang-runtime: '10'
cuda: true

- name: selfh-ubu20-clang9-runtime10-cuda
os: self-hosted #ubuntu-20.04
runs-on: cuda
compiler: clang-9
clang-runtime: '10'
cuda: true

- name: ubu20-clang9-runtime15
os: ubuntu-20.04
compiler: clang-9
Expand Down Expand Up @@ -470,11 +477,11 @@ jobs:
clang-runtime: '8'

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Save PR Info
Expand All @@ -483,7 +490,7 @@ jobs:
mkdir -p ./pr
echo ${{ github.event.number }} > ./pr/NR
echo ${{ github.repository }} > ./pr/REPO
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
if: ${{ matrix.coverage == true }}
with:
name: pr
Expand Down Expand Up @@ -527,7 +534,7 @@ jobs:
echo "deb https://apt.llvm.org/${os_codename}/ llvm-toolchain-${os_codename}-${{ matrix.clang-runtime }} main" | sudo tee -a /etc/apt/sources.list
sudo apt update
fi
sudo apt install llvm-${{ matrix.clang-runtime }}-dev \
sudo apt install -y llvm-${{ matrix.clang-runtime }}-dev \
llvm-${{ matrix.clang-runtime }}-tools \
clang-${{ matrix.clang-runtime }} \
libclang-${{ matrix.clang-runtime }}-dev \
Expand Down Expand Up @@ -651,7 +658,7 @@ jobs:
- name: Restore Cache LLVM/Clang runtime build directory (debug_build==true)
if: ${{ (matrix.debug_build == true) && (runner.os != 'windows') }}
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
id: cache
with:
path: |
Expand Down Expand Up @@ -682,10 +689,10 @@ jobs:
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_INCLUDE_DOCS=OFF \
../llvm
cmake --build . --target clang FileCheck llvm-config --parallel ${CPU_COUNT}
cmake --build . --target clang FileCheck llvm-config clang-repl --parallel ${CPU_COUNT}
cd ../../
- name: Save Cache LLVM/Clang runtime build directory (debug_build==true)
uses: actions/cache/save@v3
uses: actions/cache/save@v4
if: ${{ (matrix.debug_build == true) && (runner.os != 'windows') && (steps.cache.outputs.cache-hit != 'true') }}
with:
path: |
Expand Down Expand Up @@ -713,7 +720,7 @@ jobs:
# llvm-8-tools is broken as it depends on python2.7 we use FileCheck from llvm-7-tools
if [[ '${{ matrix.clang-runtime }}' == '8' ]]; then
if [[ ! -f $PATH_TO_LLVM_BUILD/bin/FileCheck ]]; then
sudo apt install llvm-9-dev llvm-9-tools
sudo apt install -y llvm-9-dev llvm-9-tools
sudo ln -s /usr/lib/llvm-9/bin/FileCheck $PATH_TO_LLVM_BUILD/bin/FileCheck
fi
fi
Expand Down Expand Up @@ -748,7 +755,7 @@ jobs:
- name: Setup code coverage
if: ${{ (matrix.coverage == true) }}
run: |
sudo apt install lcov
sudo apt install -y lcov
echo "CLAD_CODE_COVERAGE=1" >> $GITHUB_ENV
echo "BUILD_TYPE=Debug" >> $GITHUB_ENV
- name: Display config *nix
Expand Down Expand Up @@ -911,7 +918,7 @@ jobs:
cat obj/CMakeCache.txt
cat obj/CMakeFiles/*.log
- name: Setup tmate session
if: ${{ failure() && runner.debug }}
if: ${{ runner.debug }}
uses: mxschmitt/action-tmate@v3
# When debugging increase to a suitable value!
timeout-minutes: 30
Expand All @@ -932,9 +939,12 @@ jobs:
- name: Upload to codecov.io
if: ${{ success() && (matrix.coverage == true) }}
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
file: ./coverage.info
fail_ci_if_error: true
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Upload report to coverity_scan
if: ${{ success() && (matrix.coverity == true) }}
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout PR branch
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.7
python-version: 3.11
- name: Install clang-format
run: |
curl https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
echo "deb https://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main" | sudo tee -a /etc/apt/sources.list
os_codename="`cat /etc/os-release | grep UBUNTU_CODENAME | cut -d = -f 2`"
echo "deb https://apt.llvm.org/${os_codename}/ llvm-toolchain-${os_codename}-18 main" | sudo tee -a /etc/apt/sources.list
sudo apt update
sudo apt install -y clang-format-15
sudo apt install -y clang-format-18
- name: Download git-clang-format
run: |
wget https://raw.githubusercontent.com/llvm/llvm-project/main/clang/tools/clang-format/git-clang-format
Expand All @@ -41,10 +42,10 @@ jobs:
-c color.ui=always \
-c diff.wsErrorHighlight=all \
-c color.diff.whitespace='red reverse' \
clang-format-15 --diff --binary clang-format-15 --commit $PR_BASE -- demos/ include/ lib/ tools/ || \
clang-format-18 --diff --binary clang-format-18 --commit $PR_BASE || \
(echo "Please run the following git-clang-format locally to fix the formatting: \n
git-clang-format HEAD~\n
for multiple commits we should place the formatting changes in the related commit with:\n
\t\tgit rebase -i -x \"git-clang-format-15 master && git commit -a --allow-empty --fixup=HEAD\" --strategy-option=theirs origin/master\n
\t\tgit rebase -i -x \"git-clang-format-18 master && git commit -a --allow-empty --fixup=HEAD\" --strategy-option=theirs origin/master\n
\t\t Then inspect the results with: git log --oneline\n
\t\t Then squash without poluting the history with: git rebase --autosquash -i master\n" && exit 1)
2 changes: 1 addition & 1 deletion .github/workflows/clang-tidy-review-post.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
steps:
- name: Post review comments
id: post-review
uses: ZedThree/clang-tidy-review/post@v0.13.2
uses: ZedThree/clang-tidy-review/post@v0.18.0
with:
max_comments: 10

Expand Down
24 changes: 15 additions & 9 deletions .github/workflows/clang-tidy-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,36 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout PR branch
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1
uses: KyleMayes/install-llvm-action@v2.0.3
with:
version: "12.0.0"
version: "17.0.6"

- name: install lit
run: pip install lit

- name: run git config command
run: |
git config --global --add safe.directory /github/workspace
- name: Run clang-tidy
uses: ZedThree/clang-tidy-review@v0.13.2
uses: ZedThree/clang-tidy-review@v0.18.0
id: review
with:
build_dir: build
apt_packages: libxml2,libxml2-dev,libtinfo-dev,zlib1g-dev,libzstd-dev
apt_packages: cmake,libxml2,libxml2-dev,libtinfo-dev,zlib1g-dev,libzstd-dev
exclude: "test/*,unittests/*,benchmark/*,demos/*"
split_workflow: true
config_file: .clang-tidy
cmake_command: >
pip install cmake lit &&
cmake --version &&
git config --global --add safe.directory /github/workspace &&
CC=$GITHUB_WORKSPACE/llvm/bin/clang CXX=$GITHUB_WORKSPACE/llvm/bin/clang++
cmake . -B build -DLLVM_DIR="$GITHUB_WORKSPACE/llvm"
-DClang_DIR="$GITHUB_WORKSPACE/llvm"
-DCMAKE_BUILD_TYPE="Release"
-DLLVM_EXTERNAL_LIT="`which lit`"
-DCMAKE_EXPORT_COMPILE_COMMANDS=On
- name: Upload artifacts
uses: ZedThree/clang-tidy-review/upload@v0.13.1
uses: ZedThree/clang-tidy-review/upload@v0.18.0
4 changes: 2 additions & 2 deletions .github/workflows/postci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
${{ github.event.workflow_run.event == 'pull_request'}}
steps:
- name: 'Download artifact'
uses: actions/github-script@v3.1.0
uses: actions/github-script@v7.0.1
with:
script: |
var artifacts = await github.actions.listWorkflowRunArtifacts({
Expand All @@ -38,7 +38,7 @@ jobs:
echo "PR_NUMBER=`cat ./NR`" >> $GITHUB_ENV
echo "PR_REPO=`cat ./REPO`" >> $GITHUB_ENV
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
43 changes: 27 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/
PATTERN "*.inc"
)

install(FILES cmake/modules/AddClad.cmake
DESTINATION lib/cmake/clad
)

add_definitions( -D_GNU_SOURCE
-DCLAD_SRCDIR_INCL="${CLAD_SOURCE_DIR}/include"
-DCLAD_INSTDIR_INCL="${CLAD_BINARY_DIR}/include" )
Expand Down Expand Up @@ -317,30 +321,37 @@ if (NOT CLAD_BUILD_STATIC_ONLY)
include(GoogleBenchmark)
endif(CLAD_ENABLE_BENCHMARKS)

# Change the default compiler to the clang which we run clad upon. Our unittests
# need to use a supported by clad compiler. Note that's a huge hack and it is
# not guaranteed to work with cmake.
set(stored_cxx_compiler ${CMAKE_CXX_COMPILER})
set(stored_cxx_flags ${CMAKE_CXX_FLAGS})

set(CMAKE_CXX_COMPILER ${LLVM_TOOLS_BINARY_DIR}/clang)
# Filter some unsupported flags by clang.
string(REPLACE "-fno-lifetime-dse" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE "-Wno-class-memaccess" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")

add_subdirectory(unittests)
add_subdirectory(test)
add_subdirectory(demos/ErrorEstimation/CustomModel)
add_subdirectory(demos/ErrorEstimation/PrintModel)

if (NOT CLAD_DISABLE_TESTS OR CLAD_ENABLE_BENCHMARKS)
# Change the default compiler to the clang which we run clad upon. Our unittests
# need to use a supported by clad compiler. Note that's a huge hack and it is
# not guaranteed to work with cmake.
set(stored_cxx_compiler ${CMAKE_CXX_COMPILER})
set(stored_cxx_flags ${CMAKE_CXX_FLAGS})

set(CMAKE_CXX_COMPILER ${LLVM_TOOLS_BINARY_DIR}/clang)
# Filter some unsupported flags by clang.
string(REPLACE "-fno-lifetime-dse" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE "-Wno-class-memaccess" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif()

if (NOT CLAD_DISABLE_TESTS)
add_subdirectory(unittests)
add_subdirectory(test)
endif()

# Add benchmarking infrastructure.
if (CLAD_ENABLE_BENCHMARKS)
add_subdirectory(benchmark)
endif(CLAD_ENABLE_BENCHMARKS)

# Restore the default compiler.
set(CMAKE_CXX_COMPILER ${stored_cxx_compiler})
set(CMAKE_CXX_FLAGS ${stored_cxx_flags})
if (stored_cxx_compiler)
# Restore the default compiler.
set(CMAKE_CXX_COMPILER ${stored_cxx_compiler})
set(CMAKE_CXX_FLAGS ${stored_cxx_flags})
endif()
endif()

# Workaround for MSVS10 to avoid the Dialog Hell
Expand Down
15 changes: 12 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,13 @@ review quickly and successfully share several common traits:
information is usually published as part of the pull request description and
as part of the commit message. Writing good commit messages are critical. More
[here](https://github.blog/2022-06-30-write-better-commits-build-better-projects/)
and [here](https://cbea.ms/git-commit/).
and [here](https://cbea.ms/git-commit/). If your pull request fixes an existing
issue from the bug tracker make sure that the commit log and the pull request
description mentions `Fixes: #<ISSUE_NUMBER>`. That will link both and will
close the issue automatically upon merging.
- Tested -- has a set of tests making sure that the issue will not resurface
without a notice. Usually
without a notice. Usually the codecov bots annotate the code paths that are
not tested in the pull request after being run.
- Documented -- has good amount of code comment. The test cases are also a good
source of documentation. [Here](https://stackoverflow.blog/2021/12/23/best-practices-for-writing-code-comments/)
is a guideline about how write good code comments. [Here](https://stackoverflow.com/questions/184618/what-is-the-best-comment-in-source-code-you-have-ever-encountered)
Expand All @@ -65,4 +69,9 @@ review quickly and successfully share several common traits:
### Developer Documentation

We have documented several useful hints that usually help when addressing issues
as they come during developement time in our [developer documentation](https://clad.readthedocs.io/en/latest/user/DevelopersDocumentation.html).
as they come during developement time in our [developer documentation](https://clad.readthedocs.io/en/latest/user/DevelopersDocumentation.html).

In case you are interested in seeing the big picture and are just getting
started with Clang, there is a document that might interest you: [Introduction to Clang for Clad contributors](https://clad.readthedocs.io/en/latest/user/IntroductionToClangForCladContributors.html).
It covers most of the basic concepts in Clang that Clad uses and describes the operation
of the latter with examples for newcomers specifically.
Loading

0 comments on commit fb07f8e

Please sign in to comment.