[PATCH] Enhance clang-tidy readability-simplify-boolean-expr to handle 'if (e) return true; return false; ' and improve replacement expressions.
Richard
legalize at xmission.com
Fri Jun 5 22:37:59 PDT 2015
================
Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.cpp:139
@@ +138,3 @@
+StringRef asBool(StringRef text, bool NeedsStaticCast) {
+ if (NeedsStaticCast) {
+ return ("static_cast<bool>(" + text + ")").str();
----------------
alexfh wrote:
> In clang-tidy code (and in LLVM in general) it's more common to omit braces around single-line `if` bodies. One exception is when any branch of the if-else chain uses braces, we put them to all branches.
>
> Please fix here and in other places in this CL.
[[ https://www.securecoding.cert.org/confluence/display/c/EXP19-C.+Use+braces+for+the+body+of+an+if,+for,+or+while+statement | CERT coding standards require braces ]] around all control structures, so I've routinely adopted that habit. Considering that existing security vulnerabilities were traced to the omission of the braces, I don't simply consider it a matter of style.
However, I'm not in charge of llvm code and if it is **really** that important, I can change it.
Sometimes these code reviews are simply exhausting because of all this little fiddling about with formatting instead of function.
http://reviews.llvm.org/D9810
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the cfe-commits
mailing list