Use clang-tidy to simplify boolean conditional return statements
Diff Detail
Event Timeline
I like the idea of all of these changes (this change list and the others), but just a suggestion -- it looks like when the branch of the original condition returns false, as was the case in the original code here, the internal expressions of the check are transformed via De Morgan's laws in the new code. IMO, this transformation sometimes makes things more complicated rather than less, where by "more complicated" I mean that the transformation produces an overall expression that is constructed from a considerably greater number of logical operations. For instance, here it changed a bunch of || expressions into a bunch of && expressions, with each operand individually prefixed with "!". The equivalent without having applied De Morgan's laws would just have left all of the || expressions as-is and added a single ! around the overall expression parenthesized. It would have also looked much more similar to the original code.
My general thought here is that it might make sense when performing this kind of transformation to first see if the translation via De Morgan's laws actually produces an overall expression that has fewer logical subexpressions, otherwise prefer the minimal transformation of a ! around a parenthesized expression.
lib/Edit/RewriteObjCFoundationAPI.cpp | ||
---|---|---|
634 | Looks like a chain (see prior review on your changes for more detail on what I mean by this) |
Looks like a chain (see prior review on your changes for more detail on what I mean by this)