[cfe-dev] Insert static data member definitions

devkid devkid at devkid.net
Fri Dec 14 05:29:14 PST 2012


Hi!

I'm trying to add something reflection-like to C++ via a clang plugin. In
the test file that I want to compile I've got the following piece of code:



As you can see, I expect the "reflection" class template to provide a static
data member called "name" of the type const char*. The output here should
obviously be "MyTestClass". I have realized this so far:



Where "decl" is the corresponding CXXRecordDecl for the MyTestClass,
"reflectionDef" is the ClassTemplateDecl of the "reflection" template class,
"r.name" contains the name of the Class ("MyTestClass") and the
"instantiate" function is taken from this post: 
http://clang-developers.42468.n3.nabble.com/How-to-perform-template-substitution-in-the-clang-library-td4028413.html#a4028622
<http://clang-developers.42468.n3.nabble.com/How-to-perform-template-substitution-in-the-clang-library-td4028413.html#a4028622>  

When I run clang over the test code with my plugin loaded, it compiles just
fine, but the linker seems not being able to find the definition of the
"name" data member:


The relevant output of the decleration context dump:


Do I need to tell the Sema object that it has to instantiate the data member
correctly? (And if yes, how do I do this?)



--
View this message in context: http://clang-developers.42468.n3.nabble.com/Insert-static-data-member-definitions-tp4028995.html
Sent from the Clang Developers mailing list archive at Nabble.com.



More information about the cfe-dev mailing list