Create a clang-tidy option for building IREE (#9402)
Adds an IREE_ENABLE_CLANG_TIDY flag to IREE to start turning on clang-tidy features.
Anything that triggers failures is disabled right now.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3d4875d..412865e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -34,6 +34,7 @@
option(IREE_ENABLE_RUNTIME_TRACING "Enables instrumented runtime tracing." OFF)
option(IREE_ENABLE_COMPILER_TRACING "Enables instrumented compiler tracing." OFF)
option(IREE_ENABLE_THREADING "Builds IREE in with thread library support." ON)
+option(IREE_ENABLE_CLANG_TIDY "Builds IREE in with clang tidy enabled on IREE's libraries." OFF)
# TODO(#8469): remove the dependency on cpuinfo entirely.
option(IREE_ENABLE_CPUINFO "Enables runtime use of cpuinfo for processor topology detection." ON)
@@ -671,6 +672,10 @@
# IREE top-level libraries
#-------------------------------------------------------------------------------
+if(IREE_ENABLE_CLANG_TIDY)
+ set(CMAKE_CXX_CLANG_TIDY clang-tidy -warnings-as-errors=*)
+endif()
+
add_subdirectory(build_tools/embed_data/)
# Note: Test deps are not built as part of all (use the iree-test-deps target).
@@ -695,6 +700,11 @@
# tools/ can depend on compiler/ and runtime/
add_subdirectory(tools)
+
+if(IREE_ENABLE_CLANG_TIDY)
+ set(CMAKE_CXX_CLANG_TIDY "")
+endif()
+
if(IREE_BUILD_TRACY)
if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
message(WARNING "Building Tracy (IREE_BUILD_TRACY) on non-Linux is unsupported and may fail below.")
diff --git a/compiler/src/.clang-tidy b/compiler/src/.clang-tidy
new file mode 100644
index 0000000..4e3f659
--- /dev/null
+++ b/compiler/src/.clang-tidy
@@ -0,0 +1,15 @@
+Checks: >
+ -*,
+ clang-diagnostic-*,
+ misc-*,
+ llvm-*,
+ -misc-unused-parameters,
+ -misc-non-private-member-variables-in-classes,
+ -misc-no-recursion,
+ -misc-unused-using-decls,
+ -llvm-else-after-return,
+ -llvm-include-order,
+ -llvm-qualified-auto,
+ -misc-redundant-expression,
+ -llvm-namespace-comment
+
diff --git a/runtime/src/.clang-tidy b/runtime/src/.clang-tidy
new file mode 100644
index 0000000..97faac2
--- /dev/null
+++ b/runtime/src/.clang-tidy
@@ -0,0 +1,7 @@
+
+Checks: >
+ -clang-analyzer-deadcode*,
+ -clang-analyzer-cplusplus*,
+ -clang-analyzer-core*
+
+HeaderFilterRegex: '.*^(third_party|googletest).*'
diff --git a/tools/.clang-tidy b/tools/.clang-tidy
new file mode 100644
index 0000000..97faac2
--- /dev/null
+++ b/tools/.clang-tidy
@@ -0,0 +1,7 @@
+
+Checks: >
+ -clang-analyzer-deadcode*,
+ -clang-analyzer-cplusplus*,
+ -clang-analyzer-core*
+
+HeaderFilterRegex: '.*^(third_party|googletest).*'