diff options
Diffstat (limited to 'include/clang/AST/CommentVisitor.h')
-rw-r--r-- | include/clang/AST/CommentVisitor.h | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/include/clang/AST/CommentVisitor.h b/include/clang/AST/CommentVisitor.h index d1cc2d0a4e5e1..e37e9d6cd2999 100644 --- a/include/clang/AST/CommentVisitor.h +++ b/include/clang/AST/CommentVisitor.h @@ -11,22 +11,21 @@ #define LLVM_CLANG_AST_COMMENTVISITOR_H #include "clang/AST/Comment.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/Support/ErrorHandling.h" namespace clang { namespace comments { - -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 +43,26 @@ public: // 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<std::add_pointer, 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<llvm::make_const_ptr, ImplClass, RetTy, + ParamTys...> {}; } // namespace comments } // namespace clang |