From: Peter Collingbourne Date: Fri, 13 May 2011 03:28:54 +0000 (+0000) Subject: Add a ConstStmtVisitor class X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7999991060b136db49eb9d6b34595383de56278c;p=clang 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 --- 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