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/docs/getting_started/build-options.rst b/docs/getting_started/build-options.rst
index d4fe338..a14200c 100644
--- a/docs/getting_started/build-options.rst
+++ b/docs/getting_started/build-options.rst
@@ -162,7 +162,27 @@
     cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
     cmake --build ${RMM_BUILD_DIR} -- checkincludes-codebase
 
-14. Perform unit tests on development host:
+14. Perform a clang-tidy analysis:
+
+Run clang-tidy on commits in the current branch against BASE_COMMIT (default
+origin/master):
+
+.. code-block:: bash
+
+    cmake -DRMM_CONFIG=fvp_defcfg -DRMM_TOOLCHAIN=llvm -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
+    cmake --build ${RMM_BUILD_DIR} -- clang-tidy-patch
+
+Run clang-tidy on entire codebase:
+
+.. code-block:: bash
+
+    cmake -DRMM_CONFIG=fvp_defcfg -DRMM_TOOLCHAIN=llvm -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
+    cmake --build ${RMM_BUILD_DIR} -- clang-tidy-codebase
+
+Note that clang-tidy will work with all configurations. It will only check the
+source files that are used for the specified configuration.
+
+15. Perform unit tests on development host:
 
 Build and run unit tests on host platform. It is recommended to enable the
 Debug build of RMM.
@@ -180,7 +200,7 @@
     cmake --build ${RMM_BUILD_DIR} -- build -j
     ${RMM_BUILD_DIR}/Debug/rmm.elf -gxlat -v -r${NUMBER_OF_TEST_ITERATIONS}
 
-15. Generate Coverage Report.
+16. Generate Coverage Report.
 
 It is possible to generate a coverage report for a last execution of the host
 platform (whichever the variant) by using the `run-coverage` build target.