Clang API: specialise a class template and all its members

Hello all,

I have a clang::ClassTemplateDecl object with a single template argument. I want to specialise it for a certain type (void*). I use the following code:

clang::TemplateArgument t(C->getASTContext().VoidPtrTy);

auto CTSVoidStar = clang::ClassTemplateSpecializationDecl::Create(C->getASTContext(),

clang::TagTypeKind::TTK_Class, CTS->getDeclContext(), clang::SourceLocation(), clang::SourceLocation(),

CTS->getSpecializedTemplate(), &t, CTS->getTemplateArgs().size(), CTS);

where CTS->getSpecializedTemplate() is my ClassTemplateDecl. The problem with it is while according to CTSVoidStar->dump() it looks correct, it lacks any functions, and it’s the functions that I need - their mangled names in particular. I know for sure that my ClassTemplateDecl does have functions. My question is how to get a complete specialisation, with all members and not just the class itself. Thank you.


Dimitar Dobrev

Perhaps you could have a look at Ideally calling this interface with the right set of arguments would create a proper specialization or a diagnostic. --Vassil

Thank you for your reply. Have you ever used this API? If so, I would really appreciate a few lines of code because some of the parameters I have no idea how to get. Some, such as “TemplateParameterLists”, are all clear but where would I get Scope from, for example?

That’s the tricky part. One way to do this: construct a valid C++ example; compile it with a debug version of clang; attach gdb to it; set a breakpoint and investigate how those parameters get created. --Vassil

I understand. Thank you very much for your time.