Hey friends,
I've had cycles to evaluate a few more clang-tidy checks for inclusion in Chromium. Clang-tidy has a lot of checks spelled bugprone-*, so this is step one in a journey. ;)
This round, I looked at the following two checks:
-
bugprone-unused-raii -- complains about patterns that look like unused RAII objects (e.g. `std::lock_guard(this->lock); use(this->protected_by_lock);`.) Outside of unittests, this flagged 15 places in Chromium; 12 are almost definitely bugs, and it's unclear if the remaining three are intended or not.
-
bugprone-string-integer-assignment -- complains about the use of `std::string::operator=(int)` and similar. Of the ~17 unique pieces of code (there was much near-copy-paste in e.g., protobufs), it caught 6 things which are very likely to be bugs. The rest was in the shape `base::RandInt('a', 'z');`, `'a' + some_var`, ...
I think the first one's a pretty clear win. The false-positive rate of the second in existing code is a bit high for my liking, but I'd imagine that a broken string-integer-assignment would generally be quite visible, so it's likely harder for that to slip through unnoticed for a long period of time than something like an unused raii container.
Thoughts?
George