6969# will explicitly disable these targets from the command line at configure time
7070#
7171
72+ set (CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Export compile commands" FORCE)
73+
7274# Helper function to actually create the targets, not to be used outside this file
7375function (create_clang_tidy_targets key fixes)
7476 add_custom_target (
@@ -93,7 +95,7 @@ function(swift_create_clang_tidy_targets)
9395 return ()
9496 endif ()
9597
96- set (argOption "DONT_GENERATE_CLANG_TIDY_CONFIG" )
98+ set (argOption "DONT_GENERATE_CLANG_TIDY_CONFIG" "WITHOUT_SWIFT_TYPES" )
9799 set (argSingle "" )
98100 set (argMulti "" )
99101
@@ -115,12 +117,7 @@ function(swift_create_clang_tidy_targets)
115117 early_exit(STATUS "${PROJECT_NAME} clang-tidy support is DISABLED" )
116118 endif ()
117119
118- # This is required so that clang-tidy can work out what compiler options to use for each file
119- set (CMAKE_EXPORT_COMPILE_COMMANDS
120- ON
121- CACHE BOOL "Export compile commands" FORCE)
122-
123- find_program (CLANG_TIDY NAMES clang-tidy-6.0 clang-tidy)
120+ find_program (CLANG_TIDY NAMES clang-tidy-14 clang-tidy)
124121
125122 if ("${CLANG_TIDY} " STREQUAL "CLANG_TIDY-NOTFOUND" )
126123 message (WARNING "Could not find clang-tidy, link targets will not be created" )
@@ -204,7 +201,49 @@ function(swift_create_clang_tidy_targets)
204201 -readability-avoid-const-params-in-decls
205202 -readability-non-const-parameter
206203 -readability-redundant-declaration
207- -readability-redundant-member-init)
204+ -readability-redundant-member-init
205+ # Disable all new checks introduced between clang-6 and clang-14
206+ -clang-analyzer-core.StackAddressEscape
207+ -clang-analyzer-core.VLASize
208+ -clang-analyzer-cplusplus.NewDeleteLeaks
209+ -clang-analyzer-deadcode.DeadStores
210+ -clang-analyzer-optin.cplusplus.UninitializedObject
211+ -cert-err33-c
212+ -cert-exp42-c
213+ -cert-dcl37-c
214+ -cert-dcl51-cpp
215+ -cert-flp37-c
216+ -cert-oop54-cpp
217+ -cert-str34-c
218+ -cppcoreguidelines-avoid-c-arrays
219+ -cppcoreguidelines-avoid-goto
220+ -cppcoreguidelines-avoid-magic-numbers
221+ -cppcoreguidelines-avoid-non-const-global -variables
222+ -cppcoreguidelines-init-variables
223+ -cppcoreguidelines-macro-usage
224+ -cppcoreguidelines-narrowing-conversions
225+ -cppcoreguidelines-non-private -member-variables -in-classes
226+ -cppcoreguidelines-prefer-member-initializer
227+ -cppcoreguidelines-virtual-class-destructor
228+ -misc-non-private -member-variables -in-classes
229+ -misc-no -recursion
230+ -modernize-avoid-c-arrays
231+ -modernize-use-trailing-return-type
232+ -performance-no -int-to-ptr
233+ -readability-const-return-type
234+ -readability-container-data-pointer
235+ -readability-convert-member-functions-to-static
236+ -readability-duplicate-include
237+ -readability-function-cognitive-complexity
238+ -readability-identifier-length
239+ -readability-isolate-declaration
240+ -readability-make-member-function-const
241+ -readability-magic-numbers
242+ -readability-qualified-auto
243+ -readability-redundant-access-specifiers
244+ -readability-suspicious-call-argument
245+ -readability-uppercase-literal-suffix
246+ -readability-use-anyofallof)
208247
209248 # Final list of checks to enable/disable
210249 set (all_checks -* ${enabled_categories} ${disabled_checks} )
@@ -228,7 +267,11 @@ AnalyzeTemporaryDtors: true
228267
229268 # Only lint targets created in this repository. Later on we will create 2 targets: clang-tidy-all will lint all "core" targets, executables and libraries clang-tidy-world will
230269 # lint everything including test suites
231- swift_list_compilable_targets(all_targets ONLY_THIS_REPO SWIFT_TYPES "executable" "library" )
270+ if (x_WITHOUT_SWIFT_TYPES)
271+ swift_list_compilable_targets(all_targets ONLY_THIS_REPO)
272+ else ()
273+ swift_list_compilable_targets(all_targets ONLY_THIS_REPO SWIFT_TYPES "executable" "library" )
274+ endif ()
232275 swift_list_compilable_targets(world_targets ONLY_THIS_REPO)
233276
234277 foreach (target IN LISTS world_targets)
@@ -256,6 +299,7 @@ AnalyzeTemporaryDtors: true
256299 message (WARNING "No sources to lint for clang-tidy-all, that doesn't sound right" )
257300 else ()
258301 list (REMOVE_DUPLICATES all_abs_srcs)
302+ list (FILTER all_abs_srcs EXCLUDE REGEX "pb.cc" )
259303 create_clang_tidy_targets(all fixes.yaml ${all_abs_srcs} )
260304 create_clang_tidy_targets(diff fixes.yaml `git diff --diff-filter =ACMRTUXB --name -only master -- ${all_abs_srcs} `)
261305 endif ()
0 commit comments