/** Finds functions which are candidates for inlining. Currently this means
functions which have no flow control statements, no more than one return
-statement, and are only called once. */
+statement, and are either builtins or only called once. */
class InlineableFunctionLocator: private TraversingVisitor
{
private:
virtual void visit(Iteration &);
};
+class UnreachableCodeRemover: private TraversingVisitor
+{
+private:
+ bool reachable;
+ std::set<Node *> unreachable_nodes;
+
+public:
+ UnreachableCodeRemover();
+
+ virtual bool apply(Stage &);
+
+private:
+ virtual void visit(Block &);
+ virtual void visit(FunctionDeclaration &);
+ virtual void visit(Conditional &);
+ virtual void visit(Iteration &);
+ virtual void visit(Return &) { reachable = false; }
+ virtual void visit(Jump &) { reachable = false; }
+};
+
/** Removes types which are not used anywhere. */
class UnusedTypeRemover: private TraversingVisitor
{