-
We are using Clang-Tidy.
-
We use the current stable release in CI, which is version 11.
-
To get started, a very small set of checks are run continuously, with an eye to expanding the set gradually as we modernize and improve the code base.
-
Unlike formatting, developers can run newer versions of clang-tidy locally and fix more warnings.
We have a convenience script for running clang-tidy.
This script needs the path to a directory containing the compilation database (compile_commands.json
)
The script makes use of GNU Parallel and clang-tidy
.
To install them on macOS:
brew install parallel llvm
On Debian-derivative Linux distributions, you have more choices on the version of clang-tidy, e.g.:
apt-get install parallel clang-tidy-12
Alternatively apt-get install clang-tidy
will give you a "default" version of clang-tidy
from the distribution.
Here's an example of generating two build directories, build.debug
and build.release
at the root of Greenplum repository:
for debug build:
$ CXX=clang++ cmake -GNinja -Hsrc/backend/gporca -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug -Bbuild.debug
and release:
$ CXX=clang++ cmake -GNinja -Hsrc/backend/gporca -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -Bbuild.release
To check (it's unsurprising if we pass the check in one configuration but not another)
$ src/tools/tidy chk build.debug
and
$ src/tools/tidy chk build.release
Note that the script assumes the name of clang-tidy
is clang-tidy
and it can be found on your PATH
.
So if you're (typically) using clang-tidy
from Homebrew's LLVM package, you'll override that assumption by e.g.:
$ CLANG_TIDY=/usr/local/opt/llvm/bin/clang-tidy src/tools/tidy chk build.debug