Find out if a function is called within a C++ project?

后端 未结 8 563
失恋的感觉
失恋的感觉 2021-02-01 19:15

I\'m trying to remove functions that are not used from a C++ project. Over time it\'s become bloated and I\'m looking to remove functions that aren\'t used at all.

I ha

8条回答
  •  遇见更好的自我
    2021-02-01 20:03

    If your code is simple enough static analysis might work. However C++ is very context-sensitive :/. So I personally would not even try to look for a tool in the area. At least not until CLANG is fully compliant with C++ :D

    I hope you have unit-tests, I would get visual studio to compile code which generates a runtime profile and then farm the function names's (with a scripting language) from the generated profile. If you have covered all of the use-cases (either manually or with unit-tests) in your application you should be able to identify the least used (or never-used) functions. Then you can use the mark-one eyeball to trim down the source-base.

    There is nothing like doing It manually though :D

提交回复
热议问题