[PATCH] some StmtExprs do not have side-effects

Richard Smith richard at metafoo.co.uk
Thu Jun 4 14:26:26 PDT 2015


================
Comment at: lib/AST/Expr.cpp:2886-2887
@@ +2885,4 @@
+  /// \brief Look for any side effects within a Stmt.
+  class SideEffectFinder : public ConstEvaluatedExprVisitor<SideEffectFinder>
+  {
+    typedef ConstEvaluatedExprVisitor<SideEffectFinder> Inherited;
----------------
`{` goes on previous line.

================
Comment at: lib/AST/Expr.cpp:2901
@@ +2900,3 @@
+      if (!E->HasSideEffects(Context, IncludePossibleEffects)) {
+        Inherited::VisitStmt(E);
+        return;
----------------
Remove this call: you've already completely checked `E` and all of its subexpressions for side-effects. Calling into the base class here will result in a (worst-case) exponential-time search as both `VisitStmt` and `HasSideEffects` will recurse into subexpressions at every level.

http://reviews.llvm.org/D10211

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list