[PATCH] D12365: Make SideEffectFinder publicly available (nfc)

scott douglass via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 26 08:21:41 PDT 2015


scott-0 created this revision.
scott-0 added a subscriber: cfe-commits.

I'm going to use SideEffectFinder in my subsequent patch.

http://reviews.llvm.org/D12365

Files:
  include/clang/AST/SideEffectFinder.h
  lib/AST/Expr.cpp

Index: lib/AST/Expr.cpp
===================================================================
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -22,6 +22,7 @@
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/Mangle.h"
 #include "clang/AST/RecordLayout.h"
+#include "clang/AST/SideEffectFinder.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/CharInfo.h"
@@ -2892,28 +2893,6 @@
   return false;
 }
 
-namespace {
-  /// \brief Look for any side effects within a Stmt.
-  class SideEffectFinder : public ConstEvaluatedExprVisitor<SideEffectFinder> {
-    typedef ConstEvaluatedExprVisitor<SideEffectFinder> Inherited;
-    const bool IncludePossibleEffects;
-    bool HasSideEffects;
-
-  public:
-    explicit SideEffectFinder(const ASTContext &Context, bool IncludePossible)
-      : Inherited(Context),
-        IncludePossibleEffects(IncludePossible), HasSideEffects(false) { }
-
-    bool hasSideEffects() const { return HasSideEffects; }
-
-    void VisitExpr(const Expr *E) {
-      if (!HasSideEffects &&
-          E->HasSideEffects(Context, IncludePossibleEffects))
-        HasSideEffects = true;
-    }
-  };
-}
-
 bool Expr::HasSideEffects(const ASTContext &Ctx,
                           bool IncludePossibleEffects) const {
   // In circumstances where we care about definite side effects instead of
Index: include/clang/AST/SideEffectFinder.h
===================================================================
--- /dev/null
+++ include/clang/AST/SideEffectFinder.h
@@ -0,0 +1,41 @@
+//===--- SideEffectFinder.h - Visitor for finding side-effects --*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+//  This file defines the SideEffectFinder.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_AST_SIDEEFECTFINDER_H
+#define LLVM_CLANG_AST_SIDEEFECTFINDER_H
+
+#include "clang/AST/EvaluatedExprVisitor.h"
+
+namespace clang {
+/// \brief Look for any side effects within an Expr.
+class SideEffectFinder : public ConstEvaluatedExprVisitor<SideEffectFinder> {
+  typedef ConstEvaluatedExprVisitor<SideEffectFinder> Inherited;
+  const bool IncludePossibleEffects;
+  bool HasSideEffects;
+
+public:
+  explicit SideEffectFinder(const ASTContext &Context, bool IncludePossible)
+    : Inherited(Context),
+      IncludePossibleEffects(IncludePossible), HasSideEffects(false) { }
+
+  bool hasSideEffects() const { return HasSideEffects; }
+
+  void VisitExpr(const Expr *E) {
+    if (!HasSideEffects &&
+        E->HasSideEffects(Context, IncludePossibleEffects))
+      HasSideEffects = true;
+  }
+};
+}  // end namespace clang
+
+#endif


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12365.33205.patch
Type: text/x-patch
Size: 2894 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150826/041f845b/attachment.bin>


More information about the cfe-commits mailing list