This PR enables more clang-tidy bugprone checks and fixes issues discovered by enabling them. Here are the checks now enabled: bugprone-argument-comment bugprone-assert-side-effect bugprone-assignment-in-if-condition bugprone-bad-signal-to-kill-thread bugprone-bool-pointer-implicit-conversion bugprone-copy-constructor-init bugprone-dangling-handle bugprone-dynamic-static-initializers bugprone-fold-init-type bugprone-forward-declaration-namespace bugprone-forwarding-reference-overload bugprone-inaccurate-erase bugprone-incorrect-roundings bugprone-infinite-loop bugprone-macro-repeated-side-effects bugprone-misplaced-operator-in-strlen-in-alloc bugprone-misplaced-pointer-arithmetic-in-alloc bugprone-move-forwarding-reference bugprone-multiple-statement-macro bugprone-no-escape bugprone-not-null-terminated-result bugprone-parent-virtual-call bugprone-posix-return bugprone-redundant-branch-condition bugprone-shared-ptr-array-mismatch bugprone-signal-handler 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-stringview-nullptr bugprone-suspicious-enum-usage bugprone-suspicious-include bugprone-suspicious-memory-comparison bugprone-suspicious-memset-usage bugprone-suspicious-missing-comma bugprone-suspicious-semicolon bugprone-suspicious-string-compare bugprone-swapped-arguments bugprone-terminating-continue bugprone-throw-keyword-missing bugprone-too-small-loop-variable bugprone-unchecked-optional-access bugprone-undefined-memory-manipulation bugprone-undelegated-constructor bugprone-unhandled-exception-at-new bugprone-unhandled-self-assignment bugprone-unused-raii bugprone-virtual-near-miss
Adding these checks makes the code more secure and helps to catch bugs and errors early. It also avoids reviewers to manually check for these issues during reviews.
I think we should enable the remaining bugprone-* checks but they require much more refactoring so it may be better to enable them in follow-ups PRs.