From b42e726a8e6f84d604df19b61c707211ae38e09b Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Tue, 6 Aug 2019 11:51:32 -0700 Subject: [PATCH 1/2] Use FindClangTidy in the cmake submodule to make things easier --- CMakeLists.txt | 1 + cmake | 2 +- src/CMakeLists.txt | 23 +++++++++-------------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 91d6e4220d..84009f10f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ project(Zeek C CXX) cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) include(cmake/CommonCMakeConfig.cmake) +include(cmake/FindClangTidy.cmake) ######################################################################## ## Project/Build Configuration diff --git a/cmake b/cmake index 58e4eebe3a..cbfc46f108 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit 58e4eebe3aebd0cf608e51046805a9ab1ffa6c1b +Subproject commit cbfc46f108cd3dcf29b6c6835f072a950e36cec3 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3a48407361..bc362c6d62 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -444,17 +444,12 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/sqlite3.h DESTINATION include/zeek/3rdparty ) -find_program(CLANG_TIDY NAMES clang-tidy) -if (CLANG_TIDY) - set(TIDY_SRCS "") - foreach(f ${MAIN_SRCS}) - list(APPEND TIDY_SRCS "src/${f}") - endforeach(f) - # TODO: this currently doesn't include many of the subdirectories/plugins - # that build static libraries for inclusion into the final zeek binary - # (analyzers, broker, etc.) or generated code (BIFs, BinPAC, etc.). - add_custom_target(clang-tidy - COMMAND ${CLANG_TIDY} -p ${CMAKE_BINARY_DIR} ${TIDY_SRCS} - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - ) -endif() +######################################################################## +## Clang-tidy target now that we have all of the sources + +add_clang_tidy_files(${MAIN_SRCS}) + +# At this point we have included all of the cc files in src, all of the BinPAC +# (*.pac.cc) files, and most of the generated code for BIFs (not including +# *.bif.register.cc) +create_clang_tidy_target() From 2e6e1aa5a8c3514d96fe84a5fa6d2f059e936270 Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Wed, 7 Aug 2019 09:05:29 -0700 Subject: [PATCH 2/2] Change over to whitelisting clang-tidy options instead of blacklisting --- .clang-tidy | 44 ++++---------------------------------------- 1 file changed, 4 insertions(+), 40 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 0f0d9b609d..6ac1a8cfe7 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,40 +1,4 @@ -Checks: '*, - -abseil-string-find-startswith, - -bugprone-exception-escape, - -bugprone-macro-parentheses, - -bugprone-suspicious-semicolon, - -cert-err58-cpp, - -cppcoreguidelines-avoid-c-arrays, - -cppcoreguidelines-avoid-goto, - -cppcoreguidelines-avoid-magic-numbers, - -cppcoreguidelines-macro-usage, - -cppcoreguidelines-non-private-member-variables-in-classes, - -cppcoreguidelines-pro-bounds-array-to-pointer-decay, - -cppcoreguidelines-pro-bounds-constant-array-index, - -cppcoreguidelines-pro-bounds-pointer-arithmetic, - -cppcoreguidelines-pro-type-const-cast, - -cppcoreguidelines-pro-type-reinterpret-cast, - -fuchsia-default-arguments, - -fuchsia-multiple-inheritance, - -fuchsia-overloaded-operator, - -fuchsia-statically-constructed-objects, - -fuchsia-trailing-return, - -google-build-using-namespace, - -google-explicit-constructor, - -google-readability-braces-around-statements, - -hicpp-avoid-c-arrays, - -hicpp-avoid-goto, - -hicpp-braces-around-statements, - -hicpp-explicit-conversions, - -hicpp-no-array-decay, - -llvm-header-guard, - -misc-macro-parentheses, - -misc-non-private-member-variables-in-classes, - -misc-suspicious-semicolon, - -misc-unused-parameters, - -modernize-avoid-c-arrays, - -modernize-use-nodiscard, - -readability-braces-around-statements, - -readability-container-size-empty, - -readability-implicit-bool-conversion, - -readability-magic-numbers' +Checks: '-*, + bugprone-*, + clang-analyzer-*, + performance-*'