[cfe-dev] ClassTemplateSpecializationDecl hasDefinition() == false, how to make it true?

Kris Rasmussen via cfe-dev cfe-dev at lists.llvm.org
Wed Apr 27 13:47:11 PDT 2016


I learned that the issue here is that ```BarInt``` is an incomplete type
because no on has looked at its members. Is there a way to force the
instantiation at parse/AST traversal time even if it isn't instantiated by
the code being parsed directly?

Thanks,
Kris

On Wed, Apr 27, 2016 at 9:29 AM, Kris Rasmussen <
kristopher.rasmussen at gmail.com> wrote:

> Hi,
>
> Is anyone able to help me figure out how to ensure
> ClassTemplateSpecializationDecls always have definitions so that I can
> properly inspect there members with the appropriate type substitutions? I
> am visiting template instantiations via
> ```shouldVisitTemplateInstantiations() { return true; }```, but I'm finding
> that they do not always have a definition attached to them.
>
> I'm porting a code generation tool from the python clang bindings to C++
> using ClangTool and RecursiveASTVisitor. My tool generates lua bindings
> from C++ source code. It needs to generate bindings for template
> instantiations, and requires knowledge of the template arguments in order
> to do so.
>
> This code will result in a ClassTemplateSpecializationDecl that is missing
> its definition (hasDefinition() == false):
>
> ```
>   template<typename T>
>   class Bar {
>   public:
>     T m_t;
>   };
>   using BarInt = Bar<int>;
> ```
>
> Whereas this code will result in hasDefinition() == true as I want:
> ```
>   class Foo : public Bar<int> {};
> ```
>
> Thanks for any help you can provide! I've searched the net for answers,
> and also browsed the clang source code, but I'll admit that I haven't dug
> deeply enough yet to figure out exactly which code path is triggering the
> instantiations that are missing definitions yet.
>
> Thanks,
> Kris
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160427/f53895c5/attachment.html>


More information about the cfe-dev mailing list