if [ -z "$RUN_CLANG_TIDY" ]
then
echo "Please set the path to run-clang-tidy using the git hook"
- echo "git config hooks.runclangtidypath /path/to/run-clang-tidy-7.py"
+ echo "git config hooks.runclangtidypath /path/to/run-clang-tidy-9.py"
echo "or by setting an environment variable, e.g."
- echo "RUN_CLANG_TIDY=/path/to/run-clang-tidy-7.py"
+ echo "RUN_CLANG_TIDY=/path/to/run-clang-tidy-9.py"
exit 2
fi
if ! which "$RUN_CLANG_TIDY" 1>/dev/null
then
- echo "run-clang-tidy-7.py not found: $RUN_CLANG_TIDY"
+ echo "run-clang-tidy-9.py not found: $RUN_CLANG_TIDY"
exit 2
fi
fi
if [ -z "$runclangtidy_path" ]
then
echo "Please set the path to run-clang-tidy using 'git config hooks.runclangtidypath'."
- echo "Note that you need at least clang-tidy-8."
+ echo "Note that you need at least clang-tidy-9."
exit 1
fi
export RUN_CLANG_TIDY="$runclangtidy_path"
COMPILER_MAJOR_VERSION: 8
extends:
- .use-clang:base
+
+.use-clang9:
+ image: gromacs/cmake-3.13.0-llvm-9-intelopencl-openmpi:master
+ variables:
+ COMPILER_MAJOR_VERSION: 9
+ extends:
+ - .use-clang:base
clang-tidy:configure:
extends:
- .gromacs:base:configure
- - .use-clang7
+ - .use-clang9
- .rules:not-for-release
dependencies: []
variables:
- .gromacs:base:build
- .use-ccache
- .variables:default
- - .use-clang7
+ - .use-clang9
- .rules:nightly-not-for-release
stage: source-check
needs:
- .gromacs:base:build
- .use-ccache
- .variables:default
- - .use-clang7
+ - .use-clang9
- .rules:not-for-release
stage: source-check
needs:
KUBERNETES_CPU_REQUEST: 2
KUBERNETES_MEMORY_LIMIT: 4Gi
script:
- - RUN_CLANG_TIDY=run-clang-tidy-$COMPILER_MAJOR_VERSION bash admin/clang-tidy.sh check --parallel=$KUBERNETES_CPU_LIMIT --warnings=clang-tidy.log --rev=origin/master -B=$BUILD_DIR
+ # TODO (issue #3272) `master` is not appropriate for use on release-xxxx branches, how should we handle that?
+ # See discussion at https://gitlab.com/gromacs/gromacs/-/merge_requests/67
+ - REV=$(git fetch -q https://gitlab.com/gromacs/gromacs.git master && git show -s --pretty=format:"%h" `git merge-base FETCH_HEAD HEAD`)
+ - RUN_CLANG_TIDY=run-clang-tidy-$COMPILER_MAJOR_VERSION bash admin/clang-tidy.sh check --parallel=$KUBERNETES_CPU_LIMIT --warnings=clang-tidy.log --rev=$REV -B=$BUILD_DIR
- grep -iq "found code issues" clang-tidy.log | tee code-lint.txt || true
- if [ -s code-lint.txt ] ; then echo "clang-tidy.sh found issues"; exit 1; fi
artifacts:
.. cmake:: GMX_CLANG_TIDY
- `clang-tidy <http://releases.llvm.org/8.0.0/tools/clang/tools/extra/docs/clang-tidy/index.html>`_
+ `clang-tidy <http://releases.llvm.org/9.0.0/tools/clang/tools/extra/docs/clang-tidy/index.html>`_
is used for static code analysis and (some) automated fixing of issues detected. clang-tidy is easy to install. It is contained in
- the llvm binary `package <http://releases.llvm.org/download.html#8.0.0>`_. Only
- version 8.0.* with libstdc++<7 or libc++ is supported. Others might miss tests or give false positives.
- It is run automatically on Jenkins for each commit. Many checks have fixes which can automatically be
+ the llvm binary `package <http://releases.llvm.org/download.html#9.0.0>`_. Only
+ version 9.0.* with libstdc++<7 or libc++ is supported. Others might miss tests or give false positives.
+ It is run automatically in gitlab CI for each commit. Many checks have fixes which can automatically be
applied. To run it, the build has to be configured with
- ``cmake -DGMX_CLANG_TIDY=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=on``.
+ ``cmake -DGMX_CLANG_TIDY=ON -DCMAKE_BUILD_TYPE=Debug``.
Any ``CMAKE_BUILD_TYPE`` which enables asserts (e.g. ASAN) works. Such a configured build will
run both the compiler as well as clang-tidy when building. The name of the clang-tidy executable is set with
``-DCLANG_TIDY=...``, and the full path to it can be set with ``-DCLANG_TIDY_EXE=...``.
Setting up clang-tidy
---------------------
-|Gromacs| source code tidiness checking is enforced with clang-tidy 8.0.1.
+|Gromacs| source code tidiness checking is enforced with clang-tidy provided
+alongside *clang* compiler version 9.
:command:`clang-tidy` is one of the core *clang* tools.
It may be included in a *clang* or *llvm* package from your favorite packaging
-system or you may find a standalone *clang-tidy* package,
-but you should confirm that the provided command is version 8.0.1 or
-7.1.0. Example::
+system or you may find a standalone *clang-tidy* or *clang-tools* package,
+but you should confirm that the provided command is version 9.
+Example::
$ clang-tidy --version
- clang-tidy version 7.1.0 (tags/RELEASE_710/final)
+ LLVM (http://llvm.org/):
+ LLVM version 9.0.0
If you use a different version of clang-tidy,
you will likely get different checking results than
.. note::
- Refer to `LLVM <http://releases.llvm.org/download.html#7.1.0>`__ for
+ Refer to `LLVM <http://releases.llvm.org/download.html#9.0.1>`__ for
source and binary downloads.
If downloading sources, note that you will need to download both the
*LLVM source code* and the *Clang source code*.
As per the clang
- `INSTALL.txt <https://github.com/llvm/llvm-project/blob/release/7.x/clang/INSTALL.txt>`__,
+ `INSTALL.txt <https://github.com/llvm/llvm-project/blob/release/9.x/clang/INSTALL.txt>`__,
place the expanded clang source into a :file:`tools/clang` subdirectory within
the expanded llvm archive, then run CMake against the llvm source directory.
which will be automatically updated (if necessary) when you :command:`git pull`
from the |Gromacs| repository.
For more about the tool and the :file:`.clang-tidy` configuration file,
-visit https://releases.llvm.org/7.0.1/tools/clang/docs/ClangTidy.html
-
+visit http://releases.llvm.org/9.0.0/tools/clang/tools/extra/docs/clang-tidy/index.html
Scripts
-------