Hey all,
There was an effort a while back to enable useful clang-tidy checks in Chromium that seems to have been abandoned due to time/resources.
I'm interested in reviving this effort and propose restarting with the following two checks that seem particularly low-risk but could catch some useful bugs.
I'd like to turn on the following:
bugprone-suspicious-memset-usageThis diagnostic finds `memset` calls with mistakes in their arguments.
It triggers
exactly once in Chromium (in V8 in particular):
`memset(&heap_stats, 0xBADC0DE, sizeof(heap_stats));`
Here, the fill value of 0xBADC0DE is meant to be an easy-to-recognize value on the stack... however, memset converts its second argument to an unsigned char before using it, and this value is outside that range, so this value won't be found on the stack in practice.
Given that it only triggers once but seems to have found a real bug when it triggered, I think we should enable this.
bugprone-terminating-continue
This diagnostic detects do while loops with a condition that always evalutes to false that have a continue statement. These continues break the loop, which is either a bug or should be a `break` for legibility.
It triggers six times in Chromium and all these are in swiftshader. (
Example,
example.)
These sites all looked like they would in fact be better as `break`s / were not false positives so this seems useful.
The CL for these changes are
here & I welcome any feedback. Thanks!