templight icon indicating copy to clipboard operation
templight copied to clipboard

Templight not finding templates

Open eldiener opened this issue 9 years ago • 2 comments

I ran templight++ with the -Xtemplight -profiler option against a source file and it generated an appropriate .pbf file. I then ran templight_convert against the .pbf using '--format text' and it produced its text output file. But nowhere in this file is anything having to do with a class template which I am instantiating in the source file. Instead I see numerous TemplateBegin and TemplateEnd entries for constructs which are not templates at all, even though they are being used by my template code.

I am really baffled why templight++ is not working for me at all. Any thoughts or ideas would be appreciated.

eldiener avatar May 09 '15 18:05 eldiener

How are you instantiating the template? For instance, using a typedef is not sufficient. You should use either an explicit instantiation:

template my_class<something, something>;

Or, just use the template instantiation in a function (like main):

void main() {
  my_class< something, something > c;
  my_function< something, something >();
};

As for the numerous begin-end blocks for things that are not templates, these are memoizations which are meant to catch templates that have already been instantiated earlier (i.e., memoized by the compiler), but that feature has a lot of noise and catches a lot of non-template stuff (functions and classes). I hope to get rid of this noise one day, but I need input from people with more deep knowledge of the inner-workings of Clang to be able to fix this (i.e., filter out the non-template entities but catch all the memoized instantiations).

mikael-s-persson avatar May 09 '15 21:05 mikael-s-persson

I am using a template instantiation in a global variable.

#include <boost/test/unit_test.hpp>
#include <boost/property/property_member_data_value.hpp>
#include <libs/property/test/test_member_data_impl.cpp>

using namespace property;

p_member_data_class pmd_gl_int;

prop_member_data<int,p_member_data_class,&p_member_data_class::p_data_int>    p_gl_int(pmd_gl_int);

void TestInt()
{

p_gl_int = 34662;

BOOST_CHECK_EQUAL(p_gl_int,34662);

}

void test_member_data_value_function()
{
TestInt();
}

boost::unit_test::test_suite* init_unit_test_suite( int , char* [] )
{
boost::unit_test::test_suite* test = BOOST_TEST_SUITE( "Property Test Member Data Value Suite" );

test->add( BOOST_TEST_CASE( &test_member_data_value_function ) );

return test;
}

Neither prop_member_data<int,p_member_data_class,&p_member_data_class::p_data_int> is showing up as a template nor is the template classes in

<boost/property/property_member_data_value.hpp> 

showing up anywhere. This all compiles correctly using clang, although with some irrelevant warnings from lower-level Boost code.

This is my own code, not anything currently in Boost, for a library on which I am working. I won't discuss the library itself until I am completely finished, with code, tests, full documentation etc. I put the code in the latest boost tree for easy access to other Boost libraries which I am using. I was hoping I could use templight++ to tell me why some template code is not working the way I would expect.

eldiener avatar May 09 '15 22:05 eldiener