Commit Graph

78 Commits

Author SHA1 Message Date
Maksim Kita
f4101861e7 Function name normalization fix functions header 2022-10-04 17:29:33 +02:00
Azat Khuzhin
4e3135383b Fix clang-tidy warnings (from clang-15)
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-09-10 21:38:35 +02:00
Robert Schulze
cedf75ed5e
Enable clang-tidy for headers
clang-tidy now also checks code in header files. Because the analyzer
finds tons of issues, activate the check only for directory "base/" (see
file ".clang-tidy"). All other directories, in particular "src/" are
left to future work.

While many findings were fixed, some were not (and suppressed instead).
Reasons for this include: a) the file is 1:1 copypaste of a 3rd-party
lib (e.g. pcg_extras.h) and fixing stuff would make upgrades/fixes more
difficult b) a fix would have broken lots of using code
2022-08-31 10:48:15 +00:00
Alexey Milovidov
d2ed4c5fc5
Check what will be if I enable concurrency-mt-unsafe in clang-tidy 2022-08-15 07:49:23 +03:00
Anton Popov
df6882d2b9
Revert "Fix errors of CheckTriviallyCopyableMove type" 2022-06-07 13:53:10 +02:00
Robert Schulze
2d87af2a15
Merge pull request #37647 from DevTeamBK/Fix-all-CheckTriviallyCopyableMove-Errors
Fix errors of CheckTriviallyCopyableMove type
2022-06-05 19:58:47 +02:00
HeenaBansal2009
05d2b13510 temporary commit to get the errors of CheckTriviallyCopyableMove type 2022-05-30 04:22:41 -07:00
Alexey Milovidov
dce7a86ca9 Merge branch 'master' into llvm-14 2022-05-22 22:38:07 +02:00
Robert Schulze
5eb741ec0b
Merge pull request #37347 from ClickHouse/disable-readability-identifier-length
Disable clang-tidy readability-identifier-length
2022-05-20 09:04:59 +02:00
Robert Schulze
a609287761
Add a comment about disabling further checks 2022-05-19 17:39:53 +02:00
Robert Schulze
17afe42ad3
Disable clang-tidy readability-identifier-length
readability-identifier-length was added with Clang 14 which does not yet
run in the central builds yet but (at least on my system) locally.
Disabling the check because it is too noisy. Older clang-tidy versions
will just ignore the setting.
2022-05-19 10:41:27 +02:00
Robert Schulze
0c55ac76d2
A few clangtidy updates
Enable:

- bugprone-lambda-function-name: "Checks for attempts to get the name of
  a function from within a lambda expression. The name of a lambda is
  always something like operator(), which is almost never what was
  intended."

- bugprone-unhandled-self-assignment: "Finds user-defined copy
  assignment operators which do not protect the code against
  self-assignment either by checking self-assignment explicitly or using
  the copy-and-swap or the copy-and-move method.""

- hicpp-invalid-access-moved: "Warns if an object is used after it has
  been moved."

- hicpp-use-noexcept: "This check replaces deprecated dynamic exception
  specifications with the appropriate noexcept specification (introduced
  in C++11)"

- hicpp-use-override: "Adds override (introduced in C++11) to overridden
  virtual functions and removes virtual from those functions as it is
  not required."

- performance-type-promotion-in-math-fn: "Finds calls to C math library
  functions (from math.h or, in C++, cmath) with implicit float to
  double promotions."

Split up:

- cppcoreguidelines-*. Some of them may be useful (haven't checked in
  detail), therefore allow to toggle them individually.

Disable:

- linuxkernel-*. Obvious.
2022-05-17 20:56:57 +02:00
Nikolai Kochetov
4de6200345
Update .clang-tidy 2022-05-16 16:20:23 +02:00
Nikolai Kochetov
f1bc2bc615 Merge branch 'master' into llvm-14 2022-05-16 12:03:26 +02:00
Robert Schulze
1b81bb49b4
Enable clang-tidy modernize-deprecated-headers & hicpp-deprecated-headers
Official docs:

  Some headers from C library were deprecated in C++ and are no longer
  welcome in C++ codebases. Some have no effect in C++. For more details
  refer to the C++ 14 Standard [depr.c.headers] section. This check
  replaces C standard library headers with their C++ alternatives and
  removes redundant ones.
2022-05-09 08:23:33 +02:00
Robert Schulze
ae57e6df9c
Enable clang-tidy readability-convert-member-function-to-static
Official docs:

  Finds non-static member functions that can be made static because the
  functions don’t use this. After applying modifications as suggested by
  the check, running the check again might find more opportunities to
  mark member functions static.
2022-05-08 19:31:38 +02:00
Robert Schulze
742d38a115
Enable clang-tidy performance-trivially-destructible
Official docs:

  Finds types that could be made trivially-destructible by removing
  out-of-line defaulted destructor declarations.
2022-05-08 19:31:38 +02:00
Robert Schulze
f866f8143d
Enable clang-tidy modernize-use-noexcept
Official docs:

  This check replaces deprecated dynamic exception specifications with
  the appropriate noexcept specification (introduced in C++11). By
  default this check will replace throw() with noexcept, and
  throw(<exception>[,...]) or throw(...) with noexcept(false).
2022-05-08 19:31:38 +02:00
Robert Schulze
2219879d35
Enable clang-tidy modernize-use-equals-default
Official docs:

  This check replaces default bodies of special member functions with =
  default;. The explicitly defaulted function declarations enable more
  opportunities in optimization, because the compiler might treat
  explicitly defaulted functions as trivial.
2022-05-08 19:31:38 +02:00
Robert Schulze
a10f3e46c7
Enable clang-tidy modernize-replace-disallow-copy-and-assign-macro
Official docs:

  Finds macro expansions of DISALLOW_COPY_AND_ASSIGN(Type) and replaces
  them with a deleted copy constructor and a deleted assignment
  operator. Before the delete keyword was introduced in C++11 it was
  common practice to declare a copy constructor and an assignment
  operator as private members. This effectively makes them unusable to
  the public API of a class. With the advent of the delete keyword in
  C++11 we can abandon the private access of the copy constructor and
  the assignment operator and delete the methods entirely.
2022-05-08 19:31:38 +02:00
Robert Schulze
6eb9843fb8
Enable clang-tidy modernize-deprecated-ios-base-aliases
Official docs:

  Detects usage of the deprecated member types of std::ios_base and
  replaces those that have a non-deprecated equivalent.
2022-05-08 19:31:38 +02:00
Robert Schulze
1c1d3c3290
Enable clang-tidy misc-non-copyable-objects
Official docs:

  The check flags dereferences and non-pointer declarations of objects
  that are not meant to be passed by value, such as C FILE objects or
  POSIX pthread_mutex_t objects.
2022-05-08 19:31:35 +02:00
Robert Schulze
4e775e7eab
Enable clang-tidy misc-new-delete-overloads
Official docs:

  The check flags overloaded operator new() and operator delete()
  functions that do not have a corresponding free store function defined
  within the same scope. For instance, the check will flag a class
  implementation of a non-placement operator new() when the class does
  not also define a non-placement operator delete() function as well.
2022-05-08 19:30:58 +02:00
Robert Schulze
ad524e28a8
Enable clang-tidy misc-definitions-in-headers
Official docs:

  Finds non-extern non-inline function and variable definitions in
  header files, which can lead to potential ODR violations in case these
  headers are included from multiple translation units.
2022-05-08 19:30:58 +02:00
Robert Schulze
ea1cd8af0c
Enable clang-tidy hicpp-use-equals-default
Official docs:

  This check replaces default bodies of special member functions with =
  default;. The explicitly defaulted function declarations enable more
  opportunities in optimization, because the compiler might treat
  explicitly defaulted functions as trivial.
2022-05-08 19:30:58 +02:00
Robert Schulze
b51edf69b4
Enable clang-tidy google-global-names-in-headers
Official docs:

  Flag global namespace pollution in header files. Right now it only
  triggers on using declarations and directives.
2022-05-08 19:30:58 +02:00
Robert Schulze
99b92438f0
Enable clang-tidy cert-oop58-cpp
Official docs:

  Finds assignments to the copied object and its direct or indirect
  members in copy constructors and copy assignment operators.
2022-05-08 19:30:58 +02:00
Robert Schulze
f99a3d9284
Enable clang-tidy cert-dcl58-cpp
Official docs:

  Modification of the std or posix namespace can result in undefined
  behavior. This check warns for such modifications.
2022-05-08 19:30:58 +02:00
Robert Schulze
97603321f5
Enable clang-tidy cert-dcl51-cpp
Official docs:

  Checks for usages of identifiers reserved for use by the
  implementation. The C and C++ standards both reserve the following
  names for such use: identifiers that begin with an underscore followed
  by an uppercase letter; identifiers in the global namespace that begin
  with an underscore.
2022-05-08 19:30:58 +02:00
Robert Schulze
447f2e1d5d
Enable clang-tidy cert-dcl37-c
Official docs:

  Checks for usages of identifiers reserved for use by the
  implementation. The C and C++ standards both reserve the following
  names for such use: identifiers that begin with an underscore followed
  by an uppercase letter; identifiers in the global namespace that begin
  with an underscore.
2022-05-08 19:30:58 +02:00
Robert Schulze
fb781dab3a
Enable clang-tidy bugprone-unhandled-exception-at-new
Official docs:

  Finds calls to new with missing exception handler for std::bad_alloc.
  Calls to new may throw exceptions of type std::bad_alloc that should
  be handled. Alternatively, the nonthrowing form of new can be used.
  The check verifies that the exception is handled in the function that
  calls new. If a nonthrowing version is used or the exception is
  allowed to propagate out of the function no warning is generated. The
  exception handler is checked if it catches a std::bad_alloc or
  std::exception exception type, or all exceptions (catch-all). The
  check assumes that any user-defined operator new is either noexcept or
  may throw an exception of type std::bad_alloc (or one derived from
  it). Other exception class types are not taken into account.
2022-05-08 19:30:58 +02:00
Robert Schulze
89dbbe9a6e
Enable clang-tidy bugprone-spuriously-wake-up-functions
Official docs:

  Finds cnd_wait, cnd_timedwait, wait, wait_for, or wait_until function
  calls when the function is not invoked from a loop that checks whether
  a condition predicate holds or the function has a condition parameter.
2022-05-08 19:30:58 +02:00
Robert Schulze
d0b2fa952c
Enable clang-tidy bugprone-signal-handler
Official docs:

  Finds functions registered as signal handlers that call non
  asynchronous-safe functions.
2022-05-08 19:30:58 +02:00
Robert Schulze
9f1116b385
Enable clang-tidy bugprone-no-escape
Official docs:

  Finds pointers with the noescape attribute that are captured by an
  asynchronously-executed block. The block arguments in dispatch_async()
  and dispatch_after() are guaranteed to escape, so it is an error if a
  pointer with the noescape attribute is captured by one of these
  blocks.
2022-05-08 19:30:55 +02:00
Robert Schulze
ee72bd832d
Enable clang-tidy bugprone-misplaced-widening-cast
Official docs:

  This check will warn when there is a cast of a calculation result to a
  bigger type. If the intention of the cast is to avoid loss of
  precision then the cast is misplaced, and there can be loss of
  precision. Otherwise the cast is ineffective.
2022-05-08 19:20:44 +02:00
Robert Schulze
a5ee67885d
Enable clang-tidy bugprone-forwarding-reference-overload
Official docs:

  The check looks for perfect forwarding constructors that can hide copy
  or move constructors. If a non const lvalue reference is passed to the
  constructor, the forwarding reference parameter will be a better match
  than the const reference parameter of the copy constructor, so the
  perfect forwarding constructor will be called, which can be confusing.
2022-05-08 19:20:14 +02:00
Robert Schulze
543fd7e1e0
Enable clang-tidy bugprone-dynamic-static-initializers
Official docs:

  Finds instances of static variables that are dynamically initialized in
  header files. This can pose problems in certain multithreaded contexts.
2022-05-08 19:19:36 +02:00
Robert Schulze
20513df733
Enable clang-tidy readability-qualified-auto
Official docs:

Adds pointer qualifications to auto-typed variables that are deduced to
pointers. This makes it obvious if a auto typed variable is a pointer.
This check will transform auto to auto * when the type is deduced to be
a pointer.
2022-05-08 19:17:15 +02:00
Robert Schulze
627cc1ccfa
Enable clang-tidy misc-static-assert
Official docs:

  Replaces assert() with static_assert() if the condition is evaluable
  at compile time. The condition of static_assert() is evaluated at
  compile time which is safer and more efficient.
2022-05-08 19:16:41 +02:00
Robert Schulze
7d3913f350
Enable clang-tidy bugprone-assert-side-effect
Official docs:

  Finds assert() with side effect. The condition of assert() is
  evaluated only in debug builds so a condition with side effect can
  cause different behavior in debug / release builds.
2022-05-08 19:15:55 +02:00
Robert Schulze
9c51657821
Enable clang-tidy modernize-replace-auto-ptr
Official docs:

  This check replaces the uses of the deprecated class std::auto_ptr by
  std::unique_ptr (introduced in C++11). The transfer of ownership, done
  by the copy-constructor and the assignment operator, is changed to
  match std::unique_ptr usage by using explicit calls to std::move().
2022-05-08 19:15:21 +02:00
Robert Schulze
7036bc4e99
Enable clang-tidy modernize-unary-static-assert
Official docs:

  The check diagnoses any static_assert declaration with an empty string
  literal and provides a fix-it to replace the declaration with a
  single-argument static_assert declaration.
2022-05-08 19:14:39 +02:00
Robert Schulze
7d1ac7fa7f
Enable clang-tidies clang-analyzer-core.DynamicTypePropagation and clang-analyzer-core.uninitialized.CapturedBlockVariable
Official docs:

  - Generate dynamic type information
  - Check for blocks that capture uninitialized values
2022-05-08 19:13:40 +02:00
Robert Schulze
f2b1748c48
Enable clang-tidy bugprone-suspicious-semicolon
Official docs:

  Finds most instances of stray semicolons that unexpectedly alter the
  meaning of the code.
2022-05-08 19:13:37 +02:00
Robert Schulze
61cbcbf073
Enable clang-tidy readability-misleading-indentation
Official docs:

  Correct indentation helps to understand code. Mismatch of the
  syntactical structure and the indentation of the code may hide serious
  problems.
2022-05-08 19:12:01 +02:00
Robert Schulze
3d3977bad3
Enable clang-tidy cert-err60-cpp
Official docs:

  This check flags all throw expressions where the exception object is
  not nothrow copy constructible.
2022-05-06 00:36:26 +02:00
Robert Schulze
8b2f715b72
Further fixup of Linux-specific failures 2022-05-05 12:44:08 +02:00
Robert Schulze
3a7588d109
Fixup clang-tidy 2022-05-05 10:48:02 +02:00
Robert Schulze
4fff7a3d93
Invert .clang-tidy
Instead of disabling all checks + specifying which are enabled
(whitelist), enable all checks + specify which checks are disabled
(blacklist). The same set of checks executes as before.

Motivation:

a) Given the goal to (generally) enable as many checks as possible, a
   blacklist produces a smaller and easier to maintain .clang-tidy file.

b) Many new checks introduced with LLVM 12/13/14 were forgotten to turn
   on. A blacklist makes sure that future compiler upgrades enable new
   checks by default.
2022-05-05 00:31:48 +02:00
Robert Schulze
b829c743cc
Removing performance-no-int-to-ptr for now 2022-05-03 21:22:13 +02:00