feat(tools): add support for clang-tidy
This patch integrates clang-tidy into the project. Custom targets for
clang-tidy are added, which run clang-tidy on either the codebase or
pending commits.
A selection of checks has been enabled, some have their warnings
promoted to errors. The enabled checks, and the checks which have
warnings promoted to errors, are configured in the .clang-tidy file.
Signed-off-by: Chuyue Luo <Chuyue.Luo@arm.com>
Change-Id: Idba6d6b3e4438f524ac68307b1e463b9aec958e3
diff --git a/.clang-tidy b/.clang-tidy
new file mode 100644
index 0000000..e0d8eae
--- /dev/null
+++ b/.clang-tidy
@@ -0,0 +1,36 @@
+#
+# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
+#
+
+#
+# Configuration file for clang-tidy.
+#
+# Checks are specified as a comma-separated list. A '-' before the name of the
+# check will disable that check.
+#
+Checks: '-*,
+ bugprone-*,
+ -bugprone-reserved-identifier,
+ -bugprone-easily-swappable-parameters,
+ -bugprone-branch-clone,
+ misc-redundant-expression,
+ misc-unused-parameters,
+ google-readability-casting'
+
+#
+# The WarningsAsErrors field specifies which checks will have their warnings
+# promoted to errors. These checks are specified in the same way as above.
+#
+WarningsAsErrors: '-*,
+ bugprone-narrowing-conversions,
+ bugprone-implicit-widening-of-multiplication-result,
+ bugprone-infinite-loop,
+ bugprone-too-small-loop-variable'
+
+#
+# The HeaderFilterRegex field specifies which header files clang-tidy will
+# output warnings from. Note that this does NOT affect which *.c files are
+# checked.
+#
+HeaderFilterRegex: 'drivers/|plat/|runtime/|lib/'