[PATCH] Enhance clang-tidy readability-simplify-boolean-expr to handle 'if (e) return true; return false; '
Richard
legalize at xmission.com
Sat May 16 22:13:11 PDT 2015
================
Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.cpp:130-145
@@ -121,2 +129,18 @@
+
+bool isFollowedBy(const CompoundStmt *Compound, const Stmt *Before,
+ const Stmt *After) {
+ if (Compound->size() < 2) {
+ return false;
+ }
+
+ CompoundStmt::const_body_iterator BeforeIt = Compound->body_begin();
+ CompoundStmt::const_body_iterator AfterIt = Compound->body_begin();
+ for (++AfterIt; AfterIt != Compound->body_end(); ++BeforeIt, ++AfterIt) {
+ if (*BeforeIt == Before && *AfterIt == After) {
+ return true;
+ }
+ }
+
+ return false;
}
----------------
I think this would make a good matcher, but I am unsure how to best express it using the matcher infrastructure. I could find no way in the existing matcher lexicon to say "match compound statements where this statement follows that statement"
http://reviews.llvm.org/D9810
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the cfe-commits
mailing list