[PATCH] D55069: Extend the CommentVisitor with parameter types

2018-12-02 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL348100: Extend the CommentVisitor with parameter types 
(authored by steveire, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55069

Files:
  cfe/trunk/include/clang/AST/CommentVisitor.h


Index: cfe/trunk/include/clang/AST/CommentVisitor.h
===
--- cfe/trunk/include/clang/AST/CommentVisitor.h
+++ cfe/trunk/include/clang/AST/CommentVisitor.h
@@ -19,14 +19,16 @@
 template  struct make_ptr { using type = T *; };
 template  struct make_const_ptr { using type = const T *; };
 
-template class Ptr, typename ImplClass, typename 
RetTy=void>
+template  class Ptr, typename ImplClass,
+  typename RetTy = void, class... ParamTys>
 class CommentVisitorBase {
 public:
 #define PTR(CLASS) typename Ptr::type
-#define DISPATCH(NAME, CLASS) \
- return static_cast(this)->visit ## 
NAME(static_cast(C))
+#define DISPATCH(NAME, CLASS)  
\
+  return static_cast(this)->visit##NAME(  
\
+  static_cast(C), std::forward(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
-class CommentVisitor :
-public CommentVisitorBase {};
-
-template
-class ConstCommentVisitor :
-public CommentVisitorBase {};
+template 
+class CommentVisitor
+: public CommentVisitorBase {};
+
+template 
+class ConstCommentVisitor
+: public CommentVisitorBase 
{
+};
 
 } // namespace comments
 } // namespace clang


Index: cfe/trunk/include/clang/AST/CommentVisitor.h
===
--- cfe/trunk/include/clang/AST/CommentVisitor.h
+++ cfe/trunk/include/clang/AST/CommentVisitor.h
@@ -19,14 +19,16 @@
 template  struct make_ptr { using type = T *; };
 template  struct make_const_ptr { using type = const T *; };
 
-template class Ptr, typename ImplClass, typename RetTy=void>
+template  class Ptr, typename ImplClass,
+  typename RetTy = void, class... ParamTys>
 class CommentVisitorBase {
 public:
 #define PTR(CLASS) typename Ptr::type
-#define DISPATCH(NAME, CLASS) \
- return static_cast(this)->visit ## NAME(static_cast(C))
+#define DISPATCH(NAME, CLASS)  \
+  return static_cast(this)->visit##NAME(  \
+  static_cast(C), std::forward(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
-class CommentVisitor :
-public CommentVisitorBase {};
-
-template
-class ConstCommentVisitor :
-public CommentVisitorBase {};
+template 
+class CommentVisitor
+: public CommentVisitorBase {};
+
+template 
+class ConstCommentVisitor
+: public CommentVisitorBase {
+};
 
 } // namespace comments
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55069: Extend the CommentVisitor with parameter types

2018-11-30 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

In D55069#1314508 , @steveire wrote:

> > Huh, that's surprising. It's a perfect forwarding reference
>
> It's not a forwarding reference because the template parameter is from the 
> record, not the function. See
>
>   https://godbolt.org/z/L4N2aS


Ah, you're exactly right! I hadn't picked up on that.

>> One of the reasons I think this may be important is with the JSON dumper -- 
>> it may pass around JSON values rather than references and rely on move 
>> semantics to make this work.
> 
> I don't know what you're planning so I can't imagine what you want to pass 
> through these visit function parameters. It would be surprising to me if you 
> used this feature of the visitor for json dumping.

It can be dealt with if/when it arises.

LGTM!


Repository:
  rC Clang

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

https://reviews.llvm.org/D55069



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55069: Extend the CommentVisitor with parameter types

2018-11-30 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

> Huh, that's surprising. It's a perfect forwarding reference

It's not a forwarding reference because the template parameter is from the 
record, not the function. See

https://godbolt.org/z/L4N2aS

> One of the reasons I think this may be important is with the JSON dumper -- 
> it may pass around JSON values rather than references and rely on move 
> semantics to make this work.

I don't know what you're planning so I can't imagine what you want to pass 
through these visit function parameters. It would be surprising to me if you 
used this feature of the visitor for json dumping.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55069



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55069: Extend the CommentVisitor with parameter types

2018-11-30 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D55069#1313591 , @steveire wrote:

> The follow-up patch didn't build anymore with the `&&`.
>
>   ../tools/clang/lib/AST/ASTDumper.cpp:2672:75: error: cannot bind rvalue 
> reference of type ‘const clang::comments::FullComment*&&’ to lvalue of type 
> ‘const clang::comments::FullComment* const’
>ConstCommentVisitor::visit(C, 
> FC);
>  
>


Huh, that's surprising. It's a perfect forwarding reference and that use would 
be binding an lvalue reference, not an rvalue reference (I believe -- it's a 
bit hard to tell given that the patch with the uses is split out). Did you 
update both `visit()` and `visitComment()`? I just noticed that StmtVisitor 
also does not use perfect forwarding, so perhaps this isn't critical, but I'm 
curious as to why this doesn't behave as expected. One of the reasons I think 
this may be important is with the JSON dumper -- it may pass around JSON values 
rather than references and rely on move semantics to make this work.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55069



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55069: Extend the CommentVisitor with parameter types

2018-11-29 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

Ah, `test/Misc/ast-dump-comment.cpp` is existing test coverage for this indeed, 
great.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55069



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55069: Extend the CommentVisitor with parameter types

2018-11-29 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

The follow-up patch didn't build anymore with the `&&`.

  ../tools/clang/lib/AST/ASTDumper.cpp:2672:75: error: cannot bind rvalue 
reference of type ‘const clang::comments::FullComment*&&’ to lvalue of type 
‘const clang::comments::FullComment* const’
   ConstCommentVisitor::visit(C, FC);


Repository:
  rC Clang

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

https://reviews.llvm.org/D55069



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55069: Extend the CommentVisitor with parameter types

2018-11-29 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 175962.
steveire added a comment.

Add &&


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  struct make_ptr { using type = T *; };
 template  struct make_const_ptr { using type = const T *; };
 
-template class Ptr, typename ImplClass, typename 
RetTy=void>
+template  class Ptr, typename ImplClass,
+  typename RetTy = void, class... ParamTys>
 class CommentVisitorBase {
 public:
 #define PTR(CLASS) typename Ptr::type
-#define DISPATCH(NAME, CLASS) \
- return static_cast(this)->visit ## 
NAME(static_cast(C))
+#define DISPATCH(NAME, CLASS)  
\
+  return static_cast(this)->visit##NAME(  
\
+  static_cast(C), std::forward(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
-class CommentVisitor :
-public CommentVisitorBase {};
+template 
+class CommentVisitor
+: public CommentVisitorBase {};
 
-template
-class ConstCommentVisitor :
-public CommentVisitorBase {};
+template 
+class ConstCommentVisitor
+: public CommentVisitorBase 
{
+};
 
 } // 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  struct make_ptr { using type = T *; };
 template  struct make_const_ptr { using type = const T *; };
 
-template class Ptr, typename ImplClass, typename RetTy=void>
+template  class Ptr, typename ImplClass,
+  typename RetTy = void, class... ParamTys>
 class CommentVisitorBase {
 public:
 #define PTR(CLASS) typename Ptr::type
-#define DISPATCH(NAME, CLASS) \
- return static_cast(this)->visit ## NAME(static_cast(C))
+#define DISPATCH(NAME, CLASS)  \
+  return static_cast(this)->visit##NAME(  \
+  static_cast(C), std::forward(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
-class CommentVisitor :
-public CommentVisitorBase {};
+template 
+class CommentVisitor
+: public CommentVisitorBase {};
 
-template
-class ConstCommentVisitor :
-public CommentVisitorBase {};
+template 
+class ConstCommentVisitor
+: public CommentVisitorBase {
+};
 
 } // namespace comments
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55069: Extend the CommentVisitor with parameter types

2018-11-29 Thread Stephen Kelly via Phabricator via cfe-commits
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  struct make_ptr { using type = T *; };
 template  struct make_const_ptr { using type = const T *; };
 
-template class Ptr, typename ImplClass, typename 
RetTy=void>
+template  class Ptr, typename ImplClass,
+  typename RetTy = void, class... ParamTys>
 class CommentVisitorBase {
 public:
 #define PTR(CLASS) typename Ptr::type
-#define DISPATCH(NAME, CLASS) \
- return static_cast(this)->visit ## 
NAME(static_cast(C))
+#define DISPATCH(NAME, CLASS)  
\
+  return static_cast(this)->visit##NAME(  
\
+  static_cast(C), std::forward(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
-class CommentVisitor :
-public CommentVisitorBase {};
+template 
+class CommentVisitor
+: public CommentVisitorBase {};
 
-template
-class ConstCommentVisitor :
-public CommentVisitorBase {};
+template 
+class ConstCommentVisitor
+: public CommentVisitorBase 
{
+};
 
 } // 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  struct make_ptr { using type = T *; };
 template  struct make_const_ptr { using type = const T *; };
 
-template class Ptr, typename ImplClass, typename RetTy=void>
+template  class Ptr, typename ImplClass,
+  typename RetTy = void, class... ParamTys>
 class CommentVisitorBase {
 public:
 #define PTR(CLASS) typename Ptr::type
-#define DISPATCH(NAME, CLASS) \
- return static_cast(this)->visit ## NAME(static_cast(C))
+#define DISPATCH(NAME, CLASS)  \
+  return static_cast(this)->visit##NAME(  \
+  static_cast(C), std::forward(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
-class CommentVisitor :
-public CommentVisitorBase {};
+template 
+class CommentVisitor
+: public CommentVisitorBase {};
 
-template
-class ConstCommentVisitor :
-public CommentVisitorBase {};
+template 
+class ConstCommentVisitor
+: public CommentVisitorBase {
+};
 
 } // namespace comments
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55069: Extend the CommentVisitor with parameter types

2018-11-29 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

I'm not aware of existing test coverage for any of this.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55069



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55069: Extend the CommentVisitor with parameter types

2018-11-29 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 175960.
steveire added a comment.

Add &&


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  struct make_ptr { using type = T *; };
 template  struct make_const_ptr { using type = const T *; };
 
-template class Ptr, typename ImplClass, typename 
RetTy=void>
+template  class Ptr, typename ImplClass,
+  typename RetTy = void, class... ParamTys>
 class CommentVisitorBase {
 public:
 #define PTR(CLASS) typename Ptr::type
-#define DISPATCH(NAME, CLASS) \
- return static_cast(this)->visit ## 
NAME(static_cast(C))
+#define DISPATCH(NAME, CLASS)  
\
+  return static_cast(this)->visit##NAME(  
\
+  static_cast(C), std::forward(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
-class CommentVisitor :
-public CommentVisitorBase {};
+template 
+class CommentVisitor
+: public CommentVisitorBase {};
 
-template
-class ConstCommentVisitor :
-public CommentVisitorBase {};
+template 
+class ConstCommentVisitor
+: public CommentVisitorBase 
{
+};
 
 } // 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  struct make_ptr { using type = T *; };
 template  struct make_const_ptr { using type = const T *; };
 
-template class Ptr, typename ImplClass, typename RetTy=void>
+template  class Ptr, typename ImplClass,
+  typename RetTy = void, class... ParamTys>
 class CommentVisitorBase {
 public:
 #define PTR(CLASS) typename Ptr::type
-#define DISPATCH(NAME, CLASS) \
- return static_cast(this)->visit ## NAME(static_cast(C))
+#define DISPATCH(NAME, CLASS)  \
+  return static_cast(this)->visit##NAME(  \
+  static_cast(C), std::forward(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
-class CommentVisitor :
-public CommentVisitorBase {};
+template 
+class CommentVisitor
+: public CommentVisitorBase {};
 
-template
-class ConstCommentVisitor :
-public CommentVisitorBase {};
+template 
+class ConstCommentVisitor
+: public CommentVisitorBase {
+};
 
 } // namespace comments
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55069: Extend the CommentVisitor with parameter types

2018-11-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D55069#1313276 , @aaron.ballman 
wrote:

> Overall this seems reasonable, but this change is currently a no-op because 
> nothing is using this -- what's the plan for using and testing these changes?


The answer is: D55070 , which is NFC and 
presumably already has test coverage for it.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55069



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55069: Extend the CommentVisitor with parameter types

2018-11-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Overall this seems reasonable, but this change is currently a no-op because 
nothing is using this -- what's the plan for using and testing these changes?




Comment at: include/clang/AST/CommentVisitor.h:31
 
-  RetTy Visit(PTR(Comment) C) {
+  RetTy Visit(PTR(Comment) C, ParamTys... P) {
 if (!C)

Should this be `ParamTys&&...` because we're forwarding in the actual call? 
(Similar below)


Repository:
  rC Clang

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

https://reviews.llvm.org/D55069



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55069: Extend the CommentVisitor with parameter types

2018-11-29 Thread Stephen Kelly via Phabricator via cfe-commits
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  struct make_ptr { using type = T *; };
 template  struct make_const_ptr { using type = const T *; };
 
-template class Ptr, typename ImplClass, typename 
RetTy=void>
+template  class Ptr, typename ImplClass,
+  typename RetTy = void, class... ParamTys>
 class CommentVisitorBase {
 public:
 #define PTR(CLASS) typename Ptr::type
 #define DISPATCH(NAME, CLASS)  
\
-  return static_cast(this)->Visit##NAME(static_cast(C))
+  return static_cast(this)->Visit##NAME(  
\
+  static_cast(C), std::forward(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
-class CommentVisitor :
-public CommentVisitorBase {};
+template 
+class CommentVisitor
+: public CommentVisitorBase {};
 
-template
-class ConstCommentVisitor :
-public CommentVisitorBase {};
+template 
+class ConstCommentVisitor
+: public CommentVisitorBase 
{
+};
 
 } // 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  struct make_ptr { using type = T *; };
 template  struct make_const_ptr { using type = const T *; };
 
-template class Ptr, typename ImplClass, typename RetTy=void>
+template  class Ptr, typename ImplClass,
+  typename RetTy = void, class... ParamTys>
 class CommentVisitorBase {
 public:
 #define PTR(CLASS) typename Ptr::type
 #define DISPATCH(NAME, CLASS)  \
-  return static_cast(this)->Visit##NAME(static_cast(C))
+  return static_cast(this)->Visit##NAME(  \
+  static_cast(C), std::forward(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
-class CommentVisitor :
-public CommentVisitorBase {};
+template 
+class CommentVisitor
+: public CommentVisitorBase {};
 
-template
-class ConstCommentVisitor :
-public CommentVisitorBase {};
+template 
+class ConstCommentVisitor
+: public CommentVisitorBase {
+};
 
 } // namespace comments
 } // namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits