[PATCH] D55069: Extend the CommentVisitor with parameter types

Stephen Kelly via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 29 14:34:46 PST 2018


steveire updated this revision to Diff 175967.
steveire added a comment.

Remove &&


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55069/new/

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))
+#define DISPATCH(NAME, CLASS)                                                  \
+  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();
 
@@ -44,25 +46,26 @@
   // If the derived class does not implement a certain Visit* method, fall back
   // on Visit* method for the superclass.
 #define ABSTRACT_COMMENT(COMMENT) COMMENT
-#define COMMENT(CLASS, PARENT) \
-  RetTy visit ## CLASS(PTR(CLASS) C) { DISPATCH(PARENT, PARENT); }
+#define COMMENT(CLASS, 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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55069.175967.patch
Type: text/x-patch
Size: 2490 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181129/76a3d5fa/attachment-0001.bin>


More information about the cfe-commits mailing list