Skip to content

Commit

Permalink
Create a clang-tidy option for building IREE (#9402)
Browse files Browse the repository at this point in the history
Adds an IREE_ENABLE_CLANG_TIDY flag to IREE to start turning on clang-tidy features.
Anything that triggers failures is disabled right now.
  • Loading branch information
rsuderman authored Jun 8, 2022
1 parent 74d741e commit d42e002
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ include(CMakeDependentOption)
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)
Expand Down Expand Up @@ -671,6 +672,10 @@ add_custom_target(iree-test-deps COMMENT "Building IREE test deps")
# 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).
Expand All @@ -695,6 +700,11 @@ add_subdirectory(runtime)
# 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.")
Expand Down
15 changes: 15 additions & 0 deletions compiler/src/.clang-tidy
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions runtime/src/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

Checks: >
-clang-analyzer-deadcode*,
-clang-analyzer-cplusplus*,
-clang-analyzer-core*
HeaderFilterRegex: '.*^(third_party|googletest).*'
7 changes: 7 additions & 0 deletions tools/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

Checks: >
-clang-analyzer-deadcode*,
-clang-analyzer-cplusplus*,
-clang-analyzer-core*
HeaderFilterRegex: '.*^(third_party|googletest).*'

0 comments on commit d42e002

Please sign in to comment.