Update to clang-tidy-9
authorMark Abraham <mark.j.abraham@gmail.com>
Sun, 12 Apr 2020 08:55:43 +0000 (08:55 +0000)
committerPaul Bauer <paul.bauer.q@gmail.com>
Sun, 12 Apr 2020 08:55:43 +0000 (08:55 +0000)
Code fixes have already taken place, it remains to update the
CI configuration to use the existing llvm-9 Docker image and
adjust the documentation to match.

admin/clang-tidy.sh
admin/git-pre-commit
admin/gitlab-ci/global.gitlab-ci.yml
admin/gitlab-ci/lint.gitlab-ci.yml
docs/dev-manual/build-system.rst
docs/dev-manual/code-formatting.rst

index 677d79490c5d5399551b18c384d5791b9c4e7b5b..d606fa5b595420b6481e581dffb261fd8a914504 100755 (executable)
@@ -105,14 +105,14 @@ then
     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
index d5d5bf858ec44abe965e09ab0bae55b54a6216cc..be833e3312429ae111b8596aa19f904a9b2ad7c1 100755 (executable)
@@ -88,7 +88,7 @@ then
     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"
index bbb0716c7da2e50dc4de3a7727ac9571adf01631..2ac489e83a3b40aded97eb4ae167b0588e79928c 100644 (file)
     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
index 3836cbe5b6010f0d12b1c91c91dfe17b8f1fe112..6c3a96af0de84a3563fd562caaa3990f90257d96 100644 (file)
@@ -3,7 +3,7 @@
 clang-tidy:configure:
   extends:
     - .gromacs:base:configure
-    - .use-clang7
+    - .use-clang9
     - .rules:not-for-release
   dependencies: []
   variables:
@@ -18,7 +18,7 @@ clang-tidy:build:
     - .gromacs:base:build
     - .use-ccache
     - .variables:default
-    - .use-clang7
+    - .use-clang9
     - .rules:nightly-not-for-release
   stage: source-check
   needs:
@@ -32,7 +32,7 @@ clang-tidy:test:
     - .gromacs:base:build
     - .use-ccache
     - .variables:default
-    - .use-clang7
+    - .use-clang9
     - .rules:not-for-release
   stage: source-check
   needs:
@@ -44,7 +44,10 @@ clang-tidy:test:
     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:
index a98c9e9f84298b72f2c7155d6200c3565e6981b7..a35b57f78427902aba124c80fa84cdb690a8038e 100644 (file)
@@ -352,13 +352,13 @@ Variables affecting the ``all`` target
 
 .. 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=...``.
index 9beeb4529c35113bfddd3c72f45a0400777a5111..963389b3ce5c2eae7d1ee170dc772a5b05b26471 100644 (file)
@@ -93,15 +93,17 @@ Other files are ignored by ``clang-tidy.sh``, ``clang-format.sh``,
 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
@@ -110,12 +112,12 @@ and the commits that you push will fail the automated tests.
 
 .. 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.
 
@@ -134,8 +136,7 @@ clang-tidy discovers which formatting rules to apply from the
 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
 -------