How to filter out untouched code in C++
For dissecting/understanding huge template-heavy code base it would really useful to have a tool that tells me what class/code have made it to the final b开发者_StackOverflow中文版inary.
For example if there are two class A and B in the code but I only end up instantiating only A then I would somehow like to know filter out B. Are there any tools to achieve the same with template-based code.
Use some profiler/code coverage tools. Some versions of MS Visual Studio ship with profiler. Then there are several commercial profilers/coverage tools like Intel VTune. On *nix with GCC there is the gcov.
run doxygen to generate referral graph and see what class is not been referred
You can try using nm:
The nm utility shall display symbolic information appearing in the object file, executable file, or object-file
although using it and wading through its output is not very fun.
As a different approach, is it not possible to start browse/read/understand the caller code first to note down the classes that are used/included?
See my answer to the question i asked recently on SO.
The idea is to compile your code after having enabled the "showIncludes" compiler option, then deal with output to extract the information you need (either manually or automatically, using a python script, for example).
Doing this, i have been able to extract the exact code files that are used to build our software.
精彩评论