From: Chris Lattner Date: Tue, 21 Aug 2007 04:06:29 +0000 (+0000) Subject: Now that the visitor is defined in one place, it is nice and easy to allow clients X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e12b4301820bbae6b67a88fa98617dc571331555;p=clang Now that the visitor is defined in one place, it is nice and easy to allow clients to have visitors that return non-void. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41212 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/StmtVisitor.h b/include/clang/AST/StmtVisitor.h index 346f331050..43f8637861 100644 --- a/include/clang/AST/StmtVisitor.h +++ b/include/clang/AST/StmtVisitor.h @@ -20,10 +20,10 @@ namespace clang { /// StmtVisitor - This class implements a simple visitor for Stmt subclasses. /// Since Expr derives from Stmt, this also includes support for visiting Exprs. -template +template class StmtVisitor { public: - void Visit(Stmt *S) { + RetTy Visit(Stmt *S) { // Top switch stmt: dispatch to VisitFooStmt for each FooStmt. switch (S->getStmtClass()) { default: assert(0 && "Unknown stmt kind!"); @@ -38,13 +38,13 @@ public: // If the implementation chooses not to implement a certain visit method, fall // back on VisitExpr or whatever else is the superclass. #define STMT(N, CLASS, PARENT) \ - void Visit ## CLASS(CLASS *Node) { \ + RetTy Visit ## CLASS(CLASS *Node) { \ return static_cast(this)->Visit ## PARENT(Node); \ } #include "clang/AST/StmtNodes.def" // Base case, ignore it. :) - void VisitStmt(Stmt *Node) {} + RetTy VisitStmt(Stmt *Node) { return RetTy(); } }; }