From d4525b016f5a1ab2852acb2108742b2f9d0bd3bd Mon Sep 17 00:00:00 2001 From: Egor Zhdan Date: Thu, 7 Nov 2024 23:25:33 +0000 Subject: [PATCH] [Clang] Dispatch default overloads of `TemplateArgumentVisitor` to the implementation This fixes an issue where overriding `clang::ConstTemplateArgumentVisitor::VisitTemplateArgument` in an implementation visitor class did not have the desired effect: the overload was not invoked when one of the visitor methods (e.g. `VisitDeclarationArgument`) is not implemented, instead it dispatched to `clang::ConstTemplateArgumentVisitor::VisitTemplateArgument` itself and always returned a default-initialized result. This makes `TemplateArgumentVisitor` and `ConstTemplateArgumentVisitor` follow the implicit convention that is followed elsewhere in Clang AST, in `RecursiveASTVisitor` and `TypeVisitor`. --- clang/include/clang/AST/TemplateArgumentVisitor.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/AST/TemplateArgumentVisitor.h b/clang/include/clang/AST/TemplateArgumentVisitor.h index cf0d3220158063..923f045a995703 100644 --- a/clang/include/clang/AST/TemplateArgumentVisitor.h +++ b/clang/include/clang/AST/TemplateArgumentVisitor.h @@ -52,7 +52,8 @@ class Base { #define VISIT_METHOD(CATEGORY) \ RetTy Visit##CATEGORY##TemplateArgument(REF(TemplateArgument) TA, \ ParamTys... P) { \ - return VisitTemplateArgument(TA, std::forward(P)...); \ + return static_cast(this)->VisitTemplateArgument( \ + TA, std::forward(P)...); \ } VISIT_METHOD(Null);