Add clang-tidy file

I've customised this from the usual C++-oriented .clang-tidy file to
work with the C codebase of libpldm. I've had to drop some desirable
checks (such as `readability-identifier-naming`) as we have C++ for the
tests and it would be nice to remain idiomatic there. It turns out
clang-tidy has configuration to control what file extensions get
analysed, however it's difficult to justify enabling it when e.g. Fedora
37 only ships clang-15 which does not contain support for this option.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I0bb01c82b27265873b9049402633672a4ad94e8a
diff --git a/.clang-tidy b/.clang-tidy
new file mode 100644
index 0000000..bdb6214
--- /dev/null
+++ b/.clang-tidy
@@ -0,0 +1,217 @@
+Checks: '
+-*,
+bugprone-argument-comment,
+bugprone-assert-side-effect,
+bugprone-bad-signal-to-kill-thread,
+bugprone-bool-pointer-implicit-conversion,
+bugprone-branch-clone,
+bugprone-dangling-handle,
+bugprone-dynamic-static-initializers,
+bugprone-fold-init-type,
+bugprone-implicit-widening-of-multiplication-result,
+bugprone-inaccurate-erase,
+bugprone-incorrect-roundings,
+bugprone-infinite-loop,
+bugprone-integer-division,
+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-multiple-statement-macro,
+bugprone-narrowing-conversions,
+bugprone-no-escape,
+bugprone-not-null-terminated-result,
+bugprone-posix-return,
+bugprone-redundant-branch-condition,
+bugprone-reserved-identifier,
+bugprone-signal-handler,
+bugprone-signed-char-misuse,
+bugprone-sizeof-container,
+bugprone-sizeof-expression,
+bugprone-spuriously-wake-up-functions,
+bugprone-string-constructor,
+bugprone-string-integer-assignment,
+bugprone-string-literal-with-embedded-nul,
+bugprone-suspicious-enum-usage,
+bugprone-suspicious-include,
+bugprone-suspicious-memset-usage,
+bugprone-suspicious-missing-comma,
+bugprone-suspicious-semicolon,
+bugprone-suspicious-string-compare,
+bugprone-swapped-arguments,
+bugprone-terminating-continue,
+bugprone-too-small-loop-variable,
+bugprone-undefined-memory-manipulation,
+bugprone-unhandled-self-assignment,
+bugprone-unused-return-value,
+cert-con36-c,
+cert-con54-cpp,
+cert-dcl03-c,
+cert-dcl16-c,
+cert-dcl21-cpp,
+cert-dcl37-c,
+cert-dcl50-cpp,
+cert-dcl51-cpp,
+cert-dcl54-cpp,
+cert-dcl58-cpp,
+cert-dcl59-cpp,
+cert-env33-c,
+cert-err09-cpp,
+cert-err34-c,
+cert-err52-cpp,
+cert-err60-cpp,
+cert-err61-cpp,
+cert-fio38-c,
+cert-flp30-c,
+cert-mem57-cpp,
+cert-msc30-c,
+cert-msc32-c,
+cert-msc50-cpp,
+cert-msc51-cpp,
+cert-oop11-cpp,
+cert-oop54-cpp,
+cert-oop57-cpp,
+cert-oop58-cpp,
+cert-pos44-c,
+cert-pos47-c,
+cert-sig30-c,
+cert-str34-c,
+clang-analyzer-apiModeling.TrustNonnull,
+clang-analyzer-apiModeling.google.GTest,
+clang-analyzer-apiModeling.llvm.CastValue,
+clang-analyzer-apiModeling.llvm.ReturnValue,
+clang-analyzer-core.CallAndMessage,
+clang-analyzer-core.CallAndMessageModeling,
+clang-analyzer-core.DivideZero,
+clang-analyzer-core.DynamicTypePropagation,
+clang-analyzer-core.NonNullParamChecker,
+clang-analyzer-core.NonnilStringConstants,
+clang-analyzer-core.NullDereference,
+clang-analyzer-core.StackAddrEscapeBase,
+clang-analyzer-core.StackAddressEscape,
+clang-analyzer-core.UndefinedBinaryOperatorResult,
+clang-analyzer-core.VLASize,
+clang-analyzer-core.builtin.BuiltinFunctions,
+clang-analyzer-core.builtin.NoReturnFunctions,
+clang-analyzer-core.uninitialized.ArraySubscript,
+clang-analyzer-core.uninitialized.Assign,
+clang-analyzer-core.uninitialized.Branch,
+clang-analyzer-core.uninitialized.CapturedBlockVariable,
+clang-analyzer-core.uninitialized.UndefReturn,
+clang-analyzer-deadcode.DeadStores,
+clang-analyzer-nullability.NullPassedToNonnull,
+clang-analyzer-nullability.NullReturnedFromNonnull,
+clang-analyzer-nullability.NullabilityBase,
+clang-analyzer-nullability.NullableDereferenced,
+clang-analyzer-nullability.NullablePassedToNonnull,
+clang-analyzer-nullability.NullableReturnedFromNonnull,
+clang-analyzer-optin.mpi.MPI-Checker,
+clang-analyzer-optin.performance.GCDAntipattern,
+clang-analyzer-optin.performance.Padding,
+clang-analyzer-optin.portability.UnixAPI,
+clang-analyzer-security.FloatLoopCounter,
+clang-analyzer-security.insecureAPI.SecuritySyntaxChecker,
+clang-analyzer-security.insecureAPI.UncheckedReturn,
+clang-analyzer-security.insecureAPI.bcmp,
+clang-analyzer-security.insecureAPI.bcopy,
+clang-analyzer-security.insecureAPI.bzero,
+clang-analyzer-security.insecureAPI.decodeValueOfObjCType,
+clang-analyzer-security.insecureAPI.getpw,
+clang-analyzer-security.insecureAPI.gets,
+clang-analyzer-security.insecureAPI.mkstemp,
+clang-analyzer-security.insecureAPI.mktemp,
+clang-analyzer-security.insecureAPI.rand,
+clang-analyzer-security.insecureAPI.strcpy,
+clang-analyzer-security.insecureAPI.vfork,
+clang-analyzer-unix.API,
+clang-analyzer-unix.DynamicMemoryModeling,
+clang-analyzer-unix.Malloc,
+clang-analyzer-unix.MallocSizeof,
+clang-analyzer-unix.MismatchedDeallocator,
+clang-analyzer-unix.Vfork,
+clang-analyzer-unix.cstring.BadSizeArg,
+clang-analyzer-unix.cstring.CStringModeling,
+clang-analyzer-unix.cstring.NullArg,
+clang-analyzer-valist.CopyToSelf,
+clang-analyzer-valist.Uninitialized,
+clang-analyzer-valist.Unterminated,
+clang-analyzer-valist.ValistBase,
+clang-analyzer-webkit.NoUncountedMemberChecker,
+clang-analyzer-webkit.RefCntblBaseVirtualDtor,
+misc-misplaced-const,
+misc-redundant-expression,
+misc-static-assert,
+misc-throw-by-value-catch-by-reference,
+misc-unconventional-assign-operator,
+misc-uniqueptr-reset-release,
+misc-unused-using-decls,
+modernize-avoid-bind,
+modernize-deprecated-headers,
+modernize-deprecated-ios-base-aliases,
+modernize-loop-convert,
+modernize-make-shared,
+modernize-make-unique,
+modernize-raw-string-literal,
+modernize-replace-auto-ptr,
+modernize-replace-random-shuffle,
+modernize-return-braced-init-list,
+modernize-shrink-to-fit,
+modernize-unary-static-assert,
+modernize-use-bool-literals,
+modernize-use-transparent-functors,
+modernize-use-uncaught-exceptions,
+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-no-int-to-ptr,
+performance-type-promotion-in-math-fn,
+performance-unnecessary-copy-initialization,
+performance-unnecessary-value-param,
+readability-avoid-const-params-in-decls,
+readability-braces-around-statements,
+readability-const-return-type,
+readability-container-size-empty,
+readability-convert-member-functions-to-static,
+readability-delete-null-pointer,
+readability-deleted-default,
+readability-else-after-return,
+readability-function-size,
+-readability-identifier-naming,
+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-qualified-auto,
+readability-redundant-access-specifiers,
+readability-redundant-control-flow,
+readability-redundant-declaration,
+readability-redundant-function-ptr-dereference,
+readability-redundant-member-init,
+readability-redundant-preprocessor,
+readability-redundant-smartptr-get,
+readability-redundant-string-cstr,
+readability-redundant-string-init,
+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,
+'
+
+WarningsAsErrors: '*'
+HeaderFilterRegex: '.*'
+CheckOptions:
+  - { key: readability-identifier-naming.VariableCase,  value: lower_case }
+  - { key: readability-identifier-naming.FunctionCase,  value: lower_case }
+  - { key: readability-identifier-naming.ParameterCase, value: lower_case }
+  - { key: readability-identifier-naming.NamespaceCase, value: lower_case }
+  - { key: readability-identifier-naming.StructCase,    value: lower_case  }
+  - { key: cppcoreguidelines-macro-usage.AllowedRegexp, value: DEBUG*|NLOHMANN_JSON_SERIALIZE_ENUM }