From 7999991060b136db49eb9d6b34595383de56278c Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 13 May 2011 03:28:54 +0000 Subject: [PATCH] Add a ConstStmtVisitor class ConstStmtVisitor is a constness-preserving variant of StmtVisitor. ConstStmtVisitor and StmtVisitor share an implementation using a common base class, StmtVisitorBase, which uses a template template parameter to build pointer types. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131280 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/StmtVisitor.h | 57 ++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 16 deletions(-) diff --git a/include/clang/AST/StmtVisitor.h b/include/clang/AST/StmtVisitor.h index b8c141d7ef..29d2347546 100644 --- a/include/clang/AST/StmtVisitor.h +++ b/include/clang/AST/StmtVisitor.h @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// This file defines the StmtVisitor interface. +// This file defines the StmtVisitor and ConstStmtVisitor interfaces. // //===----------------------------------------------------------------------===// @@ -21,20 +21,26 @@ namespace clang { -#define DISPATCH(NAME, CLASS) \ - return static_cast(this)->Visit ## NAME(static_cast(S)) +template struct make_ptr { typedef T *type; }; +template struct make_const_ptr { typedef const T *type; }; -/// StmtVisitor - This class implements a simple visitor for Stmt subclasses. -/// Since Expr derives from Stmt, this also includes support for visiting Exprs. -template -class StmtVisitor { +/// StmtVisitorBase - This class implements a simple visitor for Stmt +/// subclasses. Since Expr derives from Stmt, this also includes support for +/// visiting Exprs. +template