steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added a subscriber: cfe-commits.

This has precedent in the StmtVisitor.  This change will make it
possible to clean up the comment handling in ASTDumper.


Repository:
  rC Clang

https://reviews.llvm.org/D55069

Files:
  include/clang/AST/CommentVisitor.h


Index: include/clang/AST/CommentVisitor.h
===================================================================
--- include/clang/AST/CommentVisitor.h
+++ include/clang/AST/CommentVisitor.h
@@ -19,14 +19,16 @@
 template <typename T> struct make_ptr { using type = T *; };
 template <typename T> struct make_const_ptr { using type = const T *; };
 
-template<template <typename> class Ptr, typename ImplClass, typename 
RetTy=void>
+template <template <typename> class Ptr, typename ImplClass,
+          typename RetTy = void, class... ParamTys>
 class CommentVisitorBase {
 public:
 #define PTR(CLASS) typename Ptr<CLASS>::type
 #define DISPATCH(NAME, CLASS)                                                  
\
-  return static_cast<ImplClass 
*>(this)->Visit##NAME(static_cast<PTR(CLASS)>(C))
+  return static_cast<ImplClass *>(this)->Visit##NAME(                          
\
+      static_cast<PTR(CLASS)>(C), std::forward<ParamTys>(P)...)
 
-  RetTy Visit(PTR(Comment) C) {
+  RetTy Visit(PTR(Comment) C, ParamTys... P) {
     if (!C)
       return RetTy();
 
@@ -45,24 +47,25 @@
   // on Visit* method for the superclass.
 #define ABSTRACT_COMMENT(COMMENT) COMMENT
 #define COMMENT(CLASS, PARENT)                                                 
\
-  RetTy Visit##CLASS(PTR(CLASS) C) { DISPATCH(PARENT, PARENT); }
+  RetTy Visit##CLASS(PTR(CLASS) C, ParamTys... P) { DISPATCH(PARENT, PARENT); }
 #include "clang/AST/CommentNodes.inc"
 #undef ABSTRACT_COMMENT
 #undef COMMENT
 
-  RetTy VisitComment(PTR(Comment) C) { return RetTy(); }
+  RetTy VisitComment(PTR(Comment) C, ParamTys... P) { return RetTy(); }
 
 #undef PTR
 #undef DISPATCH
 };
 
-template<typename ImplClass, typename RetTy=void>
-class CommentVisitor :
-    public CommentVisitorBase<make_ptr, ImplClass, RetTy> {};
+template <typename ImplClass, typename RetTy = void, class... ParamTys>
+class CommentVisitor
+    : public CommentVisitorBase<make_ptr, ImplClass, RetTy, ParamTys...> {};
 
-template<typename ImplClass, typename RetTy=void>
-class ConstCommentVisitor :
-    public CommentVisitorBase<make_const_ptr, ImplClass, RetTy> {};
+template <typename ImplClass, typename RetTy = void, class... ParamTys>
+class ConstCommentVisitor
+    : public CommentVisitorBase<make_const_ptr, ImplClass, RetTy, ParamTys...> 
{
+};
 
 } // namespace comments
 } // namespace clang


Index: include/clang/AST/CommentVisitor.h
===================================================================
--- include/clang/AST/CommentVisitor.h
+++ include/clang/AST/CommentVisitor.h
@@ -19,14 +19,16 @@
 template <typename T> struct make_ptr { using type = T *; };
 template <typename T> struct make_const_ptr { using type = const T *; };
 
-template<template <typename> class Ptr, typename ImplClass, typename RetTy=void>
+template <template <typename> class Ptr, typename ImplClass,
+          typename RetTy = void, class... ParamTys>
 class CommentVisitorBase {
 public:
 #define PTR(CLASS) typename Ptr<CLASS>::type
 #define DISPATCH(NAME, CLASS)                                                  \
-  return static_cast<ImplClass *>(this)->Visit##NAME(static_cast<PTR(CLASS)>(C))
+  return static_cast<ImplClass *>(this)->Visit##NAME(                          \
+      static_cast<PTR(CLASS)>(C), std::forward<ParamTys>(P)...)
 
-  RetTy Visit(PTR(Comment) C) {
+  RetTy Visit(PTR(Comment) C, ParamTys... P) {
     if (!C)
       return RetTy();
 
@@ -45,24 +47,25 @@
   // on Visit* method for the superclass.
 #define ABSTRACT_COMMENT(COMMENT) COMMENT
 #define COMMENT(CLASS, PARENT)                                                 \
-  RetTy Visit##CLASS(PTR(CLASS) C) { DISPATCH(PARENT, PARENT); }
+  RetTy Visit##CLASS(PTR(CLASS) C, ParamTys... P) { DISPATCH(PARENT, PARENT); }
 #include "clang/AST/CommentNodes.inc"
 #undef ABSTRACT_COMMENT
 #undef COMMENT
 
-  RetTy VisitComment(PTR(Comment) C) { return RetTy(); }
+  RetTy VisitComment(PTR(Comment) C, ParamTys... P) { return RetTy(); }
 
 #undef PTR
 #undef DISPATCH
 };
 
-template<typename ImplClass, typename RetTy=void>
-class CommentVisitor :
-    public CommentVisitorBase<make_ptr, ImplClass, RetTy> {};
+template <typename ImplClass, typename RetTy = void, class... ParamTys>
+class CommentVisitor
+    : public CommentVisitorBase<make_ptr, ImplClass, RetTy, ParamTys...> {};
 
-template<typename ImplClass, typename RetTy=void>
-class ConstCommentVisitor :
-    public CommentVisitorBase<make_const_ptr, ImplClass, RetTy> {};
+template <typename ImplClass, typename RetTy = void, class... ParamTys>
+class ConstCommentVisitor
+    : public CommentVisitorBase<make_const_ptr, ImplClass, RetTy, ParamTys...> {
+};
 
 } // namespace comments
 } // namespace clang
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to