Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for many clang-tidy bugprone-* checks #4464

Merged
merged 18 commits into from Dec 27, 2022
Merged

Conversation

thehans
Copy link
Member

@thehans thehans commented Dec 26, 2022

Some counts of unique lines which failed bugprone checks before:

    336 [bugprone-narrowing-conversions]
     78 [bugprone-easily-swappable-parameters]
     19 [bugprone-branch-clone]
     19 [bugprone-reserved-identifier]
     14 [bugprone-implicit-widening-of-multiplication-result]
      9 [bugprone-macro-parentheses]
      7 [bugprone-use-after-move]
      6 [bugprone-virtual-near-miss]
      5 [bugprone-exception-escape]
      4 [bugprone-suspicious-enum-usage]
      2 [bugprone-copy-constructor-init]
      1 [bugprone-parent-virtual-call]
      1 [bugprone-misplaced-widening-cast]
      1 [bugprone-integer-division]
      1 [bugprone-forwarding-reference-overload]

after:

    330 [bugprone-narrowing-conversions]
     78 [bugprone-easily-swappable-parameters]
      5 [bugprone-exception-escape]

The remaining checks are disabled in the top-level .clang-tidy file:

  • narrowing-conversions were just too many to deal with
  • easily-swappable-parameters This is triggered any time two or more parameters of the same type are adjacent in a function signature, for example anything of the form: foo(T x,T y,T z). I don't see any sensible way to avoid such occurrences.
  • exception-escape these should probably be looked into, but I'm not sure how to best handle them. The offending lines are pasted below.
src/core/Context.h:27:3: warning: an exception may be thrown in function '~ContextHandle<T>' which should not throw exceptions [bugprone-exception-escape]
src/core/Context.h:40:18: warning: an exception may be thrown in function 'operator=' which should not throw exceptions [bugprone-exception-escape]
src/core/ContextMemoryManager.cc:350:23: warning: an exception may be thrown in function '~ContextMemoryManager' which should not throw exceptions [bugprone-exception-escape]
src/core/ContextMemoryManager.h:36:3: warning: an exception may be thrown in function '~ContextMemoryManager' which should not throw exceptions [bugprone-exception-escape]
src/openscad.cc:886:5: warning: an exception may be thrown in function 'main' which should not throw exceptions [bugprone-exception-escape]

Rename `RangeType::type_t` enum to `iter_state` for clarity.
Qt's Keys and Modifier enums are not same types, but are necessarily bitwise OR'd for setting shortcuts.
libsvg derived class member function names are similar to parent class' `get_x()` and `get_y()`, but not by mistake.
I noticed that base Geometry class copy constructor would handle copying `convexity`, and thought this might be related to issue openscad#4115
This did not actually fix the issue, but... (see next commit).
Pretty sure this call to grandparent class' member function is intended.
@thehans thehans merged commit d5bae78 into openscad:master Dec 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants