# Copyright © Advanced Micro Devices, Inc., or its affiliates.
# SPDX-License-Identifier:  MIT

# Explicit positive list of clang-tidy checks.
#
# Why an explicit list (vs category wildcards like bugprone-*, misc-*, ...):
# upgrading the clang-tidy binary to a newer LLVM auto-enables every
# newly-introduced check in those categories, producing surprise failures.
# With an explicit list, new checks added by future LLVMs do NOT activate
# until they are added here on purpose.
#
# Generated from `clang-tidy --list-checks` against LLVM 20 with the prior
# wildcard config. 209 checks total. Re-generate after a deliberate
# clang-tidy upgrade to pick up new checks.
#
# Checks the prior wildcard config explicitly excluded (and which therefore
# remain absent here on purpose — do not add without discussion):
#   -fuchsia-trailing-return
#   -modernize-use-trailing-return-type
#   -modernize-concat-nested-namespaces
#   -modernize-use-nodiscard
#   -modernize-use-using
#   -performance-enum-size
#   -readability-magic-numbers
#   -readability-identifier-length
#   -readability-qualified-auto
#   -readability-uppercase-literal-suffix
#   -readability-avoid-unconditional-preprocessor-if
#   -readability-use-anyofallof
#   -readability-function-cognitive-complexity
#   -bugprone-easily-swappable-parameters
#   -bugprone-unchecked-optional-access
#   -misc-include-cleaner
#   -misc-non-private-member-variables-in-classes
#   -misc-no-recursion
#   -misc-header-include-cycle
#   -misc-use-anonymous-namespace
# Newer-LLVM checks the prior config also disabled pending an upgrade
# (kept absent here for the same reason):
#   -portability-avoid-pragma-once
#   -modernize-use-scoped-lock
#   -readability-use-concise-preprocessor-directives
#   -readability-math-missing-parentheses
Checks: >
  -*,
  bugprone-argument-comment,
  bugprone-assert-side-effect,
  bugprone-assignment-in-if-condition,
  bugprone-bad-signal-to-kill-thread,
  bugprone-bitwise-pointer-cast,
  bugprone-bool-pointer-implicit-conversion,
  bugprone-branch-clone,
  bugprone-casting-through-void,
  bugprone-chained-comparison,
  bugprone-compare-pointer-to-member-virtual-function,
  bugprone-copy-constructor-init,
  bugprone-crtp-constructor-accessibility,
  bugprone-dangling-handle,
  bugprone-dynamic-static-initializers,
  bugprone-empty-catch,
  bugprone-exception-escape,
  bugprone-fold-init-type,
  bugprone-forward-declaration-namespace,
  bugprone-forwarding-reference-overload,
  bugprone-implicit-widening-of-multiplication-result,
  bugprone-inaccurate-erase,
  bugprone-inc-dec-in-conditions,
  bugprone-incorrect-enable-if,
  bugprone-incorrect-enable-shared-from-this,
  bugprone-incorrect-roundings,
  bugprone-infinite-loop,
  bugprone-integer-division,
  bugprone-lambda-function-name,
  bugprone-macro-parentheses,
  bugprone-macro-repeated-side-effects,
  bugprone-misplaced-operator-in-strlen-in-alloc,
  bugprone-misplaced-pointer-arithmetic-in-alloc,
  bugprone-misplaced-widening-cast,
  bugprone-move-forwarding-reference,
  bugprone-multi-level-implicit-pointer-conversion,
  bugprone-multiple-new-in-one-expression,
  bugprone-multiple-statement-macro,
  bugprone-narrowing-conversions,
  bugprone-no-escape,
  bugprone-non-zero-enum-to-bool-conversion,
  bugprone-nondeterministic-pointer-iteration-order,
  bugprone-not-null-terminated-result,
  bugprone-optional-value-conversion,
  bugprone-parent-virtual-call,
  bugprone-pointer-arithmetic-on-polymorphic-object,
  bugprone-posix-return,
  bugprone-redundant-branch-condition,
  bugprone-reserved-identifier,
  bugprone-return-const-ref-from-parameter,
  bugprone-shared-ptr-array-mismatch,
  bugprone-signal-handler,
  bugprone-signed-char-misuse,
  bugprone-sizeof-container,
  bugprone-sizeof-expression,
  bugprone-spuriously-wake-up-functions,
  bugprone-standalone-empty,
  bugprone-string-constructor,
  bugprone-string-integer-assignment,
  bugprone-string-literal-with-embedded-nul,
  bugprone-stringview-nullptr,
  bugprone-suspicious-enum-usage,
  bugprone-suspicious-include,
  bugprone-suspicious-memory-comparison,
  bugprone-suspicious-memset-usage,
  bugprone-suspicious-missing-comma,
  bugprone-suspicious-realloc-usage,
  bugprone-suspicious-semicolon,
  bugprone-suspicious-string-compare,
  bugprone-suspicious-stringview-data-usage,
  bugprone-swapped-arguments,
  bugprone-switch-missing-default-case,
  bugprone-tagged-union-member-count,
  bugprone-terminating-continue,
  bugprone-throw-keyword-missing,
  bugprone-too-small-loop-variable,
  bugprone-undefined-memory-manipulation,
  bugprone-undelegated-constructor,
  bugprone-unhandled-exception-at-new,
  bugprone-unhandled-self-assignment,
  bugprone-unique-ptr-array-mismatch,
  bugprone-unsafe-functions,
  bugprone-unused-local-non-trivial-variable,
  bugprone-unused-raii,
  bugprone-unused-return-value,
  bugprone-use-after-move,
  bugprone-virtual-near-miss,
  google-global-names-in-headers,
  misc-confusable-identifiers,
  misc-const-correctness,
  misc-coroutine-hostile-raii,
  misc-definitions-in-headers,
  misc-misleading-bidirectional,
  misc-misleading-identifier,
  misc-misplaced-const,
  misc-new-delete-overloads,
  misc-non-copyable-objects,
  misc-redundant-expression,
  misc-static-assert,
  misc-throw-by-value-catch-by-reference,
  misc-unconventional-assign-operator,
  misc-uniqueptr-reset-release,
  misc-unused-alias-decls,
  misc-unused-parameters,
  misc-unused-using-decls,
  misc-use-internal-linkage,
  modernize-avoid-bind,
  modernize-avoid-c-arrays,
  modernize-deprecated-headers,
  modernize-deprecated-ios-base-aliases,
  modernize-loop-convert,
  modernize-macro-to-enum,
  modernize-make-shared,
  modernize-make-unique,
  modernize-min-max-use-initializer-list,
  modernize-pass-by-value,
  modernize-raw-string-literal,
  modernize-redundant-void-arg,
  modernize-replace-auto-ptr,
  modernize-replace-disallow-copy-and-assign-macro,
  modernize-replace-random-shuffle,
  modernize-return-braced-init-list,
  modernize-shrink-to-fit,
  modernize-type-traits,
  modernize-unary-static-assert,
  modernize-use-auto,
  modernize-use-bool-literals,
  modernize-use-constraints,
  modernize-use-default-member-init,
  modernize-use-designated-initializers,
  modernize-use-emplace,
  modernize-use-equals-default,
  modernize-use-equals-delete,
  modernize-use-integer-sign-comparison,
  modernize-use-noexcept,
  modernize-use-nullptr,
  modernize-use-override,
  modernize-use-ranges,
  modernize-use-starts-ends-with,
  modernize-use-std-format,
  modernize-use-std-numbers,
  modernize-use-std-print,
  modernize-use-transparent-functors,
  modernize-use-uncaught-exceptions,
  performance-avoid-endl,
  performance-faster-string-find,
  performance-for-range-copy,
  performance-implicit-conversion-in-loop,
  performance-inefficient-algorithm,
  performance-inefficient-string-concatenation,
  performance-inefficient-vector-operation,
  performance-move-const-arg,
  performance-move-constructor-init,
  performance-no-automatic-move,
  performance-no-int-to-ptr,
  performance-noexcept-destructor,
  performance-noexcept-move-constructor,
  performance-noexcept-swap,
  performance-trivially-destructible,
  performance-type-promotion-in-math-fn,
  performance-unnecessary-copy-initialization,
  performance-unnecessary-value-param,
  portability-restrict-system-includes,
  portability-simd-intrinsics,
  portability-std-allocator-const,
  portability-template-virtual-member-function,
  readability-avoid-const-params-in-decls,
  readability-avoid-nested-conditional-operator,
  readability-avoid-return-with-void-value,
  readability-braces-around-statements,
  readability-const-return-type,
  readability-container-contains,
  readability-container-data-pointer,
  readability-container-size-empty,
  readability-convert-member-functions-to-static,
  readability-delete-null-pointer,
  readability-duplicate-include,
  readability-else-after-return,
  readability-enum-initial-value,
  readability-function-size,
  readability-identifier-naming,
  readability-implicit-bool-conversion,
  readability-inconsistent-declaration-parameter-name,
  readability-isolate-declaration,
  readability-make-member-function-const,
  readability-misleading-indentation,
  readability-misplaced-array-index,
  readability-named-parameter,
  readability-non-const-parameter,
  readability-operators-representation,
  readability-redundant-access-specifiers,
  readability-redundant-casting,
  readability-redundant-control-flow,
  readability-redundant-declaration,
  readability-redundant-function-ptr-dereference,
  readability-redundant-inline-specifier,
  readability-redundant-member-init,
  readability-redundant-preprocessor,
  readability-redundant-smartptr-get,
  readability-redundant-string-cstr,
  readability-redundant-string-init,
  readability-reference-to-constructed-temporary,
  readability-simplify-boolean-expr,
  readability-simplify-subscript-expr,
  readability-static-accessed-through-instance,
  readability-static-definition-in-anonymous-namespace,
  readability-string-compare,
  readability-suspicious-call-argument,
  readability-uniqueptr-delete-release,
  readability-use-std-min-max

WarningsAsErrors: "*"
HeaderFileExtensions: ['h','hpp']

# This regex is a inclusion filter for the files to be checked. Its a Posix regex and
# does not seem to support negative lookahead.
HeaderFilterRegex: '.'
ExcludeHeaderFilterRegex: '^(.*(data_objects|python3\.[0-9]+|nanobind|_deps).*)$'

CheckOptions:
  # Disable type analysis for misc-use-internal-linkage to maintain consistent
  # behavior across clang-tidy versions. AnalyzeTypes was introduced after
  # LLVM 20 and defaults to true, which flags classes/structs in .cpp files.
  # Older clang-tidy versions silently ignore this option.
  - { key: misc-use-internal-linkage.AnalyzeTypes,                value: 'false' }
  # Disable pointer pointee const analysis for misc-const-correctness.
  # AnalyzePointers was introduced after LLVM 20 and defaults to true, which
  # flags pointer variables whose pointees could be declared const.
  # Older clang-tidy versions silently ignore this option.
  - { key: misc-const-correctness.AnalyzePointers,                value: 'false' }
  # Disable parameter const analysis for misc-const-correctness.
  # AnalyzeParameters was introduced after LLVM 20 and defaults to true.
  # Older clang-tidy versions silently ignore this option.
  - { key: misc-const-correctness.AnalyzeParameters,              value: 'false' }
  # Disable post-LLVM 20 bugprone-exception-escape sub-checks that expand the
  # check's scope beyond what LLVM 20 analyzed. Older versions ignore these.
  - { key: bugprone-exception-escape.CheckDestructors,             value: 'false' }
  - { key: bugprone-exception-escape.CheckMoveMemberFunctions,     value: 'false' }
  - { key: bugprone-exception-escape.CheckNothrowFunctions,        value: 'false' }
  - { key: readability-identifier-naming.NamespaceCase,           value: lower_case }
  - { key: readability-identifier-naming.ClassCase,               value: CamelCase }
  - { key: readability-identifier-naming.StructCase,              value: CamelCase }
  - { key: readability-identifier-naming.FunctionCase,            value: camelBack }
  - { key: readability-identifier-naming.VariableCase,            value: camelBack }
  - { key: readability-identifier-naming.ParameterCase,           value: camelBack }
  - { key: readability-identifier-naming.MemberCase,              value: camelBack }
  - { key: readability-identifier-naming.PrivateMemberCase,       value: camelBack }
  - { key: readability-identifier-naming.ProtectedMemberPrefix,   value: _ }
  - { key: readability-identifier-naming.PrivateMemberPrefix,     value: _ }
  - { key: readability-identifier-naming.EnumCase,                value: CamelCase  }
  - { key: readability-identifier-naming.EnumConstantCase,        value: UPPER_CASE }
  - { key: readability-identifier-naming.GlobalConstantCase,      value: UPPER_CASE }
  - { key: readability-identifier-naming.ConstexprVariableCase,   value: UPPER_CASE }
  - { key: readability-identifier-naming.StaticVariablePrefix,    value: s_ }
  # Ignore hipdnnHandle name everywhere (required for public API compatibility)
  - { key: readability-identifier-naming.StructIgnoredRegexp,     value: "hipdnnHandle" }
  - { key: readability-identifier-naming.ClassIgnoredRegexp,      value: "hipdnnHandle" }
  - { key: readability-identifier-naming.TypedefIgnoredRegexp,    value: "hipdnnHandle" }
