Skip to content

Commit

Permalink
[Clang] Dispatch default overloads of TemplateArgumentVisitor to th…
Browse files Browse the repository at this point in the history
…e 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`.
  • Loading branch information
egorzhdan authored Nov 7, 2024
1 parent 1cb119b commit d4525b0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion clang/include/clang/AST/TemplateArgumentVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ class Base {
#define VISIT_METHOD(CATEGORY) \
RetTy Visit##CATEGORY##TemplateArgument(REF(TemplateArgument) TA, \
ParamTys... P) { \
return VisitTemplateArgument(TA, std::forward<ParamTys>(P)...); \
return static_cast<ImplClass *>(this)->VisitTemplateArgument( \
TA, std::forward<ParamTys>(P)...); \
}

VISIT_METHOD(Null);
Expand Down

0 comments on commit d4525b0

Please sign in to comment.