Skip to content
Merged
53 changes: 50 additions & 3 deletions ClangTidy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function(swift_create_clang_tidy_targets)
return()
endif()

set(argOption "DONT_GENERATE_CLANG_TIDY_CONFIG")
set(argOption "DONT_GENERATE_CLANG_TIDY_CONFIG" "WITHOUT_SWIFT_TYPES")
set(argSingle "")
set(argMulti "")

Expand Down Expand Up @@ -204,7 +204,49 @@ function(swift_create_clang_tidy_targets)
-readability-avoid-const-params-in-decls
-readability-non-const-parameter
-readability-redundant-declaration
-readability-redundant-member-init)
-readability-redundant-member-init
# Disable all new checks introduced between clang-6 and clang-14
-clang-analyzer-core.StackAddressEscape
-clang-analyzer-core.VLASize
-clang-analyzer-cplusplus.NewDeleteLeaks
-clang-analyzer-deadcode.DeadStores
-clang-analyzer-optin.cplusplus.UninitializedObject
-cert-err33-c
-cert-exp42-c
-cert-dcl37-c
-cert-dcl51-cpp
-cert-flp37-c
-cert-oop54-cpp
-cert-str34-c
-cppcoreguidelines-avoid-c-arrays
-cppcoreguidelines-avoid-goto
-cppcoreguidelines-avoid-magic-numbers
-cppcoreguidelines-avoid-non-const-global-variables
-cppcoreguidelines-init-variables
-cppcoreguidelines-macro-usage
-cppcoreguidelines-narrowing-conversions
-cppcoreguidelines-non-private-member-variables-in-classes
-cppcoreguidelines-prefer-member-initializer
-cppcoreguidelines-virtual-class-destructor
-misc-non-private-member-variables-in-classes
-misc-no-recursion
-modernize-avoid-c-arrays
-modernize-use-trailing-return-type
-performance-no-int-to-ptr
-readability-const-return-type
-readability-container-data-pointer
-readability-convert-member-functions-to-static
-readability-duplicate-include
-readability-function-cognitive-complexity
-readability-identifier-length
-readability-isolate-declaration
-readability-make-member-function-const
-readability-magic-numbers
-readability-qualified-auto
-readability-redundant-access-specifiers
-readability-suspicious-call-argument
-readability-uppercase-literal-suffix
-readability-use-anyofallof)

# Final list of checks to enable/disable
set(all_checks -* ${enabled_categories} ${disabled_checks})
Expand All @@ -228,7 +270,11 @@ AnalyzeTemporaryDtors: true

# 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
# lint everything including test suites
swift_list_compilable_targets(all_targets ONLY_THIS_REPO SWIFT_TYPES "executable" "library")
if (x_WITHOUT_SWIFT_TYPES)
swift_list_compilable_targets(all_targets ONLY_THIS_REPO)
else()
swift_list_compilable_targets(all_targets ONLY_THIS_REPO SWIFT_TYPES "executable" "library")
endif()
swift_list_compilable_targets(world_targets ONLY_THIS_REPO)

foreach(target IN LISTS world_targets)
Expand Down Expand Up @@ -256,6 +302,7 @@ AnalyzeTemporaryDtors: true
message(WARNING "No sources to lint for clang-tidy-all, that doesn't sound right")
else()
list(REMOVE_DUPLICATES all_abs_srcs)
list(FILTER all_abs_srcs EXCLUDE REGEX "pb.cc")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What were these files?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generated nanopb files? Used by real-time replay and fast start

create_clang_tidy_targets(all fixes.yaml ${all_abs_srcs})
create_clang_tidy_targets(diff fixes.yaml `git diff --diff-filter=ACMRTUXB --name-only master -- ${all_abs_srcs}`)
endif()
Expand Down