I'd like to propose that we enable the bugprone-assert-side-effect clang-tidy lint. The evaluation doc I have is here
I think the key points for discussion are:
- Do we want this on at all?
- If enabled, should we also have it treat all function calls as non-const?
Based on the previous discussion, my thoughts are:
- Despite only 1 of the 11 occurrences of this (with CheckFunctions disabled) being true-positives, I expect that most accidental side-effects are discovered in postsubmit and fixed. The primary benefit of this lint will be surfacing issues earlier.
- Enabling the non-const function call detection has us flag 15K DCHECKs rather than 11. I estimate the flaggable number of DCHECKs in Chrome to be around 90K (see the doc for why :) ). We can probably chip away at this by adding ignored function regexes, but these also reduce the chances that we'll catch a real issue, since these regexes will have to be quite generic (e.g., does the function name contain "is"?)
Given the very low false-positive rate (10/90K DCHECKs across Chromium), and given that flagging this kind of issue pre-commit is much better than only discovering it in postsubmit, I'm in favor of adding this lint.
Feedback is appreciated!