[cfe-dev] Explicit Template Arguments in DeclRefExpressions

Lukas Vogel lukedirtwalkerdev at gmail.com
Sun Jun 23 10:35:55 PDT 2013


Hi,

I'm trying to translate Template arguments (as part of a source to source
translation tool).  Therefore I need only to consider explicit arguments
(as written in the source)

However the TemplateArgument I receive always have random kind numbers
(when static casting to int and print them) therefore I never get the kind
of the argument and can't translate the arguments.

My code looks as follows

if(declRefExpr->hasExplicitTemplateArgs())

{

  unsigned templateArgs = declRefExpr->getNumTemplateArgs();

  auto astTemplateArgsList = declRefExpr->getExplicitTemplateArgs();

  for(unsigned i = 0; i < templateArgs; i++)

	astTemplateArgsList[i].getArgument()

 }

Does anyone see what is wrong with this code or where could be the error?

Furthermore I looked into the implementation of getTemplateArgs()  (which
is called by the [] operator)
http://clang.llvm.org/doxygen/TemplateBase_8h_source.html#l00561 there it
is just return "this+1"  with a cast which is quite un-intuitive but I
guess it is correct?

Thanks for any help.

Lukas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130623/eae0d629/attachment.html>


More information about the cfe-dev mailing list