llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.59k stars 11.81k forks source link

[question] How to create visitor for template specialization? #73653

Open harsszegi opened 10 months ago

harsszegi commented 10 months ago

Hi,

when I dump the AST with clang I can clearly see the ClassTemplateSpecializationDecl and all the specialized member functions, constructors, etc. with CXXMethodDecl and CXXConstructorDecl and all the parameters are specialized already.

How can I achieve the same with VisitChildren? If I visit a cursor which is CX_DeclKind.CX_DeclKind_ClassTemplateSpecialization, I get TSK_Undeclared for the specializationkind, so nothing is visited. If I visit cursor's "SpecializedCursorTemplate", I receive the unspecialized template itself, which makes not much use for me. So how can I achieve the same outcome with visitors what I get with AST dump, .e.g. get the fully specialized template instance? Thanks,

llvmbot commented 10 months ago

@llvm/issue-subscribers-clang-frontend

Author: Tibor Harsszegi (harsszegi)

Hi, when I dump the AST with clang I can clearly see the ClassTemplateSpecializationDecl and all the specialized member functions, constructors, etc. with CXXMethodDecl and CXXConstructorDecl and all the parameters are specialized already. How can I achieve the same with VisitChildren? If I visit a cursor which is CX_DeclKind.CX_DeclKind_ClassTemplateSpecialization, I get TSK_Undeclared for the specializationkind, so nothing is visited. If I visit cursor's "SpecializedCursorTemplate", I receive the unspecialized template itself, which makes not much use for me. So how can I achieve the same outcome with visitors what I get with AST dump, .e.g. get the fully specialized template instance? Thanks,
EugeneZelenko commented 10 months ago

@PiotrZSL: Could you help, please?

PiotrZSL commented 10 months ago

To be honest. I never used cursors to visit AST, always directly with AstMatchers or RecursiveASTVisitor.