Commit Graph

63 Commits

Author SHA1 Message Date
Brecht Van Lommel
af0c561b15 Clang Tidy: Silence a few more warnings
* bugprone-signed-char-misuse: Not relevant because of -funsigned-char.
* bugprone-switch-missing-default-case: Not necessarily better to add default.
* bugprone-multi-level-implicit-pointer-conversion: Common pattern.
* bugprone-assignment-in-if-condition: Common pattern, not against guidelines.

Pull Request: https://projects.blender.org/blender/blender/pulls/133734
2025-01-31 17:03:16 +01:00
Brecht Van Lommel
a3a104f97a Clang Tidy: Ignore some newer readability warnings
These patterns are very common throughout the Blender codebase, which makes
the clang-tidy output and using clangd in an IDE quite noisy. They were introduced
in LLVM version 18 and 19.

* readability-math-missing-parentheses
* readability-avoid-nested-conditional-operator
* readability-enum-initial-value
* readability-avoid-unconditional-preprocessor-if

Pull Request: https://projects.blender.org/blender/blender/pulls/132462
2025-01-02 16:22:44 +01:00
Campbell Barton
952e1d46d1 Cleanup: match declaration names, avoid shadowing & clear trailing space 2024-10-03 12:12:08 +10:00
Jonas Holzman
01e96b3422 macOS: Enable clang-tidy Objective-C checks
This commit improves macOS Objective-C code linting and developer
experience by enabling clang-tidy Objective-C checks. The full list
of objc-* checks can be found here:

https://clang.llvm.org/extra/clang-tidy/checks/list.html

As these checks are pretty simple and non-invasive, they have all
been kept enabled. Currently, enabling this series of checks does
not introduce any new clang-tidy warnings in the current Objective-C
code.

Pull Request: https://projects.blender.org/blender/blender/pulls/128334
2024-10-01 14:13:40 +02:00
Sebastian Parborg
763b8f1423 Clang-tidy: Ignore variable name length and .c/.cc include warnings
After some internal discussion it was decided that we should ignore name
variable length tidy warnings. Otherwise we would have warnings for
every variable that is under three characters long.

Additionally we will also ignore any warnings when including non header
files as the Unity library in our build system uses this excessively
2022-05-06 15:26:54 +02:00
Sebastian Parborg
dd2df5ceb0 Fix: Comments in clang-tidy checks list is not allowed
Clang-tidy will not parse any options after the comment.
2022-05-06 15:26:54 +02:00
Jacques Lucke
9159295c3c Clang Tidy: ignore some passes that changed or were added in version 13
I get hundreds of clang-tidy errors without ignoring those passes right now.
To not forget about the passes, I added them to T78535.
2021-11-23 19:45:05 +01:00
Jacques Lucke
19dfb6ea1f Cleanup: enable modernize-use-equals-default check
This removes a lot of unnecessary code that is generated by
the compiler automatically.

In very few cases, a defaulted destructor in a .cc file is
still necessary, because of forward declarations in the header.

I removed some defaulted virtual destructors, because they are not
necessary, when the parent class has a virtual destructor already.

Defaulted constructors are only necessary when there is another
constructor, but the class should still be default constructible.

Differential Revision: https://developer.blender.org/D10911
2021-04-08 11:07:27 +02:00
Jacques Lucke
f56fddbf9a Clang Tidy: disable WarningsAsErrors
This makes regular development more pleasant, because one does not have
to fix unrelated clang tidy mistakes when one is in the middle of something.
Before this change, I would usually turn clang-tidy off entirely, but then
forget to turn it on again.

This change has been agreed on by Sergey as well.
2021-03-29 11:04:34 +02:00
Jacques Lucke
2e213003b8 Cleanup: add comment
See rBb9cd2f4531ca670c196b0b14b1359d0f375103c2 for more info.
2021-03-22 11:35:19 +01:00
Jacques Lucke
a506f87c90 Clang Tidy: disable modernize-raw-string-literal again
This check does not work when gtests are enabled yet.
See rBb9cd2f4531ca670c196b0b14b1359d0f375103c2 for more details.
2021-03-22 11:26:48 +01:00
Sergey Sharybin
b4dca4ea2c Cleanup: Use raw string literal
Resolves modernize-raw-string-literal Clang-Tidy warning

The way warning works is it suggests to use raw literal when
overhead of having escape characters is higher than the overhead
of having raw literal syntax (talking about code size overhead).
This means that the warning will not trigger for "foo\"bar".

Differential Revision: https://developer.blender.org/D10322
2021-02-05 16:43:23 +01:00
Sergey Sharybin
5ec4ba8080 Cleanup: Use lambda instead of function bind
More detailed explanation why it is a preferred way of coding
nowadays can be found at

https://clang.llvm.org/extra/clang-tidy/checks/modernize-avoid-bind.html

Resolves modernize-avoid-bind Clang-Tidy warning.

Differential Revision: https://developer.blender.org/D10320
2021-02-05 16:43:23 +01:00
Sergey Sharybin
56903024dc Cleanup: Use transparent functor
Resolves modernize-use-transparent-functors Clang-Tidy warning.

Differential Revision: https://developer.blender.org/D10323
2021-02-05 15:39:50 +01:00
Ankit Meel
7054d03701 Cleanup: Clang-tidy modernize-use-default-member-init
Using assignment syntax as we don't use `{}` initialization yet.

Reviewed By: sergey
Differential Revision: https://developer.blender.org/D9501
2021-02-05 19:09:36 +05:30
Sybren A. Stüvel
7f2d356a67 Cleanup: Clang-Tidy, modernize-use-using
Replace `typedef` with `using` in C++ code.

In the case of `typedef struct SomeName { ... } SomeName;` I removed the
`typedef` altogether, as this is unnecessary in C++. Such cases have been
rewritten to `struct SomeName { ... };`

No functional changes.
2020-12-04 12:46:43 +01:00
Sybren A. Stüvel
10a8286a26 Cleanup: Clang-tidy, actually enable the modernize-use-override rule
Forgot this in rB168909d9741.

No functional changes.
2020-12-04 12:31:49 +01:00
Sybren A. Stüvel
958df2ed1b Cleanup: Clang-Tidy, modernize-deprecated-headers
No functional changes.
2020-12-04 11:28:09 +01:00
Ankit Meel
88de58fd1a Clang-tidy, fix bugprone-exception-escape.
Remove redundant call to `ofstream::close()` from `~PSStrokeRenderer`
and `~TextStrokeRenderer`. ofstream will be destructed automatically.

- For `~Depsgraph`, `std::function`'s constructor can throw.
- Passing throwing statements in the lambda will not be detected by
  clang-tidy.
Fix these issues by using lambda as function argument.

Reviewed By: sergey, sybren
Differential Revision: https://developer.blender.org/D9497
2020-11-17 17:33:25 +05:30
Ankit Meel
4525049aa0 Cleanup: Clang-tidy, modernize-concat-nested-namespaces 2020-11-07 18:48:13 +05:30
Sybren A. Stüvel
16732def37 Cleanup: Clang-Tidy modernize-use-nullptr
Replace `NULL` with `nullptr` in C++ code.

No functional changes.
2020-11-06 18:08:25 +01:00
Sergey Sharybin
3cb4c51308 Cleanup: Clang-Tidy, modernize-make-unique 2020-11-06 16:47:16 +01:00
Sergey Sharybin
af35ada2f3 Cleanup: Clang-Tidy, modernize-use-bool-literals 2020-11-06 14:32:51 +01:00
Sergey Sharybin
8d5073345d Cleanup: Clang-Tidy, modernize-use-emplace 2020-11-06 14:06:52 +01:00
Sergey Sharybin
a331d5c992 Cleanup: Clang-Tidy, modernize-redundant-void-arg 2020-11-06 13:40:46 +01:00
Sergey Sharybin
3b77c670f0 Clang Tidy: Expand modernize category
Gives an idea of which warnings are affecting Blender code base.
2020-11-06 12:16:02 +01:00
Sergey Sharybin
190170d4cc Cleanup: Clang-Tidy, readability-redundant-member-init 2020-11-06 11:54:53 +01:00
Ankit Meel
afd13710b8 Cleanup: Clang-tidy readability-named-parameter
No functional change.
2020-10-21 13:21:00 +05:30
Ankit Meel
7ac6f4d26c Cleanup: Clang-tidy readability-redundant-string-init
No functional change.
2020-10-21 13:15:17 +05:30
Ankit Meel
ee90effd3a Clang-tidy: disable new warnings.
Until it is decided whether to work on, or ignore these
warning, disable them. See T78535 

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D9281
2020-10-21 12:58:39 +05:30
Sebastian Parborg
2115232a16 Cleanup: Clang-Tidy readability-inconsistent-declaration-parameter-name fix
No functional changes
2020-09-04 21:04:16 +02:00
Sybren A. Stüvel
ce67a9d39f Cleanup: Clang-Tidy bugprone-copy-constructor-init fix
No expected functional changes.
2020-09-04 17:17:57 +02:00
Sybren A. Stüvel
3215651f47 Cleanup: Clang-Tidy, describe current status of rules
No functional changes.
2020-09-04 16:29:18 +02:00
Sybren A. Stüvel
fb5e2f5610 Cleanup: Clang-Tidy bugprone-incorrect-roundings fixes
Should cause no noticeable difference.
2020-09-04 16:23:08 +02:00
Sybren A. Stüvel
570811f0ef Cleanup: Enable Clang-Tidy readability-qualified-auto rule
No functional changes. No changes except enabling the rule, even.
2020-09-04 13:39:32 +02:00
Sybren A. Stüvel
e72a520a4c Cleanup: Clang-Tidy readability-redundant-declaration fix
No functional changes.
2020-09-04 13:31:10 +02:00
Sybren A. Stüvel
cc2b114a21 Cleanup: Clang-Tidy readability-static-accessed-through-instance fixes
No functional changes.
2020-09-04 12:37:56 +02:00
Sybren A. Stüvel
8057ab10db Cleanup: Clang-Tidy readability-const-return-type fixes
No functional changes.
2020-09-04 12:04:47 +02:00
Sybren A. Stüvel
371ddda4d0 Cleanup: Clang-Tidy readability-redundant-preprocessor fixes
Remove redundantly nested `#if` and `#ifdef` statements.

One nested `#if 0` block was left untouched, as it's in particle code
that's no longer maintained. Furthermore, that block also has some
explanation as to the differences between the enabled & disabled parts.

One nested `#if 0` construct was completely removed, leaving only the
actually used bit of code. There was no explanation as to the usefulness
of the disabled code, and it hasn't been touched in years.

No functional changes.
2020-09-04 11:26:26 +02:00
Sybren A. Stüvel
ad6e63cb96 Cleanup: enable Clang-Tidy bugprone-parent-virtual-call rule
I added a single `NOLINT` exception with explanation.

No functional changes.
2020-08-07 17:59:26 +02:00
Sybren A. Stüvel
60b42ef117 Cleanup: enabled Clang-Tidy bugprone-suspicious-missing-comma rule
No functional changes because no code changed.
2020-08-07 17:46:32 +02:00
Sybren A. Stüvel
ca85da075b Cleanup: enabled Clang-Tidy bugprone-not-null-terminated-result rule
No functional changes because no code changed.
2020-08-07 17:38:45 +02:00
Sybren A. Stüvel
a9c91ce331 Cleanup: fixed Clang-Tidy bugprone-suspicious-string-compare warnings
No functional changes.
2020-08-07 17:16:49 +02:00
Sybren A. Stüvel
4c2ce816aa Cleanup: enabled Clang-Tidy rule bugprone-infinite-loop
Enabling it and doing a full rebuild didn't cause any warnings, so nothing
else to do here.

No functional changes.
2020-08-07 16:46:26 +02:00
Sybren A. Stüvel
6414da0381 Cleanup: enable and silence Clang-Tidy readability-function-size
Enable Clang-Tidy's `readability-function-size` rule and add a few
`NOLINT` markers to explicitly silence warnings for three functions.
These functions are huge and would IMO benefit from splitting up, but
are hard to without intimate knowledge of the code.

At least by enabling the rule, we can start tweaking the values and
refactoring other functions that bubble up as being too long/complex.

No functional changes.
2020-08-07 16:23:17 +02:00
Sybren A. Stüvel
c04088fed1 Cleanup: Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule. This should be the final commit of the series of commits that
addresses this particular rule.

No functional changes.
2020-08-07 13:38:07 +02:00
Sergey Sharybin
cfc6f9eb18 Clang-Tidy: Address readability-redundant-string-init 2020-08-07 12:18:15 +02:00
Jacques Lucke
efc6f6e1ae Clang-Tidy: ignore some newer checks
Those checks have been added to clang tidy within the last year.
They fail when I use a clang tidy version I built from source.

Reviewers: sergey

Differential Revision: https://developer.blender.org/D8302
2020-07-15 14:24:24 +02:00
Jacques Lucke
725973485a Clang Tidy: enable readability-non-const-parameter warning
Clang Tidy reported a couple of false positives. I disabled
those `NOLINTNEXTLINE`.

Differential Revision: https://developer.blender.org/D8199
2020-07-13 11:27:09 +02:00
Sebastian Parborg
d7dbf90a02 Clang-tidy: Enable braces-around-statements warning 2020-07-03 21:23:33 +02:00