[cfe-commits] r41212 - /cfe/trunk/include/clang/AST/StmtVisitor.h
Chris Lattner
sabre at nondot.org
Mon Aug 20 21:06:29 PDT 2007
Author: lattner
Date: Mon Aug 20 23:06:29 2007
New Revision: 41212
URL: http://llvm.org/viewvc/llvm-project?rev=41212&view=rev
Log:
Now that the visitor is defined in one place, it is nice and easy to allow clients
to have visitors that return non-void.
Modified:
cfe/trunk/include/clang/AST/StmtVisitor.h
Modified: cfe/trunk/include/clang/AST/StmtVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtVisitor.h?rev=41212&r1=41211&r2=41212&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/StmtVisitor.h (original)
+++ cfe/trunk/include/clang/AST/StmtVisitor.h Mon Aug 20 23:06:29 2007
@@ -20,10 +20,10 @@
/// StmtVisitor - This class implements a simple visitor for Stmt subclasses.
/// Since Expr derives from Stmt, this also includes support for visiting Exprs.
-template<typename ImplClass>
+template<typename ImplClass, typename RetTy=void>
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 @@
// 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<ImplClass*>(this)->Visit ## PARENT(Node); \
}
#include "clang/AST/StmtNodes.def"
// Base case, ignore it. :)
- void VisitStmt(Stmt *Node) {}
+ RetTy VisitStmt(Stmt *Node) { return RetTy(); }
};
}
More information about the cfe-commits
mailing list