[cfe-dev] Explicit Template Arguments in DeclRefExpressions

Lukas Vogel lukedirtwalkerdev at gmail.com
Sun Jun 23 14:05:01 PDT 2013


Hm solved this myself by replacing

declRefExpr->getExplicitTemplateArgs();

with

declRefExpr->getExplicitTemplateArgs().getTemplateArgs();


which is weird considering the implementation of operator[] does the same?



2013/6/23 Lukas Vogel <lukedirtwalkerdev at gmail.com>

> 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/ab1585e8/attachment.html>


More information about the cfe-dev mailing list