[PATCH] D39121: [clang-tidy] Misplaced Operator in Strlen in Alloc

Balogh, Ádám via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 30 08:39:48 PDT 2017


baloghadamsoftware added a comment.

In https://reviews.llvm.org/D39121#910715, @aaron.ballman wrote:

> The diagnostic tells the user that you surround the arg to strlen with parens to silence the diagnostic, but the fixit doesn't do that -- it moves the addition to the result. That's confusing behavior. However, if you add another fixit to surround the arg with parens (and leave in the existing one), then there are conflicting fixits (you don't want to apply them both) which would also be confusing.


Then, I think we should rephrase the diagnostic message again. I am confident that in at least 99.9% of the cases adding 1 to the argument is a mistake. So the primary suggestion should be to move the addition to the result instead. The suggestion to put the argument in extra parentheses should be secondary, maybe also put in parentheses.


https://reviews.llvm.org/D39121





More information about the cfe-commits mailing list