Diff Detail
Event Timeline
This strikes me as something the compiler should diagnose instead of a clang-tidy check. Incrementing a bool has been deprecated for some time, but it is outright removed in C++17, so I think giving users a migration path as part of the compiler would be far more beneficial. What do you think?
Besides comments, looks good to me. But before posting make sure that clang-diagnostics doesn't already have fixits.
clang-tidy/modernize/IncrementBoolCheck.cpp | ||
---|---|---|
51 | doesn't isInTemplateInstantiation fix it? | |
clang-tidy/modernize/ModernizeTidyModule.cpp | ||
38 | run git-clang-format on your patch, because I see that perhaps this one and other files coud be clang-formatted | |
docs/clang-tidy/checks/modernize-increment-bool.rst | ||
50–55 | put this one under the if statment and remove comments liek this: if (!first) second = first++; // is equivalent to if (!first) { second = false; first = true; } |
What clang diagnostic flags this issue? I'd rather make sure it provides good fixits than as a clang-tidy check that does almost the same. Clang-tidy can be configured to run Clang diagnostics and it will happily apply fixes if asked to.
-Wdeprecated-increment-bool does it. But what I see from SemaExpr.cpp in CheckIncrementDecrementOperand, it doesn't have any fixits.
I would still strongly prefer to see this fixed in CheckIncrementDecrementOperand instead of creating an entire clang-tidy check for it.
-Wdeprecated-increment-bool does it. But what I see from SemaExpr.cpp in CheckIncrementDecrementOperand, it doesn't have any fixits.
If an automated fix for this issue makes sense at all, it should be implemented in the Clang's diagnostic. BTW, have you seen this pattern in the real code? I haven't. Maybe it's so rare that implementing a fix-it suggestion for it just isn't worth the effort?
doesn't isInTemplateInstantiation fix it?