[cfe-users] TemplateSpecializationType bug?

Pouet fourtytwo via cfe-users cfe-users at lists.llvm.org
Wed Aug 16 02:10:28 PDT 2017


Hi cfe-users,

I'm quite new to this list, I guess this is the right place to post; if
not, please, let me know.

I'm using clang tooling to get the clang AST from C++11 code. I'm having
trouble with a TemplateSpecializationType in the following source code :
------------------------------------------------------------
-------------------------------------------------------
template<typename _T> struct S;
template<template<_U> class _C, typename _T> struct S<_C<_T>> {};
------------------------------------------------------------
-------------------------------------------------------

The second declaration is a template specialization of the first
declaration which template argument is an instantiation of a template
template parameter (1st template parameter) with the second template
parameter.
Clang AST shows the template argument as being the second template
parameter in the following dump ("clang -Xclang -ast-dump -fsyntax-only
..."), which seems incorrect:
-------------------------------------------------------------------------------------------------------------------
... (ClassTemplateDecl for 1st declaration of struct S)
`-ClassTemplatePartialSpecializationDecl 0x... <line:..., col:...> ...
struct S definition
  |-TemplateArgument type '<type-parameter-0-1>'
  |-TemplateTemplateParmDecl 0x... <line:..., col:...> ... _C
  | `-TemplateTypeParmDecl 0x... <line:..., col:...> ... typename _U
  |-TemplateTypeParmDecl 0x... <line:..., col:...> ...referenced typename _T
  `-CXXRecordDecl 0x... <line:..., col:...> ... implicit struct S
-------------------------------------------------------------------------------------------------------------------

On the other hand, in the AST clang builds, it appears that
TemplateArgument type '<type-parameter-0-1>' has type
TemplateSpecializationType whose TemplateName (getTemplateName()) is a
TemplateDecl (getKind() and getAsTemplateDecl()). The TemplateDecl is a
bogus TemplateTemplateParmDecl which has no name, whereas it should be the
"_C" TemplateTemplateParmDecl.

Is this a bug?
Has it been reported?
Should I report it myself? (How should I do?)
I could not find any information. Please let me know.
Note that the source code seems to compile ok (clang does not crash).
Regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20170816/01ab648f/attachment.html>


More information about the cfe-users mailing list