Commit Graph

44 Commits

Author SHA1 Message Date
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
Robert Schulze
0a4eccb73e
Activated a bunch of LLVM 12/13/14 clang-tidy warnings
Omitted new checks which produce too many matches or which are
controversial (e.g. readability-identifier-length).

New checks:

- misc-misleading-bidirectional + misc-misleading-identifier

  Detects potential attack as described in the Trojan Source attack

- modernize-macro-to-enum

  Replaces groups of adjacent macros with an unscoped anonymous enum

- modernize-shrink-to-fit

  Replace copy and swap tricks on shrinkable containers with the
  shrink_to_fit() method call

- modernize-use-transparent-functors

  Prefer transparent functors to non-transparent ones

- modernize-use-uncaught-exceptions

  This check will warn on calls to std::uncaught_exception and replace
  them with calls to std::uncaught_exceptions (uncaught_exception was
  deprecated with C++17)

- performance-no-int-to-ptr

  Diagnoses every integer to pointer cast

- readability-duplicate-include

  Looks for duplicate includes and removes them

- readability-redundant-preprocessor

  Finds potentially redundant preprocessor directives

- bugprone-lambda-function-name

  Checks for attempts to get the name of a function from within a lambda
  expression

- bugprone-redundant-branch-condition

  Finds condition variables in nested if statements that were also
  checked in the outer if statement and were not changed

- bugprone-shared-ptr-array-mismatch

  Finds initializations of C++ shared pointers to non-array type that
  are initialized with an array

- bugprone-stringview-nullptr

  Checks for various ways that the const CharT* constructor of
  std::basic_string_view can be passed a null argument and replaces them
  with the default constructor in most cases

- bugprone-suspicious-memory-comparison

  Finds potentially incorrect calls to memcmp() based on properties of
  the arguments
2022-05-03 09:22:11 +02:00
Maksim Kita
57444fc7d3
Merge pull request #36444 from rschu1ze/clang-tidy-fixes
Clang tidy fixes
2022-04-21 16:11:27 +02:00
Robert Schulze
118e94523c
Activate clang-tidy warning "readability-container-contains"
This check suggests replacing <Container>.count() by
<Container>.contains() which is more speaking and in case of
multimaps/multisets also faster.
2022-04-18 23:53:11 +02:00
Robert Schulze
fd094185e6
Sort .clang-tidy
- not having everyone append new checks at the end means fewer merge
  conflicts

- also removed check "misc-unconventional-assign-operator" which was
  duplicated
2022-04-18 09:23:05 +02:00
Alexey Milovidov
e452949334
Merge pull request #35919 from DevTeamBK/clang-tidy-issues
Clang tidy issues
2022-04-05 19:31:09 +03:00
larryluogit
808d9afd0f
Fix optin.cplusplus.UninitializedObject issue (#35626)
* Fix optin.cplusplus.UninitializedObject issue

* Enable optin.cplusplus.UninitializedObject
2022-04-04 23:47:14 +03:00
Meena Renganathan
cf71b18472 Modified the code to fix the getenv() call issue idenitified in the clang-tidy 2022-04-04 07:23:31 -07:00
Alexey Milovidov
c9c747f615
Merge pull request #35868 from rschu1ze/remove-auto-ptr-from-clang-tidy
Drop modernize-replace-auto-ptr from .clang-tidy
2022-04-03 01:05:07 +03:00
Robert Schulze
192ff2fcf5
Drop modernize-replace-auto-ptr from .clang-tidy
- std::auto_ptr was removed from the C++17 standard
- ClickHouse is compiled with C++20
- thus, the clang-tidy check is obsolete by now
2022-04-02 21:37:32 +02:00
Raúl Marín
11a029c96b Attempt to workaround clang-tidy bug 2022-03-24 10:28:29 +01:00
Maksim Kita
b1a956c5f1 clang-tidy check performance-move-const-arg fix 2022-03-02 18:15:27 +00:00
Maksim Kita
1f5837359e clang-tidy check performance-noexcept-move-constructor fix 2022-03-02 18:15:27 +00:00
mreddy017
f893002b69 Fix vulnerable code related to std::move and noexcept
This commit fixes the vulnerable code related to std::move and noexcept identified by clangtidy tool.
2022-03-02 18:15:27 +00:00
HeenaBansal2009
a73135ce59 updated .clang-tidy as per Alexey's Suggestion 2022-02-07 11:27:57 -08:00
alesapin
d1e91a7860 Revert "Revert "Fix tidy""
This reverts commit 2e5e017d6d.
2021-09-06 12:16:52 +03:00
alesapin
2e5e017d6d Revert "Fix tidy"
This reverts commit 73ef1233ef.
2021-09-06 10:52:20 +03:00
alesapin
73ef1233ef Fix tidy
Fix tidy one more time
2021-09-06 10:22:21 +03:00
Alexey Milovidov
b0a5ce7743 Enable clang-tidy for programs and utils 2020-05-18 04:19:50 +03:00
alexey-milovidov
c7863e1ac6
Clang Tidy, part 7 (#9799)
* Attempt to enable identifier naming check

* Attempt to enable identifier naming check, continue

* Progress on identifier names

* Adopt identifier names check

* Fixed error

* Merge with master

* Fixed build

* Fixed build

* Fixed build

* Fixed build

* Fixed build

* Fixed error

* Fixed error

* Fixed error
2020-03-23 05:12:31 +03:00
Alexey Milovidov
8255547656 Added one more check 2020-03-20 21:53:35 +03:00
Alexey Milovidov
a5e3d4efb7 Added most of clang-static-analyzer checks 2020-03-20 21:53:35 +03:00
Alexey Milovidov
3f13464e3d clang-tidy, part 5 2020-03-20 21:53:35 +03:00
Alexey Milovidov
93466ce097 Added even more clang-tidy checks 2020-03-18 19:51:20 +03:00
Alexey Milovidov
c20853eecc Added most of bugprone checks 2020-03-18 19:51:20 +03:00
Alexey Milovidov
1bd7e594b0 clang-tidy, part 2 2020-03-18 03:57:00 +03:00
Alexey Milovidov
79c6bd5ae7 clang-tidy, part 4 2020-03-09 00:40:00 +03:00
Alexey Milovidov
de67bd78bd Added some clang-tidy checks 2020-03-08 23:17:49 +03:00