Page MenuHome

Clang-Tidy: keep bugprone-integer-division disabled
ClosedPublic

Authored by Sybren A. Stüvel (sybren) on Sep 4 2020, 2:56 PM.

Details

Summary

Add a header to .clang-tidy that explains why certain rules are disabled.

If we indeed decide to keep the bugprone-integer-division Clang-Tidy rule
disabled, this means there are two categories of disabled rules:

  • Not yet enabled, because no developer has spent time on it, and
  • intentionally disabled.

Here are some example diffs to illustrate those annoying fixes:

+  const int half_unit_y = UI_UNIT_Y / 2;
   const int drag_threshold = min_ii(
       WM_event_drag_threshold(event),
-      (int)((UI_UNIT_Y / 2) * ui_block_to_window_scale(data->region, but->block)));
+      (int)(half_unit_y * ui_block_to_window_scale(data->region, but->block)));
-          const float margin_y = DRAG_MULTINUM_THRESHOLD_DRAG_Y / sqrtf(block->aspect);
+          const float margin_y = (float)(DRAG_MULTINUM_THRESHOLD_DRAG_Y) / sqrtf(block->aspect);
-  const float xco = x + w / 2 + 0.5f;
-  const float yco = y + h / 2 + 0.5f;
+  const float xco = x + (int)(w / 2) + 0.5f;
+  const float yco = y + (int)(h / 2) + 0.5f;

Diff Detail

Repository
rB Blender
Branch
temp-T78535-clang-tidy-integer-division (branched from master)
Build Status
Buildable 9984
Build 9984: arc lint + arc unit

Event Timeline

Sybren A. Stüvel (sybren) requested review of this revision.Sep 4 2020, 2:56 PM

I suggest to have common comment on the top saying that the warnings are disabled because they are too pedantic and not worth fixing. And comment that some of them will be enabled as part of the Clang-Tidy task (with the link to T<number>).

.clang-tidy
3–4

This isn't really true. We are at the point where almost all warnings we want to be enabled are enabled. The rest of the warnings are too pedantic, happens everywhere, and do not add value for addressing.

I'm also not sure it worth mentioning per-warning reasoning at this point. Could be useful if we want to support them in the future, or want to enable them in some areas or things like that.

  • Clarified comment
  • Moved bugprone-integer-division rule back to where it was
This revision was not accepted when it landed; it landed in state Needs Review.Sep 4 2020, 4:30 PM
This revision was automatically updated to reflect the committed changes.